You are here

protected function ListUsageController::getSourceEntityStatus in Entity Usage 8.2

Same name and namespace in other branches
  1. 8.4 src/Controller/ListUsageController.php \Drupal\entity_usage\Controller\ListUsageController::getSourceEntityStatus()

Retrieve the source entity's status.

Parameters

\Drupal\Core\Entity\EntityInterface $source_entity: The source entity.

Return value

string The entity's status.

1 call to ListUsageController::getSourceEntityStatus()
ListUsageController::getRows in src/Controller/ListUsageController.php
Retrieve all usage rows for this target entity.

File

src/Controller/ListUsageController.php, line 293

Class

ListUsageController
Controller for our pages.

Namespace

Drupal\entity_usage\Controller

Code

protected function getSourceEntityStatus(EntityInterface $source_entity) {

  // Treat paragraph entities in a special manner. Paragraph entities
  // should get their host (parent) entity's status.
  if ($source_entity
    ->getEntityTypeId() == 'paragraph') {

    /** @var \Drupal\paragraphs\ParagraphInterface $source_entity */
    $parent = $source_entity
      ->getParentEntity();
    if (!empty($parent)) {
      return $this
        ->getSourceEntityStatus($parent);
    }
  }
  if (isset($source_entity->status)) {
    $published = !empty($source_entity->status->value) ? $this
      ->t('Published') : $this
      ->t('Unpublished');
  }
  else {
    $published = '';
  }
  return $published;
}