You are here

public function DataPolicy::entityOverviewPage in Data Policy 8

Show description of data policy.

Return value

array The data policy description text.

1 string reference to 'DataPolicy::entityOverviewPage'
data_policy.routing.yml in ./data_policy.routing.yml
data_policy.routing.yml

File

src/Controller/DataPolicy.php, line 109

Class

DataPolicy
Class DataPolicy.

Namespace

Drupal\data_policy\Controller

Code

public function entityOverviewPage() {
  $entity_id = $this->request
    ->get('id');
  if (!empty($entity_id)) {
    $entity = $this
      ->entityTypeManager()
      ->getStorage('data_policy')
      ->load($entity_id);

    // Get translation for the current language.
    $entity = $this->entityRepository
      ->getTranslationFromContext($entity);
    $description = $entity
      ->get('field_description')
      ->view([
      'label' => 'hidden',
    ]);
    return [
      '#theme' => 'data_policy_data_policy',
      '#content' => $description,
    ];
  }
  $entity_ids = $this->dataPolicyConsentManager
    ->getEntityIdsFromConsentText();
  $links = [];
  foreach ($entity_ids as $entity_id) {

    /** @var \Drupal\data_policy\Entity\DataPolicyInterface $entity */
    $entity = $this
      ->entityTypeManager()
      ->getStorage('data_policy')
      ->load($entity_id);

    // Get translation for the current language.
    $entity = $this->entityRepository
      ->getTranslationFromContext($entity);
    $links[] = Link::createFromRoute($entity
      ->getName(), 'entity.data_policy.revision', [
      'entity_id' => $entity
        ->id(),
      'data_policy_revision' => $entity
        ->getRevisionId(),
    ]);
  }
  return [
    '#title' => $this
      ->t('Active revisions'),
    '#theme' => 'item_list',
    '#items' => $links,
  ];
}