You are here

class ThemeKeyNegotiator in ThemeKey 8

Hierarchy

Expanded class hierarchy of ThemeKeyNegotiator

1 string reference to 'ThemeKeyNegotiator'
themekey.services.yml in ./themekey.services.yml
themekey.services.yml
1 service uses ThemeKeyNegotiator
theme.negotiator.themekey in ./themekey.services.yml
Drupal\themekey\Theme\ThemeKeyNegotiator

File

src/Theme/ThemeKeyNegotiator.php, line 15

Namespace

Drupal\themekey\Theme
View source
class ThemeKeyNegotiator implements ThemeNegotiatorInterface {

  /**
   * @var
   */
  protected $themeKeyEngine;

  /**
   * Gets the ThemeKey Engine service.
   *
   * @return \Drupal\themekey\EngineInterface
   *   The string translation service.
   */
  protected function getThemeKeyEngine() {
    if (!$this->themeKeyEngine) {
      $this->themeKeyEngine = \Drupal::service('themekey.engine');
    }
    return $this->themeKeyEngine;
  }

  /**
   * Sets the ThemeKey Engine service to use.
   *
   * @param \Drupal\themekey\EngineInterface $themeKeyEngine
   *   The string translation service.
   *
   * @return $this
   */
  public function setThemeKeyEngine(EngineInterface $themeKeyEngine) {
    $this->themeKeyEngine = $themeKeyEngine;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    if (strpos($route_match
      ->getRouteName(), 'themekey_rule.') === 0) {
      return FALSE;
    }
    return TRUE;

    // TODO migrate complete function themekey_is_active() to applies()
    // Don't change theme when ...
    if ((in_array('system', variable_get('themekey_compat_modules_enabled', array())) || !(variable_get('admin_theme', '0') && path_is_admin($_GET['q']))) && strpos($_GET['q'], 'admin/structure/block/demo') !== 0 && strpos($_SERVER['SCRIPT_FILENAME'], 'cron.php') === FALSE && strpos($_SERVER['SCRIPT_FILENAME'], 'drush.php') === FALSE && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'install' && MAINTENANCE_MODE != 'update')) {
      require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey') . '/themekey_base.inc';
      $paths = $paths = array_merge_recursive(themekey_invoke_modules('themekey_disabled_paths'), module_invoke_all('themekey_disabled_paths'));
      foreach ($paths as $path) {
        if (strpos($_GET['q'], $path) === 0) {
          return FALSE;
        }
      }
      return TRUE;
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    return $this
      ->getThemeKeyEngine()
      ->determineTheme($route_match);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ThemeKeyNegotiator::$themeKeyEngine protected property @var
ThemeKeyNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
ThemeKeyNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme
ThemeKeyNegotiator::getThemeKeyEngine protected function Gets the ThemeKey Engine service.
ThemeKeyNegotiator::setThemeKeyEngine public function Sets the ThemeKey Engine service to use.