You are here

public function GroupTypeListBuilder::getDefaultOperations in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Controller/GroupTypeListBuilder.php \Drupal\group\Entity\Controller\GroupTypeListBuilder::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 ConfigEntityListBuilder::getDefaultOperations

File

src/Entity/Controller/GroupTypeListBuilder.php, line 44

Class

GroupTypeListBuilder
Defines a class to build a listing of group type entities.

Namespace

Drupal\group\Entity\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);

  // Place the group type specific operations after the operations added by
  // field_ui.module which have the weights 15, 20, 25.
  if (isset($operations['edit'])) {
    $operations['edit']['weight'] = 30;
  }
  if ($entity
    ->hasLinkTemplate('permissions-form')) {
    $operations['permissions'] = [
      'title' => $this
        ->t('Edit permissions'),
      'weight' => 35,
      'url' => $entity
        ->toUrl('permissions-form'),
    ];
  }

  // Can't use a link template because the group roles route doesn't start
  // with entity.group_type, see: https://www.drupal.org/node/2645136.
  $operations['group_roles'] = [
    'title' => $this
      ->t('Edit group roles'),
    'weight' => 40,
    'url' => Url::fromRoute('entity.group_role.collection', [
      'group_type' => $entity
        ->id(),
    ]),
  ];
  if ($entity
    ->hasLinkTemplate('content-plugins')) {
    $operations['content'] = [
      'title' => $this
        ->t('Set available content'),
      'weight' => 45,
      'url' => $entity
        ->toUrl('content-plugins'),
    ];
  }
  return $operations;
}