3 namespace Drupal\local_fonts;
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
7 use Symfony\Component\Routing\Route;
10 * Provides routes for Custom Font entities.
12 * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
13 * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
15 class LocalFontConfigEntityHtmlRouteProvider extends AdminHtmlRouteProvider {
20 public function getRoutes(EntityTypeInterface $entity_type) {
21 $collection = parent::getRoutes($entity_type);
23 $entity_type_id = $entity_type->id();
25 if ($collection_route = $this->getCollectionRoute($entity_type)) {
26 $collection->add("entity.{$entity_type_id}.collection", $collection_route);
33 * Gets the collection route.
35 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
38 * @return \Symfony\Component\Routing\Route|null
39 * The generated route, if available.
41 protected function getCollectionRoute(EntityTypeInterface $entity_type) {
42 if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
43 $entity_type_id = $entity_type->id();
44 $route = new Route($entity_type->getLinkTemplate('collection'));
47 '_entity_list' => $entity_type_id,
48 // Make sure this is not a TranslatableMarkup object as the
49 // TitleResolver translates this string again.
50 '_title' => (string) $entity_type->getLabel(),
52 ->setRequirement('_permission', $entity_type->getAdminPermission())
53 ->setOption('_admin_route', TRUE);