本文整理汇总了PHP中Drupal\Core\Theme\ThemeManagerInterface::setThemeRegistry方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeManagerInterface::setThemeRegistry方法的具体用法?PHP ThemeManagerInterface::setThemeRegistry怎么用?PHP ThemeManagerInterface::setThemeRegistry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Theme\ThemeManagerInterface
的用法示例。
在下文中一共展示了ThemeManagerInterface::setThemeRegistry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mail
/**
* {@inheritdoc}
*/
public function mail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE)
{
// Switch the theme to the configured mail theme.
$mail_theme = $this->getMailTheme();
$current_active_theme = $this->themeManager->getActiveTheme();
if ($mail_theme != $current_active_theme->getName()) {
$this->themeManager->setActiveTheme($this->themeInitialization->initTheme($mail_theme));
// The theme registry returns the same registry object no matter which
// theme is currently active. This works around that by having a duplicate
// service, that is only called when the mail theme is acive.
// @todo: This will not work if this can not be called. Remove this once
// https://www.drupal.org/node/2640962 is committed.
if ($this->themeManager instanceof ThemeManager) {
$this->themeManager->setThemeRegistry($this->mailThemeRegistry);
}
}
try {
$message = parent::mail($module, $key, $to, $langcode, $params, $reply, $send);
} finally {
// Revert the active theme, this is done inside a finally block so it is
// executed even if an exception is thrown during sending a mail.
if ($mail_theme != $current_active_theme->getName()) {
$this->themeManager->setActiveTheme($current_active_theme);
if ($this->themeManager instanceof ThemeManager) {
$this->themeManager->setThemeRegistry($this->defaultThemeRegistry);
}
}
}
return $message;
}