本文整理汇总了PHP中Drupal\Core\Extension\ThemeHandlerInterface::themeExists方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeHandlerInterface::themeExists方法的具体用法?PHP ThemeHandlerInterface::themeExists怎么用?PHP ThemeHandlerInterface::themeExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Extension\ThemeHandlerInterface
的用法示例。
在下文中一共展示了ThemeHandlerInterface::themeExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateHookN
/**
* 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'));
}
示例2: processDefinition
/**
* {@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'];
}
}
}
示例3: getGroupLabel
/**
* 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;
}
示例4: getActiveThemeByName
/**
* {@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;
}
示例5: providerExists
/**
* {@inheritdoc}
*/
protected function providerExists($provider)
{
return $this->themeHandler->themeExists($provider);
}