Commit 5a6647be authored by webchick's avatar webchick
Browse files

Issue #1964348 by damiankloip, xjm, dawehner: Rename...

Issue #1964348 by damiankloip, xjm, dawehner: Rename DisplayPluginBase::getStylePlugin() and enable type filtering for more plugin types.
parent b2e49105
......@@ -21,7 +21,7 @@
* help = @Translation("Display the comment with standard comment view."),
* base = {"comment"},
* entity_type = "comment",
* type = "normal"
* display_types = {"normal"}
* )
*/
class CommentRow extends EntityRow {
......
......@@ -21,7 +21,7 @@
* help = @Translation("Display the comment as RSS."),
* theme = "views_view_row_rss",
* base = {"comment"},
* type = "feed"
* display_types = {"feed"}
* )
*/
class Rss extends RowPluginBase {
......
......@@ -82,9 +82,9 @@ public function optionsSummary(&$categories, &$options) {
}
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::getStyleType().
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::getType().
*/
protected function getStyleType() {
protected function getType() {
return 'entity_reference';
}
......
......@@ -21,7 +21,7 @@
* title = @Translation("Entity Reference inline fields"),
* help = @Translation("Displays the fields with an optional template."),
* theme = "views_view_fields",
* type = "entity_reference"
* display_types = {"entity_reference"}
* )
*/
class EntityReference extends Fields {
......
......@@ -21,7 +21,7 @@
* title = @Translation("Entity Reference list"),
* help = @Translation("Returns results as a PHP array of labels and rendered rows."),
* theme = "views_view_unformatted",
* type = "entity_reference"
* display_types = {"entity_reference"}
* )
*/
class EntityReference extends StylePluginBase {
......
......@@ -26,7 +26,7 @@
* help = @Translation("Display the content with standard node view."),
* base = {"node"},
* entity_type = "node",
* type = "normal"
* display_types = {"normal"}
* )
*/
class NodeRow extends EntityRow {
......
......@@ -21,7 +21,7 @@
* help = @Translation("Display the content with standard node view."),
* theme = "views_view_row_rss",
* base = {"node"},
* type = "feed",
* display_types = {"feed"},
* module = "node"
* )
*/
......
......@@ -83,9 +83,9 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
}
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::getStyleType().
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::getType().
*/
protected function getStyleType() {
protected function getType() {
return 'data';
}
......
......@@ -22,7 +22,7 @@
* module = "rest",
* title = @Translation("Entity"),
* help = @Translation("Use entities as row data."),
* type = "data"
* display_types = {"data"}
* )
*/
class DataEntityRow extends RowPluginBase {
......
......@@ -23,7 +23,7 @@
* module = "rest",
* title = @Translation("Fields"),
* help = @Translation("Use fields as row data."),
* type = "data"
* display_types = {"data"}
* )
*/
class DataFieldRow extends RowPluginBase {
......
......@@ -23,7 +23,7 @@
* module = "rest",
* title = @Translation("Serializer"),
* help = @Translation("Serializes views row data using the Serializer component."),
* type = "data"
* display_types = {"data"}
* )
*/
class Serializer extends StylePluginBase {
......
......@@ -23,7 +23,7 @@
* help = @Translation("Display the user with standard user view."),
* base = {"users"},
* entity_type = "user",
* type = "normal"
* display_types = {"normal"}
* )
*/
class UserRow extends EntityRow {
......
......@@ -567,7 +567,7 @@ function default_summary_form(&$form, &$form_state) {
$summary_plugins = array();
$format_options = array();
foreach ($style_plugins as $key => $plugin) {
if (isset($plugin['type']) && $plugin['type'] == 'summary') {
if (isset($plugin['display_types']) && in_array('summary', $plugin['display_types'])) {
$summary_plugins[$key] = $plugin;
$format_options[$key] = $plugin['title'];
}
......
......@@ -1472,7 +1472,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$access = $this->getOption('access');
$form['access']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('access', NULL, array($this->view->storage->get('base_table'))),
'#options' => views_fetch_plugin_names('access', $this->getType(), array($this->view->storage->get('base_table'))),
'#default_value' => $access['type'],
);
......@@ -1507,7 +1507,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$cache = $this->getOption('cache');
$form['cache']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('cache', NULL, array($this->view->storage->get('base_table'))),
'#options' => views_fetch_plugin_names('cache', $this->getType(), array($this->view->storage->get('base_table'))),
'#default_value' => $cache['type'],
);
......@@ -1598,7 +1598,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$style_plugin = $this->getPlugin('style');
$form['style'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('style', $this->getStyleType(), array($this->view->storage->get('base_table'))),
'#options' => views_fetch_plugin_names('style', $this->getType(), array($this->view->storage->get('base_table'))),
'#default_value' => $style_plugin->definition['id'],
'#description' => t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'),
);
......@@ -1640,7 +1640,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$row_plugin_instance = $this->getPlugin('row');
$form['row'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('row', $this->getStyleType(), array($this->view->storage->get('base_table'))),
'#options' => views_fetch_plugin_names('row', $this->getType(), array($this->view->storage->get('base_table'))),
'#default_value' => $row_plugin_instance->definition['id'],
);
......@@ -1955,7 +1955,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$exposed_form = $this->getOption('exposed_form');
$form['exposed_form']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('exposed_form', NULL, array($this->view->storage->get('base_table'))),
'#options' => views_fetch_plugin_names('exposed_form', $this->getType(), array($this->view->storage->get('base_table'))),
'#default_value' => $exposed_form['type'],
);
......@@ -2553,10 +2553,21 @@ function preview() {
}
/**
* Displays can require a certain type of style plugin. By default, they will
* be 'normal'.
* Returns the display type that this display requires.
*
* This can be used for filtering views plugins. E.g. if a plugin category of
* 'foo' is specified, only plugins with no 'types' declared or 'types'
* containing 'foo'. If you have a type of bar, this plugin will not be used.
* This is applicable for style, row, access, cache, and exposed_form plugins.
*
* @return string
* The required display type. Defaults to 'normal'.
*
* @see views_fetch_plugin_names()
*/
protected function getStyleType() { return 'normal'; }
protected function getType() {
return 'normal';
}
/**
* Make sure the display and all associated handlers are valid.
......
......@@ -51,7 +51,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
// Set the default row style. Ideally this would be part of the option
// definition, but in this case it's dependent on the view's base table,
// which we don't know until init().
$row_plugins = views_fetch_plugin_names('row', $this->getStyleType(), array($view->storage->get('base_table')));
$row_plugins = views_fetch_plugin_names('row', $this->getType(), array($view->storage->get('base_table')));
$default_row_plugin = key($row_plugins);
if (empty($this->options['row']['type'])) {
$this->options['row']['type'] = $default_row_plugin;
......@@ -59,9 +59,9 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
}
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::getStyleType().
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::getType().
*/
protected function getStyleType() {
protected function getType() {
return 'feed';
}
......
......@@ -21,7 +21,7 @@
* id = "none",
* title = @Translation("Display all items"),
* help = @Translation("Display all items that this view might find."),
* type = "basic"
* display_types = {"basic"}
* )
*/
class None extends PagerPluginBase {
......
......@@ -19,7 +19,7 @@
* id = "some",
* title = @Translation("Display a specified number of items"),
* help = @Translation("Display a limited number items that this view might find."),
* type = "basic"
* display_types = {"basic"}
* )
*/
class Some extends PagerPluginBase {
......
......@@ -23,7 +23,7 @@
* title = @Translation("Fields"),
* help = @Translation("Displays the fields with an optional template."),
* theme = "views_view_fields",
* type = "normal"
* display_types = {"normal"}
* )
*/
class Fields extends RowPluginBase {
......
......@@ -18,7 +18,7 @@
* title = @Translation("Fields"),
* help = @Translation("Display fields as RSS items."),
* theme = "views_view_row_rss",
* type = "feed"
* display_types = {"feed"}
* )
*/
class RssFields extends RowPluginBase {
......
......@@ -21,7 +21,7 @@
* title = @Translation("Unformatted list"),
* help = @Translation("Displays rows one after another."),
* theme = "views_view_unformatted",
* type = "normal"
* display_types = {"normal"}
* )
*/
class DefaultStyle extends StylePluginBase {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment