You are here

protected function SocialGroupContentListBuilder::getDefaultOperations in Open Social 8

Same name and namespace in other branches
  1. 8.2 modules/social_features/social_group/src/Controller/SocialGroupContentListBuilder.php \Drupal\social_group\Controller\SocialGroupContentListBuilder::getDefaultOperations()
  2. 8.3 modules/social_features/social_group/src/Controller/SocialGroupContentListBuilder.php \Drupal\social_group\Controller\SocialGroupContentListBuilder::getDefaultOperations()
  3. 8.4 modules/social_features/social_group/src/Controller/SocialGroupContentListBuilder.php \Drupal\social_group\Controller\SocialGroupContentListBuilder::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

modules/social_features/social_group/src/Controller/SocialGroupContentListBuilder.php, line 155

Class

SocialGroupContentListBuilder
Provides a list controller for group content from GroupContentListBuilder.

Namespace

Drupal\social_group\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');
  }
  if (isset($operations['delete'])) {
    $operations['delete']['title'] = $this
      ->t('Remove');
  }

  // 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'),
      'weight' => 101,
      'url' => $entity
        ->getEntity()
        ->toUrl('canonical'),
    ];
  }
  return $operations;
}