You are here

public function InstallablePluginManager::getCacheKey in Markdown 8.2

Retrieves the cache key to use.

Parameters

bool $runtime: Flag indicating whether to retrieve runtime definitions.

Return value

string The cache key.

Overrides InstallablePluginManagerInterface::getCacheKey

2 calls to InstallablePluginManager::getCacheKey()
InstallablePluginManager::getCachedDefinitions in src/PluginManager/InstallablePluginManager.php
InstallablePluginManager::setCachedDefinitions in src/PluginManager/InstallablePluginManager.php
Sets a cache of plugin definitions for the decorated discovery class.

File

src/PluginManager/InstallablePluginManager.php, line 279

Class

InstallablePluginManager
Installable Plugin Manager.

Namespace

Drupal\markdown\PluginManager

Code

public function getCacheKey($runtime = FALSE) {
  $cacheKey = $this->cacheKey;
  if ($runtime) {

    // Prematurely requesting the "active theme" causes the wrong theme
    // to be chosen due to the request not yet being fully populated with
    // the correct route object, or any for that matter.
    $request = \Drupal::request();
    if ($request->attributes
      ->has(RouteObjectInterface::ROUTE_OBJECT)) {
      $cacheKey .= ':runtime:' . \Drupal::theme()
        ->getActiveTheme()
        ->getName();
    }
    else {
      $cacheKey .= ':runtime';
    }
  }
  return $cacheKey;
}