本文整理匯總了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;
}