Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / diff / src / VisualDiffThemeNegotiator.php
1 <?php
2
3 namespace Drupal\diff;
4
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Drupal\Core\Theme\ThemeNegotiatorInterface;
8
9 /**
10  * Visual inline layout theme negotiator.
11  *
12  * @package Drupal\diff
13  */
14 class VisualDiffThemeNegotiator implements ThemeNegotiatorInterface {
15
16   /**
17    * The config factory.
18    *
19    * @var \Drupal\Core\Config\ConfigFactoryInterface
20    */
21   protected $configFactory;
22
23   /**
24    * VisualDiffThemeNegotiator constructor.
25    *
26    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
27    *   The config factory.
28    */
29   public function __construct(ConfigFactoryInterface $config_factory) {
30     $this->configFactory = $config_factory;
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function applies(RouteMatchInterface $routeMatch) {
37     if ($routeMatch->getParameter('filter') !== 'visual_inline') {
38       return FALSE;
39     }
40
41     if (!$this->isDiffRoute($routeMatch)) {
42       return FALSE;
43     }
44
45     if ($this->configFactory->get('diff.settings')->get('general_settings.visual_inline_theme') !== 'default') {
46       return FALSE;
47     }
48
49     return TRUE;
50   }
51
52   /**
53    * {@inheritdoc}
54    */
55   public function determineActiveTheme(RouteMatchInterface $route_match) {
56     return $this->configFactory->get('system.theme')->get('default');
57   }
58
59   /**
60    * Checks if route names for node or other entity are corresponding.
61    *
62    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
63    *   Route match object.
64    *
65    * @return bool
66    *   Return TRUE if route name is ok.
67    */
68   protected function isDiffRoute(RouteMatchInterface $route_match) {
69     $regex_pattern = '/^entity\..*\.revisions_diff$/';
70     return $route_match->getRouteName() === 'diff.revisions_diff' ||
71       preg_match($regex_pattern, $route_match->getRouteName());
72   }
73
74 }