3 namespace Drupal\diff\Routing;
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;
11 * Contains routes for diff functionality.
13 class DiffRouteProvider implements EntityRouteProviderInterface {
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);
27 * Constructs the diff route.
29 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
32 * @return \Symfony\Component\Routing\Route|null
35 protected function getDiffRoute(EntityTypeInterface $entity_type) {
36 if ($entity_type->hasLinkTemplate('revisions-diff')) {
37 $route = new Route($entity_type->getLinkTemplate('revisions-diff'));
39 '_controller' => '\Drupal\diff\Controller\PluginRevisionController::compareEntityRevisions',
40 'filter' => 'split_fields',
42 $route->addRequirements([
43 '_entity_access' => $entity_type->id() . '.view',
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()],