本文整理汇总了PHP中Drupal\Core\Extension\ThemeHandlerInterface::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeHandlerInterface::getName方法的具体用法?PHP ThemeHandlerInterface::getName怎么用?PHP ThemeHandlerInterface::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Extension\ThemeHandlerInterface
的用法示例。
在下文中一共展示了ThemeHandlerInterface::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: demo
/**
* Returns a block theme demo page.
*
* @param string $theme
* The name of the theme.
*
* @return array
* A #type 'page' render array containing the block region demo.
*/
public function demo($theme)
{
$page = ['#title' => $this->themeHandler->getName($theme), '#type' => 'page', '#attached' => array('drupalSettings' => ['path' => ['currentPathIsAdmin' => TRUE]], 'library' => array('block/drupal.block.admin'))];
// Show descriptions in each visible page region, nothing else.
$visible_regions = $this->getVisibleRegionNames($theme);
foreach (array_keys($visible_regions) as $region) {
$page[$region]['block_description'] = array('#type' => 'inline_template', '#template' => '<div class="block-region demo-block">{{ region_name }}</div>', '#context' => array('region_name' => $visible_regions[$region]));
}
return $page;
}
示例2: 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;
}
示例3: generateReport
/**
* Generates a report about config updates.
*
* @param string $report_type
* Type of report to generate: 'type', 'module', 'theme', or 'profile'.
* @param string $value
* Machine name of a configuration type, module, or theme to generate the
* report for. Ignored for profile, since that uses the active profile.
*
* @return array
* Render array for the updates report. Empty if invalid or missing
* report type or value.
*/
protected function generateReport($report_type, $value)
{
// Figure out what to name the report, and incidentally, validate that
// $value exists for this type of report.
switch ($report_type) {
case 'type':
if ($value == 'system.all') {
$label = $this->t('All configuration');
} elseif ($value == 'system.simple') {
$label = $this->t('Simple configuration');
} else {
$definition = $this->configList->getType($value);
if (!$definition) {
return NULL;
}
$label = $this->t('@name configuration', array('@name' => $definition->getLabel()));
}
break;
case 'module':
$list = $this->moduleHandler->getModuleList();
if (!isset($list[$value])) {
return NULL;
}
$label = $this->t('@name module', array('@name' => $this->moduleHandler->getName($value)));
break;
case 'theme':
$list = $this->themeHandler->listInfo();
if (!isset($list[$value])) {
return NULL;
}
$label = $this->t('@name theme', array('@name' => $this->themeHandler->getName($value)));
break;
case 'profile':
$profile = Settings::get('install_profile');
$label = $this->t('@name profile', array('@name' => $this->moduleHandler->getName($profile)));
break;
default:
return NULL;
}
// List the active and extension-provided config.
list($active_list, $install_list, $optional_list) = $this->configList->listConfig($report_type, $value);
// Build the report.
$build = array();
$build['#title'] = $this->t('Configuration updates report for @label', array('@label' => $label));
$build['report_header'] = array('#markup' => '<h3>' . $this->t('Updates report') . '</h3>');
// List items missing from site.
$removed = array_diff($install_list, $active_list);
$build['removed'] = array('#caption' => $this->t('Missing configuration items'), '#empty' => $this->t('None: all provided configuration items are in your active configuration.')) + $this->makeReportTable($removed, 'extension', array('import'));
// List optional items that are not installed.
$inactive = array_diff($optional_list, $active_list);
$build['inactive'] = array('#caption' => $this->t('Inactive optional items'), '#empty' => $this->t('None: all optional configuration items are in your active configuration.')) + $this->makeReportTable($inactive, 'extension', array('import'));
// List items added to site, which only makes sense in the report for a
// config type.
$added = array_diff($active_list, $install_list, $optional_list);
if ($report_type == 'type') {
$build['added'] = array('#caption' => $this->t('Added configuration items'), '#empty' => $this->t('None: all active configuration items of this type were provided by modules, themes, or install profile.')) + $this->makeReportTable($added, 'active', array('export', 'delete'));
}
// For differences, we need to go through the array of config in both
// and see if each config item is the same or not.
$both = array_diff($active_list, $added);
$different = array();
foreach ($both as $name) {
if (!$this->configDiff->same($this->configRevert->getFromExtension('', $name), $this->configRevert->getFromActive('', $name))) {
$different[] = $name;
}
}
$build['different'] = array('#caption' => $this->t('Changed configuration items'), '#empty' => $this->t('None: no active configuration items differ from their current provided versions.')) + $this->makeReportTable($different, 'active', array('diff', 'export', 'revert'));
return $build;
}
示例4: demo
/**
* Returns a block theme demo page.
*
* @param string $theme
* The name of the theme.
*
* @return array
* A render array containing the CSS and title for the block region demo.
*/
public function demo($theme)
{
return array('#title' => String::checkPlain($this->themeHandler->getName($theme)), '#attached' => array('js' => array(array('data' => array('path' => array('currentPathIsAdmin' => TRUE)), 'type' => 'setting')), 'library' => array('block/drupal.block.admin')));
}