Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / diff / src / Routing / DiffRouteProvider.php
1 <?php
2
3 namespace Drupal\diff\Routing;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Entity\Routing\EntityRouteProviderInterface;
7 use Symfony\Component\Routing\Route;
8 use Symfony\Component\Routing\RouteCollection;
9
10 /**
11  * Contains routes for diff functionality.
12  */
13 class DiffRouteProvider implements EntityRouteProviderInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getRoutes(EntityTypeInterface $entity_type) {
19     $collection = new RouteCollection();
20     if ($route = $this->getDiffRoute($entity_type)) {
21       $collection->add('entity.' . $entity_type->id() . '.revisions_diff', $route);
22     }
23     return $collection;
24   }
25
26   /**
27    * Constructs the diff route.
28    *
29    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
30    *   The entity type.
31    *
32    * @return \Symfony\Component\Routing\Route|null
33    *   The diff route.
34    */
35   protected function getDiffRoute(EntityTypeInterface $entity_type) {
36     if ($entity_type->hasLinkTemplate('revisions-diff')) {
37       $route = new Route($entity_type->getLinkTemplate('revisions-diff'));
38       $route->addDefaults([
39         '_controller' => '\Drupal\diff\Controller\PluginRevisionController::compareEntityRevisions',
40         'filter' => 'split_fields',
41       ]);
42       $route->addRequirements([
43         '_entity_access' => $entity_type->id() . '.view',
44       ]);
45       $route->setOption('parameters', [
46         $entity_type->id() => ['type' => 'entity:' . $entity_type->id()],
47         'left_revision' => ['type' => 'entity_revision:' . $entity_type->id()],
48         'right_revision' => ['type' => 'entity_revision:' . $entity_type->id()],
49       ]);
50       return $route;
51     }
52   }
53
54 }