5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Drupal\Core\Theme\ThemeNegotiatorInterface;
10 * Visual inline layout theme negotiator.
12 * @package Drupal\diff
14 class VisualDiffThemeNegotiator implements ThemeNegotiatorInterface {
19 * @var \Drupal\Core\Config\ConfigFactoryInterface
21 protected $configFactory;
24 * VisualDiffThemeNegotiator constructor.
26 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
29 public function __construct(ConfigFactoryInterface $config_factory) {
30 $this->configFactory = $config_factory;
36 public function applies(RouteMatchInterface $routeMatch) {
37 if ($routeMatch->getParameter('filter') !== 'visual_inline') {
41 if (!$this->isDiffRoute($routeMatch)) {
45 if ($this->configFactory->get('diff.settings')->get('general_settings.visual_inline_theme') !== 'default') {
55 public function determineActiveTheme(RouteMatchInterface $route_match) {
56 return $this->configFactory->get('system.theme')->get('default');
60 * Checks if route names for node or other entity are corresponding.
62 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
66 * Return TRUE if route name is ok.
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());