diff --git a/src/Entity/Group.php b/src/Entity/Group.php index 3404090da6c91eefdc895de083e895a9b3ce5c98..2ca7419f9046bdb9e928a60b9c890f2835200b4d 100644 --- a/src/Entity/Group.php +++ b/src/Entity/Group.php @@ -22,6 +22,7 @@ use Drupal\user\UserInterface; * label = @Translation("Group"), * label_singular = @Translation("group"), * label_plural = @Translation("groups"), + * label_collection = @Translation("Groups"), * label_count = @PluralTranslation( * singular = "@count group", * plural = "@count groups" @@ -43,7 +44,6 @@ use Drupal\user\UserInterface; * }, * "access" = "Drupal\group\Entity\Access\GroupAccessControlHandler", * }, - * admin_permission = "administer group", * base_table = "groups", * data_table = "groups_field_data", * revision_table = "groups_revision", diff --git a/src/Entity/GroupRole.php b/src/Entity/GroupRole.php index 56d0066b9ae83968adf5ef3c06fa3cfb408418a3..d8a231cbc780916a3514fe21a5a9e669512a1561 100644 --- a/src/Entity/GroupRole.php +++ b/src/Entity/GroupRole.php @@ -16,6 +16,7 @@ use Drupal\user\RoleInterface; * label = @Translation("Group role"), * label_singular = @Translation("group role"), * label_plural = @Translation("group roles"), + * label_collection = @Translation("Group roles"), * label_count = @PluralTranslation( * singular = "@count group role", * plural = "@count group roles" diff --git a/src/Entity/GroupType.php b/src/Entity/GroupType.php index 64dc6137891d6d074d1620f9736f1504e3e14198..b2c9c7d2f7e488d2f908d2c64f7298fe6d8decd1 100644 --- a/src/Entity/GroupType.php +++ b/src/Entity/GroupType.php @@ -15,6 +15,7 @@ use Drupal\group\PermissionScopeInterface; * label = @Translation("Group type"), * label_singular = @Translation("group type"), * label_plural = @Translation("group types"), + * label_collection = @Translation("Group types"), * label_count = @PluralTranslation( * singular = "@count group type", * plural = "@count group types" @@ -27,7 +28,7 @@ use Drupal\group\PermissionScopeInterface; * "delete" = "Drupal\group\Entity\Form\GroupTypeDeleteForm" * }, * "route_provider" = { - * "html" = "Drupal\group\Entity\Routing\GroupTypeRouteProvider", + * "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider", * }, * "list_builder" = "Drupal\group\Entity\Controller\GroupTypeListBuilder", * }, diff --git a/src/Entity/Routing/GroupRoleRouteProvider.php b/src/Entity/Routing/GroupRoleRouteProvider.php index 7daa620c1e44e9f335603f4c8e32b885c58da049..1a185e437a4da80150b07517afe2842fac799fda 100644 --- a/src/Entity/Routing/GroupRoleRouteProvider.php +++ b/src/Entity/Routing/GroupRoleRouteProvider.php @@ -49,9 +49,6 @@ class GroupRoleRouteProvider extends DefaultHtmlRouteProvider { */ protected function getCollectionRoute(EntityTypeInterface $entity_type) { if ($route = parent::getCollectionRoute($entity_type)) { - // @todo Remove title part when https://www.drupal.org/node/2767025 lands. - $route->setDefault('_title', 'Group roles'); - $route->setDefault('_title_arguments', []); $route->setOption('parameters', ['group_type' => ['type' => 'entity:group_type']]); return $route; } diff --git a/src/Entity/Routing/GroupRouteProvider.php b/src/Entity/Routing/GroupRouteProvider.php index 398cf84695f569d2597e73727f28ff28bc7c379d..6da695efedf1b724e1deb174e5db8fa8b674a5bd 100644 --- a/src/Entity/Routing/GroupRouteProvider.php +++ b/src/Entity/Routing/GroupRouteProvider.php @@ -4,6 +4,7 @@ namespace Drupal\group\Entity\Routing; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider; +use Symfony\Component\Routing\Route; /** * Provides routes for groups. @@ -56,11 +57,20 @@ class GroupRouteProvider extends DefaultHtmlRouteProvider { * {@inheritdoc} */ protected function getCollectionRoute(EntityTypeInterface $entity_type) { - // @todo Remove this method when https://www.drupal.org/node/2767025 lands. - if ($route = parent::getCollectionRoute($entity_type)) { - $route->setDefault('_title', 'Groups'); - $route->setDefault('_title_arguments', []); - $route->setRequirement('_permission', 'access group overview'); + if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) { + /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */ + $label = $entity_type->getCollectionLabel(); + + $route = new Route($entity_type->getLinkTemplate('collection')); + $route + ->addDefaults([ + '_entity_list' => $entity_type->id(), + '_title' => $label->getUntranslatedString(), + '_title_arguments' => $label->getArguments(), + '_title_context' => $label->getOption('context'), + ]) + ->setRequirement('_permission', 'access group overview'); + return $route; } } diff --git a/src/Entity/Routing/GroupTypeRouteProvider.php b/src/Entity/Routing/GroupTypeRouteProvider.php deleted file mode 100644 index a4b175824ae1c007ed5a26429e725f4e6d753bf0..0000000000000000000000000000000000000000 --- a/src/Entity/Routing/GroupTypeRouteProvider.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -namespace Drupal\group\Entity\Routing; - -use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider; - -/** - * Provides routes for group types. - */ -class GroupTypeRouteProvider extends DefaultHtmlRouteProvider { - - /** - * {@inheritdoc} - */ - protected function getCollectionRoute(EntityTypeInterface $entity_type) { - // @todo Remove this method when https://www.drupal.org/node/2767025 lands. - if ($route = parent::getCollectionRoute($entity_type)) { - $route->setDefault('_title', 'Group types'); - $route->setDefault('_title_arguments', []); - return $route; - } - } - -}