Newer
Older
Angie Byron
committed
* Contains \Drupal\views\Plugin\views\display\DisplayPluginBase.
namespace Drupal\views\Plugin\views\display;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
Alex Pott
committed
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\CacheableDependencyInterface;
Dries Buytaert
committed
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Plugin\PluginDependencyTrait;
Angie Byron
committed
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
Alex Pott
committed
use Drupal\views\Form\ViewsForm;
use Drupal\views\Plugin\views\area\AreaPluginBase;
Daniel Wehner
committed
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
Dries Buytaert
committed
use Drupal\views\Views;
Angie Byron
committed
* Base class for views display plugins.
abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInterface, DependentPluginInterface {
use PluginDependencyTrait;
* @var \Drupal\views\ViewExecutable
/**
* An array of instantiated handlers used in this display.
*
* @var \Drupal\views\Plugin\views\ViewsHandlerInterface[]
*/
public $handlers = [];
Tim Plunkett
committed
/**
* An array of instantiated plugins used in this display.
*
* @var \Drupal\views\Plugin\views\ViewsPluginInterface[]
Tim Plunkett
committed
*/
protected $plugins = array();
/**
* Stores all available display extenders.
Dries Buytaert
committed
*
* @var \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase[]
Dries Buytaert
committed
protected $extenders = [];
Tim Plunkett
committed
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
protected $usesOptions = TRUE;
Tim Plunkett
committed
Daniel Wehner
committed
/**
* Stores the rendered output of the display.
*
* @see View::render
Daniel Wehner
committed
* @var string
*/
public $output = NULL;
Salvador Molina
committed
/**
* Whether the display allows the use of AJAX or not.
*
* @var bool
*/
protected $usesAJAX = TRUE;
Salvador Molina
committed
/**
* Whether the display allows the use of a pager or not.
*
* @var bool
*/
protected $usesPager = TRUE;
/**
* Whether the display allows the use of a 'more' link or not.
*
* @var bool
*/
protected $usesMore = TRUE;
Damian Lee
committed
/**
* Whether the display allows attachments.
*
* @var bool
* TRUE if the display can use attachments, or FALSE otherwise.
*/
protected $usesAttachments = FALSE;
Angie Byron
committed
/**
* Whether the display allows area plugins.
*
* @var bool
*/
protected $usesAreas = TRUE;
/**
* Static cache for unpackOptions, but not if we are in the UI.
*
* @var array
*/
protected static $unpackOptions = array();
/**
* The display information coming directly from the view entity.
*
* @see \Drupal\views\Entity\View::getDisplay()
*
* @todo \Drupal\views\Entity\View::duplicateDisplayAsType directly access it.
*
* @var array
*/
public $display;
/**
* Constructs a new DisplayPluginBase object.
*
* Because DisplayPluginBase::initDisplay() takes the display configuration by
* reference and handles it differently than usual plugin configuration, pass
* an empty array of configuration to the parent. This prevents our
* configuration from being duplicated.
*
* @todo Replace DisplayPluginBase::$display with
* DisplayPluginBase::$configuration to standardize with other plugins.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct(array(), $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) {
$this->view = $view;
Dries Buytaert
committed
$display['display_options'] += ['display_extenders' => []];
$this->extenders = array();
if ($extenders = Views::getEnabledDisplayExtenders()) {
Dries Buytaert
committed
$manager = Views::pluginManager('display_extender');
Dries Buytaert
committed
$display_extender_options = $display['display_options']['display_extenders'];
Dries Buytaert
committed
/** @var \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase $plugin */
if ($plugin = $manager->createInstance($extender)) {
Dries Buytaert
committed
$extender_options = isset($display_extender_options[$plugin->getPluginId()]) ? $display_extender_options[$plugin->getPluginId()] : [];
$plugin->init($this->view, $this, $extender_options);
$this->extenders[$extender] = $plugin;
Dries Buytaert
committed
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->display = &$display;
// Track changes that the user should know about.
$changed = FALSE;
Daniel Wehner
committed
if (!isset($options) && isset($display['display_options'])) {
$options = $display['display_options'];
Daniel Wehner
committed
if ($this->isDefaultDisplay() && isset($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;
$this->options = static::$unpackOptions[$cid];
$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;
}
}
/**
* {@inheritdoc}
*/
Daniel Wehner
committed
public function destroy() {
parent::destroy();
foreach ($this->handlers as $type => $handlers) {
foreach ($handlers as $id => $handler) {
if (is_object($handler)) {
$this->handlers[$type][$id]->destroy();
}
}
}
if (isset($this->default_display)) {
unset($this->default_display);
}
Dries Buytaert
committed
foreach ($this->extenders as $extender) {
$extender->destroy();
}
}
/**
Daniel Wehner
committed
public function isDefaultDisplay() { return FALSE; }
Daniel Wehner
committed
public function usesExposed() {
if (!isset($this->has_exposed)) {
foreach ($this->handlers as $type => $value) {
Angie Byron
committed
foreach ($this->view->$type as $handler) {
if ($handler->canExpose() && $handler->isExposed()) {
Alex Pott
committed
// One is all we need; if we find it, return TRUE.
$this->has_exposed = TRUE;
return TRUE;
}
}
}
Daniel Wehner
committed
$pager = $this->getPlugin('pager');
Alex Pott
committed
if (isset($pager) && $pager->usesExposed()) {
$this->has_exposed = TRUE;
return TRUE;
}
$this->has_exposed = FALSE;
}
return $this->has_exposed;
}
/**
Daniel Wehner
committed
public function displaysExposed() {
Salvador Molina
committed
*/
Daniel Wehner
committed
public function usesAJAX() {
Salvador Molina
committed
return $this->usesAJAX;
}
/**
public function ajaxEnabled() {
Salvador Molina
committed
if ($this->usesAJAX()) {
Daniel Wehner
committed
return $this->getOption('use_ajax');
Daniel Wehner
committed
/**
Daniel Wehner
committed
*/
public function isEnabled() {
return (bool) $this->getOption('enabled');
}
Salvador Molina
committed
*/
Daniel Wehner
committed
public function usesPager() {
Salvador Molina
committed
return $this->usesPager;
}
/**
Daniel Wehner
committed
public function isPagerEnabled() {
Salvador Molina
committed
if ($this->usesPager()) {
Daniel Wehner
committed
$pager = $this->getPlugin('pager');
Salvador Molina
committed
if ($pager) {
Alex Pott
committed
return $pager->usePager();
Salvador Molina
committed
}
Salvador Molina
committed
return FALSE;
Salvador Molina
committed
*/
Daniel Wehner
committed
public function usesMore() {
Salvador Molina
committed
return $this->usesMore;
}
/**
Daniel Wehner
committed
public function isMoreEnabled() {
Salvador Molina
committed
if ($this->usesMore()) {
Daniel Wehner
committed
return $this->getOption('use_more');
Daniel Wehner
committed
public function useGroupBy() {
return $this->getOption('group_by');
Daniel Wehner
committed
public function useMoreAlways() {
Salvador Molina
committed
if ($this->usesMore()) {
return $this->getOption('use_more_always');
Daniel Wehner
committed
public function useMoreText() {
Salvador Molina
committed
if ($this->usesMore()) {
return $this->getOption('use_more_text');
Daniel Wehner
committed
public function acceptAttachments() {
Angie Byron
committed
// To be able to accept attachments this display have to be able to use
// attachments but at the same time, you cannot attach a display to itself.
if (!$this->usesAttachments() || ($this->definition['id'] == $this->view->current_display)) {
Angie Byron
committed
Daniel Wehner
committed
if (!empty($this->view->argument) && $this->getOption('hide_attachment_summary')) {
Angie Byron
committed
foreach ($this->view->argument as $argument) {
if ($argument->needsStylePlugin() && empty($argument->argument_validated)) {
Angie Byron
committed
Damian Lee
committed
/**
Damian Lee
committed
*/
Daniel Wehner
committed
public function usesAttachments() {
Damian Lee
committed
return $this->usesAttachments;
}
Angie Byron
committed
/**
Angie Byron
committed
*/
public function usesAreas() {
return $this->usesAreas;
}
Alex Pott
committed
public function attachTo(ViewExecutable $view, $display_id, array &$build) { }
Daniel Wehner
committed
public function defaultableSections($section = NULL) {
'access' => array('access'),
'cache' => array('cache'),
'title' => array('title'),
'css_class' => array('css_class'),
'use_ajax' => array('use_ajax'),
'hide_attachment_summary' => array('hide_attachment_summary'),
Angie Byron
committed
'show_admin_links' => array('show_admin_links'),
'group_by' => array('group_by'),
'query' => array('query'),
'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
Daniel Wehner
committed
'use_more_always' => array('use_more', 'use_more_always', 'use_more_text'),
'use_more_text' => array('use_more', 'use_more_always', 'use_more_text'),
'link_display' => array('link_display', 'link_url'),
// Force these to cascade properly.
'style' => array('style', 'row'),
'row' => array('style', 'row'),
Alex Pott
committed
'pager' => array('pager'),
Alex Pott
committed
'exposed_form' => array('exposed_form'),
Alex Pott
committed
// These sections are special.
'header' => array('header'),
'footer' => array('footer'),
'empty' => array('empty'),
'relationships' => array('relationships'),
'fields' => array('fields'),
'sorts' => array('sorts'),
'arguments' => array('arguments'),
'filters' => array('filters', 'filter_groups'),
'filter_groups' => array('filters', 'filter_groups'),
);
// If the display cannot use a pager, then we cannot default it.
Salvador Molina
committed
if (!$this->usesPager()) {
unset($sections['pager']);
unset($sections['items_per_page']);
}
Dries Buytaert
committed
foreach ($this->extenders as $extender) {
Daniel Wehner
committed
$extender->defaultableSections($sections, $section);
}
if ($section) {
if (!empty($sections[$section])) {
return $sections[$section];
}
}
else {
return $sections;
}
}
protected function defineOptions() {
$options = array(
'defaults' => array(
'default' => array(
'access' => TRUE,
'cache' => TRUE,
'query' => TRUE,
'title' => TRUE,
'css_class' => TRUE,
'display_description' => FALSE,
'use_ajax' => TRUE,
'hide_attachment_summary' => TRUE,
Angie Byron
committed
'show_admin_links' => TRUE,
'pager' => TRUE,
'use_more' => TRUE,
'use_more_always' => TRUE,
'use_more_text' => TRUE,
'exposed_form' => TRUE,
'link_display' => TRUE,
Angie Byron
committed
'link_url' => TRUE,
'style' => TRUE,
'row' => TRUE,
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
'header' => TRUE,
'footer' => TRUE,
'empty' => TRUE,
'relationships' => TRUE,
'fields' => TRUE,
'sorts' => TRUE,
'arguments' => TRUE,
'filters' => TRUE,
'filter_groups' => TRUE,
),
),
'title' => array(
'default' => '',
),
'enabled' => array(
'default' => TRUE,
),
'display_comment' => array(
'default' => '',
),
'css_class' => array(
'default' => '',
),
'display_description' => array(
'default' => '',
),
'use_ajax' => array(
'default' => FALSE,
),
'hide_attachment_summary' => array(
'default' => FALSE,
),
Angie Byron
committed
'show_admin_links' => array(
'default' => TRUE,
Damian Lee
committed
),
'use_more' => array(
'default' => FALSE,
),
'use_more_always' => array(
Angie Byron
committed
'default' => TRUE,
),
'use_more_text' => array(
'default' => 'more',
),
'link_display' => array(
'default' => '',
),
'link_url' => array(
'default' => '',
),
'group_by' => array(
'default' => FALSE,
),
Alex Pott
committed
'rendering_language' => array(
Alex Pott
committed
'default' => '***LANGUAGE_entity_translation***',
Alex Pott
committed
),
// These types are all plugins that can have individual settings
// and therefore need special handling.
'access' => array(
'contains' => array(
Tim Plunkett
committed
'type' => array('default' => 'none'),
'options' => array('default' => array()),
),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
),
'cache' => array(
'contains' => array(
'type' => array('default' => 'tag'),
'options' => array('default' => array()),
),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
),
'query' => array(
'contains' => array(
Tim Plunkett
committed
'type' => array('default' => 'views_query'),
'options' => array('default' => array()),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
),
'exposed_form' => array(
'contains' => array(
Tim Plunkett
committed
'type' => array('default' => 'basic'),
'options' => array('default' => array()),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
),
'pager' => array(
'contains' => array(
'type' => array('default' => 'mini'),
Tim Plunkett
committed
'options' => array('default' => array()),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
'style' => array(
'contains' => array(
'type' => array('default' => 'default'),
'options' => array('default' => array()),
),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
'row' => array(
'contains' => array(
'type' => array('default' => 'fields'),
'options' => array('default' => array()),
),
Alex Pott
committed
'merge_defaults' => array($this, 'mergePlugin'),
),
'exposed_block' => array(
'default' => FALSE,
),
'header' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
'footer' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
'empty' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
// We want these to export last.
// These are the 5 handler types.
'relationships' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
'fields' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
'sorts' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
'arguments' => array(
'default' => array(),
Alex Pott
committed
'merge_defaults' => array($this, 'mergeHandler'),
),
'filter_groups' => array(
'contains' => array(
'operator' => array('default' => 'AND'),
'groups' => array('default' => array(1 => 'AND')),
),
),
'filters' => array(
'default' => array(),
),
);
Salvador Molina
committed
if (!$this->usesPager()) {
$options['defaults']['default']['pager'] = FALSE;
$options['pager']['contains']['type']['default'] = 'some';
}
Daniel Wehner
committed
if ($this->isDefaultDisplay()) {
Dries Buytaert
committed
$options['display_extenders'] = ['default' => []];
// First allow display extenders to provide new options.
foreach ($this->extenders as $extender_id => $extender) {
$options['display_extenders']['contains'][$extender_id]['contains'] = $extender->defineOptions();
}
// Then allow display extenders to alter existing default values.
foreach ($this->extenders as $extender) {
Daniel Wehner
committed
$extender->defineOptionsAlter($options);
Daniel Wehner
committed
public function hasPath() { return FALSE; }
Daniel Wehner
committed
public function usesLinkDisplay() { return !$this->hasPath(); }
Daniel Wehner
committed
public function usesExposedFormInBlock() { return $this->hasPath(); }
catch
committed
/**
catch
committed
*/
public function getAttachedDisplays() {
$current_display_id = $this->display['id'];
$attached_displays = array();
// Go through all displays and search displays which link to this one.
foreach ($this->view->storage->get('display') as $display_id => $display) {
if (isset($display['display_options']['displays'])) {
$displays = $display['display_options']['displays'];
if (isset($displays[$current_display_id])) {
$attached_displays[] = $display_id;
}
}
}
return $attached_displays;
}
Daniel Wehner
committed
public function getLinkDisplay() {
$display_id = $this->getOption('link_display');
if (empty($display_id) || !$this->view->displayHandlers->has($display_id)) {
Daniel Wehner
committed
foreach ($this->view->displayHandlers as $display_id => $display) {
if (!empty($display) && $display->hasPath()) {
return $display_id;
}
}
}
else {
return $display_id;
}
Alex Pott
committed
// Fall-through returns NULL.
Daniel Wehner
committed
public function getPath() {
if ($this->hasPath()) {
return $this->getOption('path');
Daniel Wehner
committed
$display_id = $this->getLinkDisplay();
if ($display_id && $this->view->displayHandlers->has($display_id) && is_object($this->view->displayHandlers->get($display_id))) {
return $this->view->displayHandlers->get($display_id)->getPath();
/**
* {@inheritdoc}
*/
public function getRoutedDisplay() {
// If this display has a route, return this display.
if ($this instanceof DisplayRouterInterface) {
return $this;
}
// If the display does not have a route (e.g. a block display), get the
// route for the linked display.
$display_id = $this->getLinkDisplay();
if ($display_id && $this->view->displayHandlers->has($display_id) && is_object($this->view->displayHandlers->get($display_id))) {
return $this->view->displayHandlers->get($display_id)->getRoutedDisplay();
}
// No routed display exists, so return NULL
return NULL;
}
/**
* {@inheritdoc}
*/
Daniel Wehner
committed
public function getUrl() {
return $this->view->getUrl(NULL, $this->display['id']);
Daniel Wehner
committed
public function isDefaulted($option) {
return !$this->isDefaultDisplay() && !empty($this->default_display) && !empty($this->options['defaults'][$option]);
Daniel Wehner
committed
public function getOption($option) {
if ($this->isDefaulted($option)) {
return $this->default_display->getOption($option);
}
if (array_key_exists($option, $this->options)) {
return $this->options[$option];
}
}
/**
Daniel Wehner
committed
public function usesFields() {
Tim Plunkett
committed
return $this->getPlugin('style')->usesFields();
Tim Plunkett
committed
*/
public function getPlugin($type) {
Tim Plunkett
committed
// Look up the plugin name to use for this instance.
Tim Plunkett
committed
$options = $this->getOption($type);
// Return now if no options have been loaded.
if (empty($options) || !isset($options['type'])) {
return;
}
Tim Plunkett
committed
// Query plugins allow specifying a specific query class per base table.
if ($type == 'query') {
Dries Buytaert
committed
$views_data = Views::viewsData()->get($this->view->storage->get('base_table'));
catch
committed
$name = isset($views_data['table']['base']['query_id']) ? $views_data['table']['base']['query_id'] : 'views_query';
Tim Plunkett
committed
}
else {
$name = $options['type'];
}
Tim Plunkett
committed
// Plugin instances are stored on the display for re-use.
if (!isset($this->plugins[$type][$name])) {
Dries Buytaert
committed
$plugin = Views::pluginManager($type)->createInstance($name);
catch
committed
// Initialize the plugin.
$plugin->init($this->view, $this, $options['options']);
Tim Plunkett
committed
Tim Plunkett
committed
$this->plugins[$type][$name] = $plugin;
Tim Plunkett
committed
return $this->plugins[$type][$name];
Daniel Wehner
committed
public function &getHandler($type, $id) {
Daniel Wehner
committed
$this->getHandlers($type);
}
if (isset($this->handlers[$type][$id])) {
return $this->handlers[$type][$id];
}
// So we can return a reference.
$null = NULL;
return $null;
}
/**
Alex Pott
committed
public function &getHandlers($type) {
if (!isset($this->handlers[$type])) {
$this->handlers[$type] = array();
catch
committed
$types = ViewExecutable::getHandlerTypes();
// Cast to an array so that if the display does not have any handlers of
// this type there is no PHP error.
foreach ((array) $this->getOption($plural) as $id => $info) {
// If this is during form submission and there are temporary options
// which can only appear if the view is in the edit cache, use those
// options instead. This is used for AJAX multi-step stuff.
Alex Pott
committed
if ($this->view->getRequest()->request->get('form_id') && isset($this->view->temporary_options[$type][$id])) {
$info = $this->view->temporary_options[$type][$id];
}
if ($info['id'] != $id) {
$info['id'] = $id;
}
// If aggregation is on, the group type might override the actual
// handler that is in use. This piece of code checks that and,
// if necessary, sets the override handler.
$override = NULL;
Daniel Wehner
committed
if ($this->useGroupBy() && !empty($info['group_type'])) {
Damian Lee
committed
$this->view->initQuery();
$aggregate = $this->view->query->getAggregationInfo();
if (!empty($aggregate[$info['group_type']]['handler'][$type])) {
$override = $aggregate[$info['group_type']]['handler'][$type];
}
}
if (!empty($types[$type]['type'])) {
$handler_type = $types[$type]['type'];
}
else {
$handler_type = $type;
}
Dries Buytaert
committed
if ($handler = Views::handlerManager($handler_type)->getHandler($info, $override)) {
// Special override for area types so they know where they come from.
if ($handler instanceof AreaPluginBase) {
$handler->areaType = $type;
$handler->init($this->view, $this, $info);
$this->handlers[$type][$id] = &$handler;
}
// Prevent reference problems.
unset($handler);
}
}
return $this->handlers[$type];
}
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
/**
* Gets all the handlers used by the display.
*
* @param bool $only_overrides
* Whether to include only overridden handlers.
*
* @return \Drupal\views\Plugin\views\ViewsHandlerInterface[]
*/
protected function getAllHandlers($only_overrides = FALSE) {
$handler_types = Views::getHandlerTypes();
$handlers = [];
// Collect all dependencies of all handlers.
foreach ($handler_types as $handler_type => $handler_type_info) {
if ($only_overrides && $this->isDefaulted($handler_type_info['plural'])) {
continue;
}
$handlers = array_merge($handlers, array_values($this->getHandlers($handler_type)));
}
return $handlers;
}
/**
* Gets all the plugins used by the display.
*
* @param bool $only_overrides
* Whether to include only overridden plugins.
*
* @return \Drupal\views\Plugin\views\ViewsPluginInterface[]
*/
protected function getAllPlugins($only_overrides = FALSE) {
$plugins = [];
// Collect all dependencies of plugins.
foreach (Views::getPluginTypes('plugin') as $plugin_type) {
$plugin = $this->getPlugin($plugin_type);
if (!$plugin) {
continue;
}
if ($only_overrides && $this->isDefaulted($plugin_type)) {
continue;
}
$plugins[] = $plugin;
}
return $plugins;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
$this->addDependencies(parent::calculateDependencies());
// Collect all the dependencies of handlers and plugins. Only calculate
// their dependencies if they are configured by this display.
$plugins = array_merge($this->getAllHandlers(TRUE), $this->getAllPlugins(TRUE));
array_walk($plugins, array($this, 'calculatePluginDependencies'));
return $this->dependencies;
}
public function getFieldLabels($groupable_only = FALSE) {
Daniel Wehner
committed
foreach ($this->getHandlers('relationship') as $relationship => $handler) {
Alex Pott
committed
$relationships[$relationship] = $handler->adminLabel();
Daniel Wehner
committed
foreach ($this->getHandlers('field') as $id => $handler) {
Alex Pott
committed
if ($groupable_only && !$handler->useStringGroupBy()) {
// Continue to next handler if it's not groupable.
continue;
}
if ($label = $handler->label()) {
$options[$id] = $label;
}
else {
$options[$id] = $handler->adminLabel();
}
if (!empty($handler->options['relationship']) && !empty($relationships[$handler->options['relationship']])) {
$options[$id] = '(' . $relationships[$handler->options['relationship']] . ') ' . $options[$id];
}
}
return $options;
}
/**
Daniel Wehner
committed
public function setOption($option, $value) {
if ($this->isDefaulted($option)) {
return $this->default_display->setOption($option, $value);
}
// Set this in two places: On the handler where we'll notice it
// but also on the display object so it gets saved. This should