• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Extension\ThemeHandlerInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     // Create a config mock which does not mock the clear(), set() and get() methods.
     $methods = get_class_methods('Drupal\\Core\\Config\\Config');
     unset($methods[array_search('set', $methods)]);
     unset($methods[array_search('get', $methods)]);
     unset($methods[array_search('clear', $methods)]);
     $config_mock = $this->getMockBuilder('Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->setMethods($methods)->getMock();
     // Create the config factory we use in the submitForm() function.
     $this->configFactory = $this->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
     $this->configFactory->expects($this->any())->method('getEditable')->will($this->returnValue($config_mock));
     // Create a MailsystemManager mock.
     $this->mailManager = $this->getMock('\\Drupal\\mailsystem\\MailsystemManager', array(), array(), '', FALSE);
     $this->mailManager->expects($this->any())->method('getDefinition')->will($this->returnValueMap(array(array('mailsystem_test', TRUE, array('label' => 'Test Mail-Plugin')), array('mailsystem_demo', TRUE, array('label' => 'Demo Mail-Plugin')))));
     $this->mailManager->expects($this->any())->method('getDefinitions')->will($this->returnValue(array(array('id' => 'mailsystem_test', 'label' => 'Test Mail-Plugin'), array('id' => 'mailsystem_demo', 'label' => 'Demo Mail-Plugin'))));
     // Create a module handler mock.
     $this->moduleHandler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->moduleHandler->expects($this->any())->method('getImplementations')->with('mail')->will($this->returnValue(array('mailsystem_test', 'mailsystem_demo')));
     $this->moduleHandler->expects($this->any())->method('moduleExists')->withAnyParameters()->will($this->returnValue(FALSE));
     // Create a theme handler mock.
     $this->themeHandler = $this->getMock('\\Drupal\\Core\\Extension\\ThemeHandlerInterface');
     $this->themeHandler->expects($this->any())->method('listInfo')->will($this->returnValue(array('test_theme' => (object) array('status' => 1, 'info' => array('name' => 'test theme name')), 'demo_theme' => (object) array('status' => 1, 'info' => array('name' => 'test theme name demo')), 'inactive_theme' => (object) array('status' => 0, 'info' => array('name' => 'inactive test theme')))));
     // Inject a language-manager into \Drupal.
     $this->languageManager = $this->getMock('\\Drupal\\Core\\StringTranslation\\TranslationInterface');
     $this->languageManager->expects($this->any())->method('translate')->withAnyParameters()->will($this->returnArgument(0));
     $container = new ContainerBuilder();
     $container->set('string_translation', $this->languageManager);
     \Drupal::setContainer($container);
 }
开发者ID:augustpascual-mse,项目名称:job-searching-network,代码行数:32,代码来源:AdminFormTest.php


示例2: __construct

 /**
  * Constructs a TwigEnvironment object and stores cache and storage
  * internally.
  */
 public function __construct(\Twig_LoaderInterface $loader = NULL, $options = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler)
 {
     // @todo Pass as arguments from the DIC.
     $this->cache_object = \Drupal::cache();
     // Ensure that twig.engine is loaded, given that it is needed to render a
     // template because functions like twig_drupal_escape_filter are called.
     require_once DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine';
     // Set twig path namespace for themes and modules.
     $namespaces = array();
     foreach ($module_handler->getModuleList() as $name => $extension) {
         $namespaces[$name] = $extension->getPath();
     }
     foreach ($theme_handler->listInfo() as $name => $extension) {
         $namespaces[$name] = $extension->getPath();
     }
     foreach ($namespaces as $name => $path) {
         $templatesDirectory = $path . '/templates';
         if (file_exists($templatesDirectory)) {
             $loader->addPath($templatesDirectory, $name);
         }
     }
     $this->templateClasses = array();
     $this->stringLoader = new \Twig_Loader_String();
     parent::__construct($loader, $options);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:29,代码来源:TwigEnvironment.php


示例3: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->directoryList = array('system' => 'core/modules/system');
     $this->themeHandler = $this->getMock('Drupal\\Core\\Extension\\ThemeHandlerInterface');
     $theme = new Extension('theme', DRUPAL_ROOT . '/core/themes/bartik', 'bartik.info.yml');
     $theme->status = 1;
     $theme->info = array('name' => 'bartik');
     $this->themeHandler->expects($this->any())->method('listInfo')->will($this->returnValue(array('bartik' => $theme)));
     $this->container->set('theme_handler', $this->themeHandler);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:14,代码来源:SystemLocalTasksTest.php


示例4: __construct

 /**
  * Constructs a new FilesystemLoader object.
  *
  * @param string|array $paths
  *   A path or an array of paths to check for templates.
  * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
  *   The module handler service.
  * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
  *   The theme handler service.
  */
 public function __construct($paths = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler)
 {
     parent::__construct($paths);
     // Add namespaced paths for modules and themes.
     $namespaces = array();
     foreach ($module_handler->getModuleList() as $name => $extension) {
         $namespaces[$name] = $extension->getPath();
     }
     foreach ($theme_handler->listInfo() as $name => $extension) {
         $namespaces[$name] = $extension->getPath();
     }
     foreach ($namespaces as $name => $path) {
         $this->addPath($path . '/templates', $name);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:25,代码来源:FilesystemLoader.php


示例5: __construct

 /**
  * Constructs a TwigEnvironment object and stores cache and storage
  * internally.
  */
 public function __construct(\Twig_LoaderInterface $loader = NULL, $options = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler)
 {
     // @todo Pass as arguments from the DIC.
     $this->cache_object = \Drupal::cache();
     // Set twig path namespace for themes and modules.
     $namespaces = array();
     foreach ($module_handler->getModuleList() as $name => $extension) {
         $namespaces[$name] = $extension->getPath();
     }
     foreach ($theme_handler->listInfo() as $name => $extension) {
         $namespaces[$name] = $extension->getPath();
     }
     foreach ($namespaces as $name => $path) {
         $templatesDirectory = $path . '/templates';
         if (file_exists($templatesDirectory)) {
             $loader->addPath($templatesDirectory, $name);
         }
     }
     $this->templateClasses = array();
     parent::__construct($loader, $options);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:25,代码来源:TwigEnvironment.php


示例6: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $config = $this->config('views.settings');
     $options = array();
     foreach ($this->themeHandler->listInfo() as $name => $theme) {
         if ($theme->status) {
             $options[$name] = $theme->info['name'];
         }
     }
     // This is not currently a fieldset but we may want it to be later,
     // so this will make it easier to change if we do.
     $form['basic'] = array();
     $form['basic']['ui_show_master_display'] = array('#type' => 'checkbox', '#title' => $this->t('Always show the master (default) display'), '#default_value' => $config->get('ui.show.master_display'));
     $form['basic']['ui_show_advanced_column'] = array('#type' => 'checkbox', '#title' => $this->t('Always show advanced display settings'), '#default_value' => $config->get('ui.show.advanced_column'));
     $form['basic']['ui_show_display_embed'] = array('#type' => 'checkbox', '#title' => t('Allow embedded displays'), '#description' => t('Embedded displays can be used in code via views_embed_view().'), '#default_value' => $config->get('ui.show.display_embed'));
     $form['basic']['ui_exposed_filter_any_label'] = array('#type' => 'select', '#title' => $this->t('Label for "Any" value on non-required single-select exposed filters'), '#options' => array('old_any' => '<Any>', 'new_any' => $this->t('- Any -')), '#default_value' => $config->get('ui.exposed_filter_any_label'));
     $form['live_preview'] = array('#type' => 'details', '#title' => $this->t('Live preview settings'), '#open' => TRUE);
     $form['live_preview']['ui_always_live_preview'] = array('#type' => 'checkbox', '#title' => $this->t('Automatically update preview on changes'), '#default_value' => $config->get('ui.always_live_preview'));
     $form['live_preview']['ui_show_preview_information'] = array('#type' => 'checkbox', '#title' => $this->t('Show information and statistics about the view during live preview'), '#default_value' => $config->get('ui.show.preview_information'));
     $form['live_preview']['options'] = array('#type' => 'container', '#states' => array('visible' => array(':input[name="ui_show_preview_information"]' => array('checked' => TRUE))));
     $form['live_preview']['options']['ui_show_sql_query_enabled'] = array('#type' => 'checkbox', '#title' => $this->t('Show the SQL query'), '#default_value' => $config->get('ui.show.sql_query.enabled'));
     $form['live_preview']['options']['ui_show_sql_query_where'] = array('#type' => 'radios', '#states' => array('visible' => array(':input[name="ui_show_sql_query_enabled"]' => array('checked' => TRUE))), '#title' => t('Show SQL query'), '#options' => array('above' => $this->t('Above the preview'), 'below' => $this->t('Below the preview')), '#default_value' => $config->get('ui.show.sql_query.where'));
     $form['live_preview']['options']['ui_show_performance_statistics'] = array('#type' => 'checkbox', '#title' => $this->t('Show performance statistics'), '#default_value' => $config->get('ui.show.performance_statistics'));
     $form['live_preview']['options']['ui_show_additional_queries'] = array('#type' => 'checkbox', '#title' => $this->t('Show other queries run during render during live preview'), '#description' => $this->t("Drupal has the potential to run many queries while a view is being rendered. Checking this box will display every query run during view render as part of the live preview."), '#default_value' => $config->get('ui.show.additional_queries'));
     return $form;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:30,代码来源:BasicSettingsForm.php


示例7: buildConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $form['theme'] = array('#type' => 'select', '#title' => $this->t('Theme'), '#default_value' => $this->configuration['theme'], '#options' => array_map(function ($theme_info) {
         return $theme_info->info['name'];
     }, $this->themeHandler->listInfo()));
     return parent::buildConfigurationForm($form, $form_state);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:CurrentThemeCondition.php


示例8: listing

 /**
  * Shows the block administration page.
  *
  * @param string|null $theme
  *   Theme key of block list.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  *
  * @return array
  *   A render array as expected by drupal_render().
  */
 public function listing($theme = NULL, Request $request = NULL)
 {
     $theme = $theme ?: $this->config('system.theme')->get('default');
     if (!$this->themeHandler->hasUi($theme)) {
         throw new NotFoundHttpException();
     }
     return $this->entityManager()->getListBuilder('block')->render($theme, $request);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:19,代码来源:BlockListController.php


示例9: testUpdateHookN

 /**
  * Tests that the Stable base theme is installed if necessary.
  */
 public function testUpdateHookN()
 {
     $this->assertTrue($this->themeHandler->themeExists('test_stable'));
     $this->assertFalse($this->themeHandler->themeExists('stable'));
     $this->runUpdates();
     // Refresh the theme handler now that Stable has been installed.
     $this->themeHandler->refreshInfo();
     $this->assertTrue($this->themeHandler->themeExists('stable'));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:StableBaseThemeUpdateTest.php


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


示例11: collect

 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = NULL)
 {
     $modules = $this->moduleHandler->getModuleList();
     $themes = $this->themeHandler->listInfo();
     $this->data['drupal_extension']['count'] = count($modules) + count($themes);
     $this->data['drupal_extension']['modules'] = $modules;
     $this->data['drupal_extension']['themes'] = $themes;
     $this->data['drupal_extension']['installation_path'] = $this->root . '/';
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:12,代码来源:ExtensionDataCollector.php


示例12: getExtensions

 /**
  * {@inheritdoc}
  */
 public function getExtensions()
 {
     foreach ($this->moduleHandler->getModuleList() as $module) {
         (yield $this->wrapCoreExtension($module));
     }
     foreach ($this->themeHandler->listInfo() as $theme) {
         (yield $this->wrapCoreExtension($theme));
     }
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:12,代码来源:ExtensionHandler.php


示例13: 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;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:19,代码来源:BlockController.php


示例14: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->themeHandler->listInfo() as $theme_name => $theme) {
         if ($theme->status) {
             $this->derivatives[$theme_name] = $base_plugin_definition;
             $this->derivatives[$theme_name]['title'] = $theme->info['name'];
             $this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name);
         }
     }
     return $this->derivatives;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:14,代码来源:ThemeLocalTask.php


示例15: onSave

 /**
  * Invalidate the 'rendered' cache tag whenever a theme setting is modified.
  *
  * @param \Drupal\Core\Config\ConfigCrudEvent $event
  *   The Event to process.
  */
 public function onSave(ConfigCrudEvent $event)
 {
     // Global theme settings.
     if ($event->getConfig()->getName() === 'system.theme.global') {
         $this->cacheTagsInvalidator->invalidateTags(['rendered']);
     }
     // Theme-specific settings, check if this matches a theme settings
     // configuration object, in that case, clear the rendered cache tag.
     foreach (array_keys($this->themeHandler->listInfo()) as $theme_name) {
         if ($theme_name == $event->getConfig()->getName()) {
             $this->cacheTagsInvalidator->invalidateTags(['rendered']);
             break;
         }
     }
 }
开发者ID:dev981,项目名称:gaptest,代码行数:21,代码来源:ThemeSettingsCacheTag.php


示例16: getExtensions

 /**
  * Gets all extensions.
  *
  * @return array
  */
 protected function getExtensions()
 {
     if (!isset($this->extensions)) {
         $this->extensions = array_merge($this->moduleHandler->getModuleList(), $this->themeHandler->listInfo());
     }
     return $this->extensions;
 }
开发者ID:shawnmmatthews,项目名称:gerber8,代码行数:12,代码来源:ThemeInitialization.php


示例17: setDefaultTheme

 /**
  * Set the default theme.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   A request object containing a theme name.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   Redirects back to the appearance admin page.
  *
  * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  *   Throws access denied when no theme is set in the request.
  */
 public function setDefaultTheme(Request $request)
 {
     $config = $this->configFactory->getEditable('system.theme');
     $theme = $request->query->get('theme');
     if (isset($theme)) {
         // Get current list of themes.
         $themes = $this->themeHandler->listInfo();
         // Check if the specified theme is one recognized by the system.
         // Or try to install the theme.
         if (isset($themes[$theme]) || $this->themeHandler->install(array($theme))) {
             $themes = $this->themeHandler->listInfo();
             // Set the default theme.
             $config->set('default', $theme)->save();
             $this->routeBuilder->setRebuildNeeded();
             // The status message depends on whether an admin theme is currently in
             // use: a value of 0 means the admin theme is set to be the default
             // theme.
             $admin_theme = $config->get('admin');
             if ($admin_theme != 0 && $admin_theme != $theme) {
                 drupal_set_message($this->t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array('%admin_theme' => $themes[$admin_theme]->info['name'], '%selected_theme' => $themes[$theme]->info['name'])));
             } else {
                 drupal_set_message($this->t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name'])));
             }
         } else {
             drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
         }
         return $this->redirect('system.themes_page');
     }
     throw new AccessDeniedHttpException();
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:42,代码来源:ThemeController.php


示例18: addCss

 /**
  * Inject the relevant css for the template.
  *
  * You can specify CSS files to be included per entity type and bundle in your
  * themes css file. This code uses your current theme which is likely to be the
  * front end theme.
  *
  * Examples:
  *
  * entity_print:
  *   all: 'yourtheme/all-pdfs',
  *   commerce_order:
  *     all: 'yourtheme/orders'
  *   node:
  *     article: 'yourtheme/article-pdf'
  *
  * @param array $render
  *   The renderable array.
  * @param \Drupal\Core\Entity\ContentEntityInterface $entity
  *   The entity info from entity_get_info().
  *
  * @return array
  *   An array of stylesheets to be used for this template.
  */
 protected function addCss($render, ContentEntityInterface $entity)
 {
     $theme = $this->themeHandler->getDefault();
     $theme_path = $this->getThemePath($theme);
     /** @var \Drupal\Core\Extension\InfoParser $parser */
     $theme_info = $this->infoParser->parse("{$theme_path}/{$theme}.info.yml");
     // Parse out the CSS from the theme info.
     if (isset($theme_info['entity_print'])) {
         // See if we have the special "all" key which is added to every PDF.
         if (isset($theme_info['entity_print']['all'])) {
             $render['#attached']['library'][] = $theme_info['entity_print']['all'];
             unset($theme_info['entity_print']['all']);
         }
         foreach ($theme_info['entity_print'] as $key => $value) {
             // If the entity type doesn't match just skip.
             if ($key !== $entity->getEntityTypeId()) {
                 continue;
             }
             // Parse our css files per entity type and bundle.
             foreach ($value as $css_bundle => $css) {
                 // If it's magic key "all" add it otherwise check the bundle.
                 if ($css_bundle === 'all' || $entity->bundle() === $css_bundle) {
                     $render['#attached']['library'][] = $css;
                 }
             }
         }
     }
     return $render;
 }
开发者ID:gerbreown1,项目名称:calvaryfree,代码行数:53,代码来源:EntityPrintPdfBuilder.php


示例19: getThemeData

 /**
  * Gets theme data.
  *
  * @return \Drupal\Core\Extension\Extension[]
  */
 protected function getThemeData()
 {
     if (!isset($this->themeData)) {
         $this->themeData = $this->themeHandler->rebuildThemeData();
     }
     return $this->themeData;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:ConfigImportSubscriber.php


示例20: getAncestry

 /**
  * Retrieves the full base/sub-theme ancestry of a theme.
  *
  * @param bool $reverse
  *   Whether or not to return the array of themes in reverse order, where the
  *   active theme is the first entry.
  *
  * @return \Drupal\bootstrap\Theme[]
  *   An associative array of \Drupal\bootstrap objects (theme), keyed
  *   by machine name.
  */
 public function getAncestry($reverse = FALSE)
 {
     $ancestry = $this->themeHandler->getBaseThemes($this->themes, $this->getName());
     foreach (array_keys($ancestry) as $name) {
         $ancestry[$name] = Bootstrap::getTheme($name, $this->themeHandler);
     }
     $ancestry[$this->getName()] = $this;
     return $reverse ? array_reverse($ancestry) : $ancestry;
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:20,代码来源:Theme.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Field\BaseFieldDefinition类代码示例发布时间:2022-05-23
下一篇:
PHP Extension\ModuleHandlerInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap