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


PHP Views::getEnabledDisplayExtenders方法代码示例

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


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

示例1: testDisplayExtenders

 /**
  * Test display extenders.
  */
 public function testDisplayExtenders()
 {
     $this->config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
     $this->assertEqual(count(Views::getEnabledDisplayExtenders()), 1, 'Make sure that there is only one enabled display extender.');
     $view = Views::getView('test_view');
     $view->initDisplay();
     $this->assertEqual(count($view->display_handler->getExtenders()), 1, 'Make sure that only one extender is initialized.');
     $display_extender = $view->display_handler->getExtenders()['display_extender_test'];
     $this->assertTrue($display_extender instanceof \Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest, 'Make sure the right class got initialized.');
     $view->preExecute();
     $this->assertTrue($display_extender->testState['preExecute'], 'Make sure the display extender was able to react on preExecute.');
     $view->execute();
     $this->assertTrue($display_extender->testState['query'], 'Make sure the display extender was able to react on query.');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:17,代码来源:DisplayExtenderTest.php

示例2: initDisplay

 /**
  * {@inheritdoc}
  */
 public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL)
 {
     $this->view = $view;
     // Load extenders as soon as possible.
     $display['display_options'] += ['display_extenders' => []];
     $this->extenders = array();
     if ($extenders = Views::getEnabledDisplayExtenders()) {
         $manager = Views::pluginManager('display_extender');
         $display_extender_options = $display['display_options']['display_extenders'];
         foreach ($extenders as $extender) {
             /** @var \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase $plugin */
             if ($plugin = $manager->createInstance($extender)) {
                 $extender_options = isset($display_extender_options[$plugin->getPluginId()]) ? $display_extender_options[$plugin->getPluginId()] : [];
                 $plugin->init($this->view, $this, $extender_options);
                 $this->extenders[$extender] = $plugin;
             }
         }
     }
     $this->setOptionDefaults($this->options, $this->defineOptions());
     $this->display =& $display;
     // Track changes that the user should know about.
     $changed = FALSE;
     if (!isset($options) && isset($display['display_options'])) {
         $options = $display['display_options'];
     }
     if ($this->isDefaultDisplay() && isset($options['defaults'])) {
         unset($options['defaults']);
     }
     $skip_cache = \Drupal::config('views.settings')->get('skip_cache');
     if (empty($view->editing) || !$skip_cache) {
         $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->getId();
         if (empty(static::$unpackOptions[$cid])) {
             $cache = \Drupal::cache('data')->get($cid);
             if (!empty($cache->data)) {
                 $this->options = $cache->data;
             } else {
                 $this->unpackOptions($this->options, $options);
                 \Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, $this->view->storage->getCacheTags());
             }
             static::$unpackOptions[$cid] = $this->options;
         } else {
             $this->options = static::$unpackOptions[$cid];
         }
     } else {
         $this->unpackOptions($this->options, $options);
     }
     // Mark the view as changed so the user has a chance to save it.
     if ($changed) {
         $this->view->changed = TRUE;
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:54,代码来源:DisplayPluginBase.php

示例3: initDisplay

 public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL)
 {
     $this->view = $view;
     $this->setOptionDefaults($this->options, $this->defineOptions());
     $this->display =& $display;
     // Load extenders as soon as possible.
     $this->extender = array();
     if ($extenders = Views::getEnabledDisplayExtenders()) {
         $manager = Views::pluginManager('display_extender');
         foreach ($extenders as $extender) {
             if ($plugin = $manager->createInstance($extender)) {
                 $plugin->init($this->view, $this);
                 $this->extender[$extender] = $plugin;
             }
         }
     }
     // Track changes that the user should know about.
     $changed = FALSE;
     // Make some modifications:
     if (!isset($options) && isset($display['display_options'])) {
         $options = $display['display_options'];
     }
     if ($this->isDefaultDisplay() && isset($options['defaults'])) {
         unset($options['defaults']);
     }
     $skip_cache = \Drupal::config('views.settings')->get('skip_cache');
     if (empty($view->editing) || !$skip_cache) {
         $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->id;
         if (empty(static::$unpackOptions[$cid])) {
             $cache = \Drupal::cache('data')->get($cid);
             if (!empty($cache->data)) {
                 $this->options = $cache->data;
             } else {
                 $this->unpackOptions($this->options, $options);
                 $id = $this->view->storage->id();
                 \Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, array('extension' => array(TRUE, 'views'), 'view' => array($id => $id)));
             }
             static::$unpackOptions[$cid] = $this->options;
         } else {
             $this->options = static::$unpackOptions[$cid];
         }
     } else {
         $this->unpackOptions($this->options, $options);
     }
     // Convert the field_langcode and field_language_add_to_query settings.
     $field_langcode = $this->getOption('field_langcode');
     $field_language_add_to_query = $this->getOption('field_language_add_to_query');
     if (isset($field_langcode)) {
         $this->setOption('field_langcode', $field_langcode);
         $this->setOption('field_langcode_add_to_query', $field_language_add_to_query);
         $changed = TRUE;
     }
     // Mark the view as changed so the user has a chance to save it.
     if ($changed) {
         $this->view->changed = TRUE;
     }
 }
开发者ID:shumer,项目名称:blog,代码行数:57,代码来源:DisplayPluginBase.php


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