/** * Tests that the Stable base theme is installed if necessary. */ public function testUpdateHookN() { $this->assertTrue($this->themeHandler->themeExists('test_stable')); $this->assertFalse($this->themeHandler->themeExists('stable')); $this->runUpdates(); // Refresh the theme handler now that Stable has been installed. $this->themeHandler->refreshInfo(); $this->assertTrue($this->themeHandler->themeExists('stable')); }
/** * {@inheritdoc} */ public function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); // Add the module or theme path to the 'path'. if ($this->moduleHandler->moduleExists($definition['provider'])) { $definition['provider_type'] = 'module'; $base_path = $this->moduleHandler->getModule($definition['provider'])->getPath(); } elseif ($this->themeHandler->themeExists($definition['provider'])) { $definition['provider_type'] = 'theme'; $base_path = $this->themeHandler->getTheme($definition['provider'])->getPath(); } else { $base_path = ''; } $definition['path'] = !empty($definition['path']) ? $base_path . '/' . $definition['path'] : $base_path; // Add the path to the icon filename. if (!empty($definition['icon'])) { $definition['icon'] = $definition['path'] . '/' . $definition['icon']; } // If 'template' is set, then we'll derive 'template_path' and 'theme'. if (!empty($definition['template'])) { $template_parts = explode('/', $definition['template']); $definition['template'] = array_pop($template_parts); $definition['theme'] = strtr($definition['template'], '-', '_'); $definition['template_path'] = $definition['path']; if (count($template_parts) > 0) { $definition['template_path'] .= '/' . implode('/', $template_parts); } } // If 'css' is set, then we'll derive 'library'. if (!empty($definition['css'])) { $definition['css'] = $definition['path'] . '/' . $definition['css']; $definition['library'] = 'layout_plugin/' . $plugin_id; } // Generate the 'region_names' key from the 'regions' key. $definition['region_names'] = array(); if (!empty($definition['regions']) && is_array($definition['regions'])) { foreach ($definition['regions'] as $region_id => $region_definition) { $definition['region_names'][$region_id] = $region_definition['label']; } } }
/** * Gets the label for a breakpoint group. * * @param string $group * The breakpoint group. * * @return string * The label. */ protected function getGroupLabel($group) { // Extension names are not translatable. if ($this->moduleHandler->moduleExists($group)) { $label = $this->moduleHandler->getName($group); } elseif ($this->themeHandler->themeExists($group)) { $label = $this->themeHandler->getName($group); } else { // Custom group label that should be translatable. $label = $this->t($group, array(), array('context' => 'breakpoint')); } return $label; }
/** * {@inheritdoc} */ public function getActiveThemeByName($theme_name) { if ($cached = $this->cache->get('theme.active_theme.' . $theme_name)) { return $cached->data; } $themes = $this->themeHandler->listInfo(); // If no theme could be negotiated, or if the negotiated theme is not within // the list of installed themes, fall back to the default theme output of // core and modules (like Stark, but without a theme extension at all). This // is possible, because loadActiveTheme() always loads the Twig theme // engine. This is desired, because missing or malformed theme configuration // should not leave the application in a broken state. By falling back to // default output, the user is able to reconfigure the theme through the UI. // Lastly, tests are expected to operate with no theme by default, so as to // only assert the original theme output of modules (unless a test manually // installs a specific theme). if (empty($themes) || !$theme_name || !isset($themes[$theme_name])) { $theme_name = 'core'; // /core/core.info.yml does not actually exist, but is required because // Extension expects a pathname. $active_theme = $this->getActiveTheme(new Extension($this->root, 'theme', 'core/core.info.yml')); // Early-return and do not set state, because the initialized $theme_name // differs from the original $theme_name. return $active_theme; } // Find all our ancestor themes and put them in an array. $base_themes = array(); $ancestor = $theme_name; while ($ancestor && isset($themes[$ancestor]->base_theme)) { $ancestor = $themes[$ancestor]->base_theme; if (!$this->themeHandler->themeExists($ancestor)) { if ($ancestor == 'stable') { // Themes that depend on Stable will be fixed by system_update_8014(). // There is no harm in not adding it as an ancestor since at worst // some people might experience slight visual regressions on // update.php. continue; } throw new MissingThemeDependencyException(sprintf('Base theme %s has not been installed.', $ancestor), $ancestor); } $base_themes[] = $themes[$ancestor]; } $active_theme = $this->getActiveTheme($themes[$theme_name], $base_themes); $this->cache->set('theme.active_theme.' . $theme_name, $active_theme); return $active_theme; }
/** * {@inheritdoc} */ protected function providerExists($provider) { return $this->themeHandler->themeExists($provider); }