Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function postProcessExtension(array &$cache, ActiveTheme $theme)
 {
     parent::postProcessExtension($cache, $theme);
     foreach ($cache as $hook => $info) {
         foreach (array('includes', 'preprocess functions') as $type) {
             // Ensure properties exist (temporarily at least).
             if (!isset($cache[$hook][$type])) {
                 $cache[$hook][$type] = array();
             }
             // Merge in base hook values.
             if (!empty($info['base hook'])) {
                 if (isset($cache[$info['base hook']][$type])) {
                     $cache[$hook][$type] = array_merge($cache[$info['base hook']][$type], $cache[$hook][$type]);
                 }
             }
             // Ensure uniqueness.
             if (!empty($info[$type])) {
                 $cache[$hook][$type] = array_unique($cache[$hook][$type]);
             }
             // Remove if empty.
             if (empty($cache[$hook][$type])) {
                 unset($cache[$hook][$type]);
             }
         }
         // Correct any unset theme path.
         if (!isset($info['theme path'])) {
             $cache[$hook]['theme path'] = $theme->getPath();
         }
         // Add extra variables to all theme hooks.
         if (isset($info['variables'])) {
             $variables = array('context' => array(), 'icon' => NULL, 'icon_position' => 'before');
             foreach ($variables as $name => $value) {
                 if (!isset($info['variables'][$name])) {
                     $cache[$hook]['variables'][$name] = $value;
                 }
             }
         }
         // Sort the preprocess functions.
         // @see https://www.drupal.org/node/2098551
         if (isset($info['preprocess functions'])) {
             $this->sortFunctions($cache[$hook]['preprocess functions'], $hook, $theme);
         }
     }
 }