You are here

protected function GroupContentListBuilder::getDefaultOperations in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Controller/GroupContentListBuilder.php \Drupal\group\Entity\Controller\GroupContentListBuilder::getDefaultOperations()

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides EntityListBuilder::getDefaultOperations

File

src/Entity/Controller/GroupContentListBuilder.php, line 133

Class

GroupContentListBuilder
Provides a list controller for group content entities.

Namespace

Drupal\group\Entity\Controller

Code

protected function getDefaultOperations(EntityInterface $entity) {

  /** @var \Drupal\group\Entity\GroupContentInterface $entity */
  $operations = parent::getDefaultOperations($entity);

  // Improve the edit and delete operation labels.
  if (isset($operations['edit'])) {
    $operations['edit']['title'] = $this
      ->t('Edit relation');
  }
  if (isset($operations['delete'])) {
    $operations['delete']['title'] = $this
      ->t('Delete relation');
  }

  // Slap on redirect destinations for the administrative operations.
  $destination = $this->redirectDestination
    ->getAsArray();
  foreach ($operations as $key => $operation) {
    $operations[$key]['query'] = $destination;
  }

  // Add an operation to view the actual entity.
  if ($entity
    ->getEntity()
    ->access('view') && $entity
    ->getEntity()
    ->hasLinkTemplate('canonical')) {
    $operations['view'] = [
      'title' => $this
        ->t('View entity'),
      'weight' => 101,
      'url' => $entity
        ->getEntity()
        ->toUrl('canonical'),
    ];
  }
  return $operations;
}