protected function GroupListBuilder::getDefaultOperations in Group 8
Same name and namespace in other branches
- 2.0.x src/Entity/Controller/GroupListBuilder.php \Drupal\group\Entity\Controller\GroupListBuilder::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/ GroupListBuilder.php, line 166
Class
- GroupListBuilder
- Provides a list controller for group entities.
Namespace
Drupal\group\Entity\ControllerCode
protected function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
/** @var \Drupal\group\Entity\GroupInterface $entity */
if ($this->moduleHandler
->moduleExists('views') && $entity
->hasPermission('administer members', $this->currentUser)) {
if ($this->router
->getRouteCollection()
->get('view.group_members.page_1') !== NULL) {
$operations['members'] = [
'title' => $this
->t('Members'),
'weight' => 15,
'url' => Url::fromRoute('view.group_members.page_1', [
'group' => $entity
->id(),
]),
];
}
}
if ($entity
->getGroupType()
->shouldCreateNewRevision() && $entity
->hasPermission('view group revisions', $this->currentUser)) {
$operations['revisions'] = [
'title' => $this
->t('Revisions'),
'weight' => 20,
'url' => $entity
->toUrl('version-history'),
];
}
// Add the current path or destination as a redirect to the operation links.
$destination = $this->redirectDestination
->getAsArray();
foreach ($operations as $key => $operation) {
$operations[$key]['query'] = $destination;
}
return $operations;
}