本文整理汇总了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.');
}
示例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;
}
}
示例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;
}
}