You are here

protected function GroupMenuContentListBuilder::getDefaultOperations in Group Menu 8

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 GroupContentListBuilder::getDefaultOperations

File

src/GroupMenuContentListBuilder.php, line 79

Class

GroupMenuContentListBuilder
Provides a list controller for menus entities in a group.

Namespace

Drupal\groupmenu

Code

protected function getDefaultOperations(EntityInterface $entity) {

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

  // Add view operation for the Group Content Relation.
  if (!isset($operations['view']) && $entity
    ->access('view')) {
    $operations['view'] = [
      'title' => $this
        ->t('View relation'),
      'weight' => 1,
      'url' => $entity
        ->toUrl(),
    ];
  }

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

  // Add operations to edit and delete the actual entity.
  if ($entity
    ->getEntity()
    ->access('update')) {
    $operations['edit-entity'] = [
      'title' => $this
        ->t('Edit menu'),
      'weight' => 102,
      'url' => $entity
        ->getEntity()
        ->toUrl(),
    ];
  }
  if ($entity
    ->getEntity()
    ->access('delete')) {
    $operations['delete-entity'] = [
      'title' => $this
        ->t('Delete menu'),
      'weight' => 103,
      'url' => $entity
        ->getEntity()
        ->toUrl('delete-form'),
    ];
  }
  return $operations;
}