X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=inline;f=web%2Fmodules%2Fcontrib%2Fdiff%2Fsrc%2FVisualDiffThemeNegotiator.php;fp=web%2Fmodules%2Fcontrib%2Fdiff%2Fsrc%2FVisualDiffThemeNegotiator.php;h=e5678c478a1bdf481d6f309c917e65ccd4d52fd0;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/diff/src/VisualDiffThemeNegotiator.php b/web/modules/contrib/diff/src/VisualDiffThemeNegotiator.php new file mode 100644 index 000000000..e5678c478 --- /dev/null +++ b/web/modules/contrib/diff/src/VisualDiffThemeNegotiator.php @@ -0,0 +1,74 @@ +configFactory = $config_factory; + } + + /** + * {@inheritdoc} + */ + public function applies(RouteMatchInterface $routeMatch) { + if ($routeMatch->getParameter('filter') !== 'visual_inline') { + return FALSE; + } + + if (!$this->isDiffRoute($routeMatch)) { + return FALSE; + } + + if ($this->configFactory->get('diff.settings')->get('general_settings.visual_inline_theme') !== 'default') { + return FALSE; + } + + return TRUE; + } + + /** + * {@inheritdoc} + */ + public function determineActiveTheme(RouteMatchInterface $route_match) { + return $this->configFactory->get('system.theme')->get('default'); + } + + /** + * Checks if route names for node or other entity are corresponding. + * + * @param \Drupal\Core\Routing\RouteMatchInterface $route_match + * Route match object. + * + * @return bool + * Return TRUE if route name is ok. + */ + protected function isDiffRoute(RouteMatchInterface $route_match) { + $regex_pattern = '/^entity\..*\.revisions_diff$/'; + return $route_match->getRouteName() === 'diff.revisions_diff' || + preg_match($regex_pattern, $route_match->getRouteName()); + } + +}