Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / fontyourface / src / FontDisplayHtmlRouteProvider.php
1 <?php
2
3 namespace Drupal\fontyourface;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
7 use Symfony\Component\Routing\Route;
8
9 /**
10  * Provides routes for Font display entities.
11  *
12  * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
13  * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
14  */
15 class FontDisplayHtmlRouteProvider extends AdminHtmlRouteProvider {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function getRoutes(EntityTypeInterface $entity_type) {
21     $collection = parent::getRoutes($entity_type);
22
23     $entity_type_id = $entity_type->id();
24
25     if ($collection_route = $this->getCollectionRoute($entity_type)) {
26       $collection->add("entity.{$entity_type_id}.collection", $collection_route);
27     }
28
29     if ($add_form_route = $this->getAddFormRoute($entity_type)) {
30       $collection->add("entity.{$entity_type_id}.add_form", $add_form_route);
31     }
32
33     return $collection;
34   }
35
36   /**
37    * Gets the collection route.
38    *
39    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
40    *   The entity type.
41    *
42    * @return \Symfony\Component\Routing\Route|null
43    *   The generated route, if available.
44    */
45   protected function getCollectionRoute(EntityTypeInterface $entity_type) {
46     if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
47       $entity_type_id = $entity_type->id();
48       $route = new Route($entity_type->getLinkTemplate('collection'));
49       $route
50         ->setDefaults([
51           '_entity_list' => $entity_type_id,
52           // Make sure this is not a TranslatableMarkup object as the
53           // TitleResolver translates this string again.
54           '_title' => (string) $entity_type->getLabel(),
55         ])
56         ->setRequirement('_permission', $entity_type->getAdminPermission())
57         ->setOption('_admin_route', TRUE);
58
59       return $route;
60     }
61   }
62
63   /**
64    * Gets the add-form route.
65    *
66    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
67    *   The entity type.
68    *
69    * @return \Symfony\Component\Routing\Route|null
70    *   The generated route, if available.
71    */
72   protected function getAddFormRoute(EntityTypeInterface $entity_type) {
73     if ($entity_type->hasLinkTemplate('add-form')) {
74       $entity_type_id = $entity_type->id();
75       $route = new Route($entity_type->getLinkTemplate('add-form'));
76       // Use the add form handler, if available, otherwise default.
77       $operation = 'default';
78       if ($entity_type->getFormClass('add')) {
79         $operation = 'add';
80       }
81       $route
82         ->setDefaults([
83           '_entity_form' => "{$entity_type_id}.{$operation}",
84           '_title' => "Add {$entity_type->getLabel()}",
85         ])
86         ->setRequirement('_entity_create_access', $entity_type_id)
87         ->setOption('parameters', [
88           $entity_type_id => ['type' => 'entity:' . $entity_type_id],
89         ])
90         ->setOption('_admin_route', TRUE);
91
92       return $route;
93     }
94   }
95
96 }