Commit e6bddaea authored by tim.plunkett's avatar tim.plunkett
Browse files

Issue #1744186 by damiankloip, tim.plunkett: Move uses_options() from plugin...

Issue #1744186 by damiankloip, tim.plunkett: Move uses_options() from plugin annotation to a class property.
parent 53c7d235
......@@ -46,6 +46,13 @@ abstract class PluginBase extends ComponentPluginBase {
*/
public $localization_keys;
/**
* Denotes whether the plugin has an additional options form.
*
* @var bool
*/
public $usesOptions = FALSE;
/**
* Constructs a Plugin object.
*/
......@@ -452,4 +459,11 @@ function plugin_title() {
return check_plain($this->definition['title']);
}
/**
* Returns the usesOptions property.
*/
function usesOptions() {
return $this->usesOptions;
}
}
......@@ -19,12 +19,16 @@
* id = "perm",
* title = @Translation("Permission"),
* help = @Translation("Access will be granted to users with the specified permission string."),
* help_topic = "access-perm",
* uses_options = TRUE
* help_topic = "access-perm"
* )
*/
class Permission extends AccessPluginBase {
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
function access($account) {
return views_check_perm($this->options['perm'], $account);
}
......
......@@ -19,12 +19,16 @@
* id = "role",
* title = @Translation("Role"),
* help = @Translation("Access will be granted to users with any of the specified roles."),
* help_topic = "access-role",
* uses_options = TRUE
* help_topic = "access-role"
* )
*/
class Role extends AccessPluginBase {
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
function access($account) {
return views_check_roles(array_filter($this->options['role']), $account);
}
......
......@@ -678,10 +678,10 @@ function default_summary_form(&$form, &$form_state) {
);
foreach ($summary_plugins as $id => $info) {
if (empty($info['uses_options'])) {
$plugin = $this->get_plugin('style', $id);
if (!$plugin->usesOptions()) {
continue;
}
$plugin = $this->get_plugin('style', $id);
if ($plugin) {
$form['summary']['options'][$id] = array(
'#prefix' => '<div id="edit-options-summary-options-' . $id . '-wrapper">',
......
......@@ -19,12 +19,16 @@
* id = "time",
* title = @Translation("Time-based"),
* help = @Translation("Simple time-based caching of data."),
* help_topic = "cache-time",
* uses_options = TRUE
* help_topic = "cache-time"
* )
*/
class Time extends CachePluginBase {
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
function option_definition() {
$options = parent::option_definition();
$options['results_lifespan'] = array('default' => 3600);
......
......@@ -44,6 +44,11 @@ abstract class DisplayPluginBase extends PluginBase {
*/
var $extender = array();
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
/**
* Stores the rendered output of the display.
*
......@@ -1209,7 +1214,7 @@ function options_summary(&$categories, &$options) {
);
// This adds a 'Settings' link to the style_options setting if the style has options.
if (!empty($style_plugin['uses_options'])) {
if ($style_plugin_instance->usesOptions()) {
$options['style_plugin']['links']['style_options'] = t('Change settings for this format');
}
......@@ -1228,7 +1233,7 @@ function options_summary(&$categories, &$options) {
'desc' => t('Change the way each row in the view is styled.'),
);
// This adds a 'Settings' link to the row_options setting if the row style has options.
if (!empty($row_plugin['uses_options'])) {
if ($row_plugin_instance->usesOptions()) {
$options['row_plugin']['links']['row_options'] = t('Change settings for this style');
}
}
......@@ -1278,7 +1283,7 @@ function options_summary(&$categories, &$options) {
$options['pager']['title'] = t('Items to display');
}
if (!empty($pager_plugin->definition['uses_options'])) {
if ($pager_plugin->usesOptions()) {
$options['pager']['links']['pager_options'] = t('Change settings for this pager type.');
}
......@@ -1340,7 +1345,7 @@ function options_summary(&$categories, &$options) {
'desc' => t('Specify access control type for this display.'),
);
if (!empty($access_plugin->definition['uses_options'])) {
if ($access_plugin->usesOptions()) {
$options['access']['links']['access_options'] = t('Change settings for this access type.');
}
......@@ -1360,11 +1365,11 @@ function options_summary(&$categories, &$options) {
'desc' => t('Specify caching type for this display.'),
);
if (!empty($cache_plugin->definition['uses_options'])) {
if ($cache_plugin->usesOptions()) {
$options['cache']['links']['cache_options'] = t('Change settings for this caching type.');
}
if (!empty($access_plugin->definition['uses_options'])) {
if ($access_plugin->usesOptions()) {
$options['access']['links']['access_options'] = t('Change settings for this access type.');
}
......@@ -1405,7 +1410,7 @@ function options_summary(&$categories, &$options) {
'desc' => t('Select the kind of exposed filter to use.'),
);
if (!empty($exposed_form_plugin->definition['uses_options'])) {
if ($exposed_form_plugin->usesOptions()) {
$options['exposed_form']['links']['exposed_form_options'] = t('Exposed form settings for this exposed form style.');
}
......@@ -1586,8 +1591,8 @@ function options_form(&$form, &$form_state) {
'#default_value' => $access['type'],
);
$access_plugin = views_fetch_plugin_data('access', $access['type']);
if (!empty($access_plugin['uses_options'])) {
$access_plugin = $this->get_plugin('access');
if ($access_plugin->usesOptions()) {
$form['markup'] = array(
'#prefix' => '<div class="form-item description">',
'#markup' => t('You may also adjust the !settings for the currently selected access restriction.', array('!settings' => $this->option_link(t('settings'), 'access_options'))),
......@@ -1629,8 +1634,8 @@ function options_form(&$form, &$form_state) {
'#default_value' => $cache['type'],
);
$cache_plugin = views_fetch_plugin_data('cache', $cache['type']);
if (!empty($cache_plugin['uses_options'])) {
$cache_plugin = $this->get_plugin('cache');
if ($cache_plugin->usesOptions()) {
$form['markup'] = array(
'#prefix' => '<div class="form-item description">',
'#suffix' => '</div>',
......@@ -1738,8 +1743,8 @@ function options_form(&$form, &$form_state) {
'#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.'),
);
$style_plugin = $manager->getDefinition($this->get_option('style_plugin'));
if (!empty($style_plugin['uses_options'])) {
$style_plugin = $this->get_plugin('style');
if ($style_plugin->usesOptions()) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->option_link(t('settings'), 'style_options'))) . '</div>',
);
......@@ -1782,8 +1787,8 @@ function options_form(&$form, &$form_state) {
'#default_value' => $this->get_option('row_plugin'),
);
$row_plugin = views_fetch_plugin_data('row', $this->get_option('row_plugin'));
if (!empty($row_plugin['uses_options'])) {
$row_plugin = $this->get_plugin('row');
if ($row_plugin->usesOptions()) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->option_link(t('settings'), 'row_options'))) . '</div>',
);
......@@ -2137,8 +2142,8 @@ function options_form(&$form, &$form_state) {
'#default_value' => $exposed_form['type'],
);
$exposed_form_plugin = views_fetch_plugin_data('exposed_form', $exposed_form['type']);
if (!empty($exposed_form_plugin['uses_options'])) {
$exposed_form_plugin = $this->get_plugin('exposed_form');
if ($exposed_form_plugin->usesOptions()) {
$form['markup'] = array(
'#prefix' => '<div class="form-item description">',
'#suffix' => '</div>',
......@@ -2173,8 +2178,8 @@ function options_form(&$form, &$form_state) {
'#default_value' => $pager['type'],
);
$pager_plugin = views_fetch_plugin_data('pager', $pager['type'], array($this->view->base_table));
if (!empty($pager_plugin['uses_options'])) {
$pager_plugin = $this->get_plugin('pager');
if ($pager_plugin->usesOptions()) {
$form['markup'] = array(
'#prefix' => '<div class="form-item description">',
'#suffix' => '</div>',
......@@ -2333,7 +2338,7 @@ function options_submit(&$form, &$form_state) {
if ($plugin) {
$access = array('type' => $form_state['values']['access']['type']);
$this->set_option('access', $access);
if (!empty($plugin->definition['uses_options'])) {
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('access_options'));
}
}
......@@ -2354,7 +2359,7 @@ function options_submit(&$form, &$form_state) {
if ($plugin) {
$cache = array('type' => $form_state['values']['cache']['type']);
$this->set_option('cache', $cache);
if (!empty($plugin->definition['uses_options'])) {
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('cache_options'));
}
}
......@@ -2412,7 +2417,7 @@ function options_submit(&$form, &$form_state) {
$this->set_option('row_options', array());
// send ajax form to options page if we use it.
if (!empty($plugin->definition['uses_options'])) {
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('row_options'));
}
}
......@@ -2427,7 +2432,7 @@ function options_submit(&$form, &$form_state) {
$this->set_option($section, $form_state['values'][$section]);
$this->set_option('style_options', array());
// send ajax form to options page if we use it.
if (!empty($plugin->definition['uses_options'])) {
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('style_options'));
}
}
......@@ -2453,7 +2458,7 @@ function options_submit(&$form, &$form_state) {
if ($plugin) {
$exposed_form = array('type' => $form_state['values']['exposed_form']['type'], 'options' => array());
$this->set_option('exposed_form', $exposed_form);
if (!empty($plugin->definition['uses_options'])) {
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('exposed_form_options'));
}
}
......@@ -2480,7 +2485,7 @@ function options_submit(&$form, &$form_state) {
$pager = array('type' => $form_state['values']['pager']['type'], 'options' => $plugin->options);
$this->set_option('pager', $pager);
if (!empty($plugin->definition['uses_options'])) {
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('pager_options'));
}
}
......
......@@ -19,7 +19,6 @@
* id = "basic",
* title = @Translation("Basic"),
* help = @Translation("Basic exposed form"),
* uses_options = TRUE,
* help_topic = "exposed-form-basic"
* )
*/
......
......@@ -24,6 +24,11 @@
*/
abstract class ExposedFormPluginBase extends PluginBase {
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
/**
* Initialize the plugin.
*
......
......@@ -19,7 +19,6 @@
* id = "input_required",
* title = @Translation("Input required"),
* help = @Translation("An exposed form that only renders a view if the form contains user input."),
* uses_options = TRUE,
* help_topic = "exposed-form-input-required"
* )
*/
......
......@@ -20,8 +20,7 @@
* title = @Translation("Paged output, full pager"),
* short_title = @Translation("Full"),
* help = @Translation("Paged output, full Drupal style"),
* help_topic = "pager-full",
* uses_options = TRUE
* help_topic = "pager-full"
* )
*/
class Full extends PagerPluginBase {
......
......@@ -20,8 +20,7 @@
* title = @Translation("Paged output, mini pager"),
* short_title = @Translation("Mini"),
* help = @Translation("Use the mini pager output."),
* help_topic = "pager-mini",
* uses_options = TRUE
* help_topic = "pager-mini"
* )
*/
class Mini extends PagerPluginBase {
......
......@@ -20,7 +20,6 @@
* title = @Translation("Display all items"),
* help = @Translation("Display all items that this view might find."),
* help_topic = "pager-none",
* uses_options = TRUE,
* type = "basic"
* )
*/
......
......@@ -26,6 +26,11 @@ abstract class PagerPluginBase extends PluginBase {
var $total_items = 0;
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
/**
* Initialize the plugin.
*
......
......@@ -20,7 +20,6 @@
* title = @Translation("Display a specified number of items"),
* help = @Translation("Display a limited number items that this view might find."),
* help_topic = "pager-some",
* uses_options = TRUE,
* type = "basic"
* )
*/
......
......@@ -24,7 +24,6 @@
* help = @Translation("Displays the fields with an optional template."),
* theme = "views_view_fields",
* uses_fields = TRUE,
* uses_options = TRUE,
* type = "normal",
* help_topic = "style-row-fields"
* )
......
......@@ -26,6 +26,11 @@
*/
abstract class RowPluginBase extends PluginBase {
/**
* Overrides Drupal\views\Plugin\Plugin::$usesOptions.
*/
public $usesOptions = TRUE;
/**
* Initialize the row plugin.
*/
......
......@@ -19,7 +19,6 @@
* help = @Translation("Display fields as RSS items."),
* theme = "views_view_row_rss",
* uses_fields = TRUE,
* uses_options = TRUE,
* type = "feed",
* help_topic = "style-row-fields"
* )
......
......@@ -24,7 +24,6 @@
* uses_row_plugin = TRUE,
* uses_row_class = TRUE,
* uses_grouping = TRUE,
* uses_options = TRUE,
* type = "normal",
* help_topic = "style-unformatted"
* )
......
......@@ -22,7 +22,6 @@
* help = @Translation("Displays the default summary as a list."),
* theme = "views_view_summary",
* type = "summary",
* uses_options = TRUE,
* help_topic = "style-summary"
* )
*/
......
......@@ -23,7 +23,6 @@
* uses_fields = FALSE,
* uses_row_plugin = TRUE,
* uses_row_class = TRUE,
* uses_options = TRUE,
* type = "normal",
* help_topic = "style-grid"
* )
......
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