当前位置: 首页>>代码示例>>PHP>>正文


PHP ThemeManagerInterface::setActiveTheme方法代码示例

本文整理汇总了PHP中Drupal\Core\Theme\ThemeManagerInterface::setActiveTheme方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeManagerInterface::setActiveTheme方法的具体用法?PHP ThemeManagerInterface::setActiveTheme怎么用?PHP ThemeManagerInterface::setActiveTheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Theme\ThemeManagerInterface的用法示例。


在下文中一共展示了ThemeManagerInterface::setActiveTheme方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testStableLibraryOverrides

 /**
  * Ensures that Stable overrides all relevant core library assets.
  */
 public function testStableLibraryOverrides()
 {
     // First get the clean library definitions with no active theme.
     $libraries_before = $this->getAllLibraries();
     $libraries_before = $this->removeVendorAssets($libraries_before);
     $this->themeManager->setActiveTheme($this->themeInitialization->getActiveThemeByName('stable'));
     $this->libraryDiscovery->clearCachedDefinitions();
     // Now get the library definitions with Stable as the active theme.
     $libraries_after = $this->getAllLibraries();
     $libraries_after = $this->removeVendorAssets($libraries_after);
     $root = \Drupal::root();
     foreach ($libraries_before as $extension => $libraries) {
         foreach ($libraries as $library_name => $library) {
             // Allow skipping libraries.
             if (in_array("{$extension}/{$library_name}", $this->librariesToSkip)) {
                 continue;
             }
             $library_after = $libraries_after[$extension][$library_name];
             // Check that all the CSS assets are overridden.
             foreach ($library['css'] as $index => $asset) {
                 $clean_path = $asset['data'];
                 $stable_path = $library_after['css'][$index]['data'];
                 // Make core/misc assets look like they are coming from a "core"
                 // module.
                 $replacements = ['core/misc/' => "core/modules/core/css/"];
                 $expected_path = strtr($clean_path, $replacements);
                 // Adjust the module asset paths to correspond with the Stable folder
                 // structure.
                 $expected_path = str_replace("core/modules/{$extension}/css/", "core/themes/stable/css/{$extension}/", $expected_path);
                 $assert_path = str_replace("core/modules/{$extension}/", '', $clean_path);
                 $this->assertEqual($expected_path, $stable_path, "{$assert_path} from the {$extension}/{$library_name} library is overridden in Stable.");
             }
         }
     }
 }
开发者ID:Wylbur,项目名称:gj,代码行数:38,代码来源:StableLibraryOverrideTest.php

示例2: 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;
 }
开发者ID:augustpascual-mse,项目名称:job-searching-network,代码行数:33,代码来源:MailsystemManager.php

示例3: testCoreLibraryCompleteness

 /**
  * Ensures that all core module and theme library files exist.
  */
 public function testCoreLibraryCompleteness()
 {
     // First verify all libraries with no active theme.
     $this->verifyLibraryFilesExist($this->getAllLibraries());
     // Then verify all libraries for each core theme. This may seem like
     // overkill but themes can override and extend other extensions' libraries
     // and these changes are only applied for the active theme.
     foreach ($this->allThemes as $theme) {
         $this->themeManager->setActiveTheme($this->themeInitialization->getActiveThemeByName($theme));
         $this->libraryDiscovery->clearCachedDefinitions();
         $this->verifyLibraryFilesExist($this->getAllLibraries());
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:16,代码来源:ResolvedLibraryDefinitionsFilesMatchTest.php


注:本文中的Drupal\Core\Theme\ThemeManagerInterface::setActiveTheme方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。