當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。