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


PHP Theme\ThemeManagerInterface类代码示例

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


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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->themeManager = $this->getMock('Drupal\\Core\\Theme\\ThemeManagerInterface');
     $mock_active_theme = $this->getMockBuilder('Drupal\\Core\\Theme\\ActiveTheme')->disableOriginalConstructor()->getMock();
     $mock_active_theme->expects($this->any())->method('getLibrariesOverride')->willReturn([]);
     $this->themeManager->expects($this->any())->method('getActiveTheme')->willReturn($mock_active_theme);
     $this->libraryDiscoveryParser = new TestLibraryDiscoveryParser($this->root, $this->moduleHandler, $this->themeManager);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:LibraryDiscoveryParserTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->libraryDiscovery = $this->getMockBuilder('Drupal\\Core\\Asset\\LibraryDiscovery')->disableOriginalConstructor()->getMock();
     $this->libraryDependencyResolver = $this->getMock('\\Drupal\\Core\\Asset\\LibraryDependencyResolverInterface');
     $this->libraryDependencyResolver->expects($this->any())->method('getLibrariesWithDependencies')->willReturnArgument(0);
     $this->moduleHandler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->themeManager = $this->getMock('\\Drupal\\Core\\Theme\\ThemeManagerInterface');
     $active_theme = $this->getMockBuilder('\\Drupal\\Core\\Theme\\ActiveTheme')->disableOriginalConstructor()->getMock();
     $active_theme->expects($this->any())->method('getName')->willReturn('bartik');
     $this->themeManager->expects($this->any())->method('getActiveTheme')->willReturn($active_theme);
     $this->languageManager = $this->getMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
     $english = $this->getMock('\\Drupal\\Core\\Language\\LanguageInterface');
     $english->expects($this->any())->method('getId')->willReturn('en');
     $japanese = $this->getMock('\\Drupal\\Core\\Language\\LanguageInterface');
     $japanese->expects($this->any())->method('getId')->willReturn('jp');
     $this->languageManager = $this->getMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
     $this->languageManager->expects($this->any())->method('getCurrentLanguage')->will($this->onConsecutiveCalls($english, $english, $japanese, $japanese));
     $this->cache = new TestMemoryBackend('llama');
     $this->assetResolver = new AssetResolver($this->libraryDiscovery, $this->libraryDependencyResolver, $this->moduleHandler, $this->themeManager, $this->languageManager, $this->cache);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:24,代码来源:AssetResolverTest.php

示例3: getVisibleBlocksPerRegion

 /**
  * {@inheritdoc}
  */
 public function getVisibleBlocksPerRegion(array &$cacheable_metadata = [])
 {
     $active_theme = $this->themeManager->getActiveTheme();
     // Build an array of the region names in the right order.
     $empty = array_fill_keys($active_theme->getRegions(), array());
     $full = array();
     foreach ($this->blockStorage->loadByProperties(array('theme' => $active_theme->getName())) as $block_id => $block) {
         /** @var \Drupal\block\BlockInterface $block */
         $access = $block->access('view', NULL, TRUE);
         $region = $block->getRegion();
         if (!isset($cacheable_metadata[$region])) {
             $cacheable_metadata[$region] = CacheableMetadata::createFromObject($access);
         } else {
             $cacheable_metadata[$region] = $cacheable_metadata[$region]->merge(CacheableMetadata::createFromObject($access));
         }
         // Set the contexts on the block before checking access.
         if ($access->isAllowed()) {
             $full[$region][$block_id] = $block;
         }
     }
     // Merge it with the actual values to maintain the region ordering.
     $assignments = array_intersect_key(array_merge($empty, $full), $empty);
     foreach ($assignments as &$assignment) {
         // Suppress errors because PHPUnit will indirectly modify the contents,
         // triggering https://bugs.php.net/bug.php?id=50688.
         @uasort($assignment, 'Drupal\\block\\Entity\\Block::sort');
     }
     return $assignments;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:32,代码来源:BlockRepository.php

示例4: getCid

 /**
  * {@inheritdoc}
  */
 protected function getCid()
 {
     if (!isset($this->cid)) {
         $this->cid = 'library_info:' . $this->themeManager->getActiveTheme()->getName();
     }
     return $this->cid;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:10,代码来源:LibraryDiscoveryCollector.php

示例5: 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

示例6: collect

 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = NULL)
 {
     $activeTheme = $this->themeManager->getActiveTheme();
     $this->data['activeTheme'] = ['name' => $activeTheme->getName(), 'path' => $activeTheme->getPath(), 'engine' => $activeTheme->getEngine(), 'owner' => $activeTheme->getOwner(), 'baseThemes' => $activeTheme->getBaseThemes(), 'extension' => $activeTheme->getExtension(), 'styleSheetsRemove' => $activeTheme->getStyleSheetsRemove(), 'libraries' => $activeTheme->getLibraries(), 'regions' => $activeTheme->getRegions()];
     if ($this->themeNegotiator instanceof ThemeNegotiatorWrapper) {
         $this->data['negotiator'] = ['class' => $this->getMethodData($this->themeNegotiator->getNegotiator(), 'determineActiveTheme'), 'id' => $this->themeNegotiator->getNegotiator()->_serviceId];
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:11,代码来源:ThemeDataCollector.php

示例7: testWildWest

 /**
  * Tests opting out of Stable by setting the base theme to false.
  */
 public function testWildWest()
 {
     $this->themeHandler->install(['test_wild_west']);
     $this->config('system.theme')->set('default', 'test_wild_west')->save();
     $theme = $this->themeManager->getActiveTheme();
     /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
     $base_themes = $theme->getBaseThemes();
     $this->assertTrue(empty($base_themes), 'No base theme is set when a theme has opted out of using Stable.');
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:12,代码来源:StableThemeTest.php

示例8: testChanges

 /**
  * Tests that changes to the info file are picked up.
  */
 public function testChanges()
 {
     $this->themeHandler->install(array('test_theme'));
     $this->themeHandler->setDefault('test_theme');
     $this->themeManager->resetActiveTheme();
     $active_theme = $this->themeManager->getActiveTheme();
     // Make sure we are not testing the wrong theme.
     $this->assertEqual('test_theme', $active_theme->getName());
     $this->assertEqual(['classy/base', 'core/normalize', 'test_theme/global-styling'], $active_theme->getLibraries());
     // @see theme_test_system_info_alter()
     $this->state->set('theme_test.modify_info_files', TRUE);
     drupal_flush_all_caches();
     $active_theme = $this->themeManager->getActiveTheme();
     $this->assertEqual(['classy/base', 'core/normalize', 'test_theme/global-styling', 'core/backbone'], $active_theme->getLibraries());
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:18,代码来源:ThemeInfoTest.php

示例9: buildInfo

 /**
  * Builds up all element information.
  *
  * @param string $theme_name
  *   The theme name.
  *
  * @return array
  */
 protected function buildInfo($theme_name)
 {
     // Get cached definitions.
     $cid = $this->getCid($theme_name);
     if ($cache = $this->cacheBackend->get($cid)) {
         return $cache->data;
     }
     // Otherwise, rebuild and cache.
     $info = [];
     foreach ($this->getDefinitions() as $element_type => $definition) {
         $element = $this->createInstance($element_type);
         $element_info = $element->getInfo();
         // If this is element is to be used exclusively in a form, denote that it
         // will receive input, and assign the value callback.
         if ($element instanceof FormElementInterface) {
             $element_info['#input'] = TRUE;
             $element_info['#value_callback'] = array($definition['class'], 'valueCallback');
         }
         $info[$element_type] = $element_info;
     }
     foreach ($info as $element_type => $element) {
         $info[$element_type]['#type'] = $element_type;
     }
     // Allow modules to alter the element type defaults.
     $this->moduleHandler->alter('element_info', $info);
     $this->themeManager->alter('element_info', $info);
     $this->cacheBackend->set($cid, $info, Cache::PERMANENT, ['element_info_build']);
     return $info;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:37,代码来源:ElementInfoManager.php

示例10: evaluate

 /**
  * {@inheritdoc}
  */
 public function evaluate()
 {
     if (!$this->configuration['theme']) {
         return TRUE;
     }
     return $this->themeManager->getActiveTheme()->getName() == $this->configuration['theme'];
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:CurrentThemeCondition.php

示例11: testDestruct

 /**
  * Tests the destruct method.
  *
  * @covers ::destruct
  */
 public function testDestruct()
 {
     $this->activeTheme = $this->getMockBuilder('Drupal\\Core\\Theme\\ActiveTheme')->disableOriginalConstructor()->getMock();
     $this->themeManager->expects($this->once())->method('getActiveTheme')->willReturn($this->activeTheme);
     $this->activeTheme->expects($this->once())->method('getName')->willReturn('kitten_theme');
     $this->libraryDiscoveryCollector = new LibraryDiscoveryCollector($this->cache, $this->lock, $this->libraryDiscoveryParser, $this->themeManager);
     $this->libraryDiscoveryParser->expects($this->once())->method('buildByExtension')->with('test')->willReturn($this->libraryData);
     $lock_key = 'library_info:kitten_theme:Drupal\\Core\\Cache\\CacheCollector';
     $this->lock->expects($this->once())->method('acquire')->with($lock_key)->will($this->returnValue(TRUE));
     $this->cache->expects($this->exactly(2))->method('get')->with('library_info:kitten_theme')->willReturn(FALSE);
     $this->cache->expects($this->once())->method('set')->with('library_info:kitten_theme', array('test' => $this->libraryData), Cache::PERMANENT, ['library_info']);
     $this->lock->expects($this->once())->method('release')->with($lock_key);
     // This should get data and persist the key.
     $this->libraryDiscoveryCollector->get('test');
     $this->libraryDiscoveryCollector->destruct();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:21,代码来源:LibraryDiscoveryCollectorTest.php

示例12: testGetInfoProperty

 /**
  * @covers ::getInfoProperty
  */
 public function testGetInfoProperty()
 {
     $this->themeManager->method('getActiveTheme')->willReturn(new ActiveTheme(['name' => 'test']));
     $element_info = new TestElementInfoManager(new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager);
     $this->assertSame('baz', $element_info->getInfoProperty('foo', '#bar'));
     $this->assertNull($element_info->getInfoProperty('foo', '#non_existing_property'));
     $this->assertSame('qux', $element_info->getInfoProperty('foo', '#non_existing_property', 'qux'));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:11,代码来源:ElementInfoManagerTest.php

示例13: getThemeName

 /**
  * Gets the name of the theme used for this block listing.
  *
  * @return string
  *   The name of the theme.
  */
 protected function getThemeName()
 {
     // If no theme was specified, use the current theme.
     if (!$this->theme) {
         $this->theme = $this->themeManager->getActiveTheme()->getName();
     }
     return $this->theme;
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:14,代码来源:BlockListBuilder.php

示例14: themePage

 /**
  * Page callback: Tests the theme negotiation functionality.
  *
  * @param bool $inherited
  *   TRUE when the requested page is intended to inherit
  *   the theme of its parent.
  *
  * @return string
  *   A string describing the requested custom theme and actual
  *   theme being used
  *   for the current page request.
  */
 public function themePage($inherited)
 {
     $theme_key = $this->themeManager->getActiveTheme()->getName();
     // Now we check what the theme negotiator service returns.
     $active_theme = $this->themeNegotiator->determineActiveTheme($this->routeMatch);
     $output = "Active theme: {$active_theme}. Actual theme: {$theme_key}.";
     if ($inherited) {
         $output .= ' Theme negotiation inheritance is being tested.';
     }
     return ['#markup' => $output];
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:23,代码来源:MenuTestController.php

示例15: testGetInfoElementPlugin

 /**
  * Tests the getInfo() method when render element plugins are used.
  *
  * @covers ::getInfo
  * @covers ::buildInfo
  *
  * @dataProvider providerTestGetInfoElementPlugin
  */
 public function testGetInfoElementPlugin($plugin_class, $expected_info)
 {
     $this->moduleHandler->expects($this->once())->method('invokeAll')->with('element_info')->willReturn(array());
     $this->moduleHandler->expects($this->once())->method('alter')->with('element_info', $this->anything())->will($this->returnArgument(0));
     $plugin = $this->getMock($plugin_class);
     $plugin->expects($this->once())->method('getInfo')->willReturn(array('#theme' => 'page'));
     $element_info = $this->getMockBuilder('Drupal\\Core\\Render\\ElementInfoManager')->setConstructorArgs(array(new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager))->setMethods(array('getDefinitions', 'createInstance'))->getMock();
     $this->themeManager->expects($this->any())->method('getActiveTheme')->willReturn(new ActiveTheme(['name' => 'test']));
     $element_info->expects($this->once())->method('createInstance')->with('page')->willReturn($plugin);
     $element_info->expects($this->once())->method('getDefinitions')->willReturn(array('page' => array('class' => 'TestElementPlugin')));
     $this->assertEquals($expected_info, $element_info->getInfo('page'));
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:20,代码来源:ElementInfoManagerTest.php


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