You are here

protected function SkinPluginManager::addStatusDefaults in Skinr 8.2

Prepare the default status for a skin.

Parameters

$skin: Information about a registered skin.

Return value

array An array of default statuses for each enabled theme.

1 call to SkinPluginManager::addStatusDefaults()
SkinPluginManager::processDefinition in src/SkinPluginManager.php
Performs extra processing on plugin definitions.

File

src/SkinPluginManager.php, line 86
Contains \Drupal\skinr\SkinPluginManager.

Class

SkinPluginManager
Manages plugins for configuration translation mappers.

Namespace

Drupal\skinr

Code

protected function addStatusDefaults($skin) {
  $status = array();

  // Retrieve the explicit default status of the registering theme for itself.
  $base_theme_status = NULL;
  if (isset($skin['status'][$skin['source']['name']])) {
    $base_theme_status = $skin['status'][$skin['source']['name']];
  }

  // Retrieve the sub themes of the base theme that registered the skin.
  $sub_themes = array();
  if (isset($skin['source']['sub themes'])) {
    $sub_themes = $skin['source']['sub themes'];
  }
  $theme_handler = \Drupal::service('theme_handler');
  $themes = $theme_handler
    ->listInfo();
  foreach ($themes as $name => $theme) {
    if (!$theme->status) {
      continue;
    }

    // If this theme is a sub theme of the theme that registered the skin, check
    // whether we need to inherit the status of the base theme to the sub theme.
    // This is the case when a skin of a base theme enables itself for the base
    // theme (not knowing about potential sub themes).
    if (isset($base_theme_status) && isset($sub_themes[$name])) {
      $status[$name] = $base_theme_status;
    }

    // Apply global default.
    $status += array(
      $name => $skin['default status'],
    );
  }

  // Lastly, apply all explicit defaults.
  $status = array_merge($status, $skin['status']);
  return $status;
}