Commit d4d91db0 authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1763678 by dawehner, tim.plunkett: CamelCase methods of PluginBase.

parent f45fd073
......@@ -2514,7 +2514,7 @@ function views_ui_standard_submit($form, &$form_state) {
$display = &$form_state['view']->display[$form_state['display_id']];
// optionsOverride toggles the override of this section.
$display->handler->optionsOverride($form, $form_state);
$display->handler->options_submit($form, $form_state);
$display->handler->submitOptionsForm($form, $form_state);
}
elseif (!$was_defaulted && $is_defaulted) {
// We used to have an override for this display, but the user now wants
......@@ -2524,7 +2524,7 @@ function views_ui_standard_submit($form, &$form_state) {
$display = &$form_state['view']->display[$form_state['display_id']];
// optionsOverride toggles the override of this section.
$display->handler->optionsOverride($form, $form_state);
$display->handler->options_submit($form, $form_state);
$display->handler->submitOptionsForm($form, $form_state);
}
$submit_handler = $form['#form_id'] . '_submit';
......@@ -3210,7 +3210,7 @@ function views_ui_edit_display_form($form, &$form_state) {
'#theme_wrappers' => array('container'),
'#attributes' => array('class' => array('scroll')),
);
$display->handler->options_form($form['options'], $form_state);
$display->handler->buildOptionsForm($form['options'], $form_state);
// The handler options form sets $form['#title'], which we need on the entire
// $form instead of just the ['options'] section.
......@@ -3237,7 +3237,7 @@ function views_ui_edit_display_form($form, &$form_state) {
*/
function views_ui_edit_display_form_validate($form, &$form_state) {
$display = &$form_state['view']->display[$form_state['display_id']];
$display->handler->options_validate($form['options'], $form_state);
$display->handler->validateOptionsForm($form['options'], $form_state);
if (form_get_errors()) {
$form_state['rerender'] = TRUE;
......@@ -3249,7 +3249,7 @@ function views_ui_edit_display_form_validate($form, &$form_state) {
*/
function views_ui_edit_display_form_submit($form, &$form_state) {
$display = &$form_state['view']->display[$form_state['display_id']];
$display->handler->options_submit($form, $form_state);
$display->handler->submitOptionsForm($form, $form_state);
views_ui_cache_set($form_state['view']);
}
......@@ -4306,7 +4306,7 @@ function views_ui_config_item_form($form, &$form_state) {
$form['#section'] = $display_id . '-' . $type . '-' . $id;
// Get form from the handler.
$handler->options_form($form['options'], $form_state);
$handler->buildOptionsForm($form['options'], $form_state);
$form_state['handler'] = &$handler;
}
......@@ -4328,7 +4328,7 @@ function views_ui_config_item_form($form, &$form_state) {
* Submit handler for configing new item(s) to a view.
*/
function views_ui_config_item_form_validate($form, &$form_state) {
$form_state['handler']->options_validate($form['options'], $form_state);
$form_state['handler']->validateOptionsForm($form['options'], $form_state);
if (form_get_errors()) {
$form_state['rerender'] = TRUE;
......@@ -4341,7 +4341,7 @@ function views_ui_config_item_form_validate($form, &$form_state) {
*/
function views_ui_config_item_form_submit_temporary($form, &$form_state) {
// Run it through the handler's submit function.
$form_state['handler']->options_submit($form['options'], $form_state);
$form_state['handler']->submitOptionsForm($form['options'], $form_state);
$item = $form_state['handler']->options;
$types = View::viewsObjectTypes();
......@@ -4374,7 +4374,7 @@ function views_ui_config_item_form_submit_temporary($form, &$form_state) {
// This unpacks only options that are in the definition, ensuring random
// extra stuff on the form is not sent through.
$handler->unpack_options($handler->options, $options, NULL, FALSE);
$handler->unpackOptions($handler->options, $options, NULL, FALSE);
// Store the item back on the view
$form_state['view']->temporary_options[$type][$form_state['id']] = $handler->options;
......@@ -4395,7 +4395,7 @@ function views_ui_config_item_form_submit_temporary($form, &$form_state) {
*/
function views_ui_config_item_form_submit($form, &$form_state) {
// Run it through the handler's submit function.
$form_state['handler']->options_submit($form['options'], $form_state);
$form_state['handler']->submitOptionsForm($form['options'], $form_state);
$item = $form_state['handler']->options;
$types = View::viewsObjectTypes();
......@@ -4428,7 +4428,7 @@ function views_ui_config_item_form_submit($form, &$form_state) {
// This unpacks only options that are in the definition, ensuring random
// extra stuff on the form is not sent through.
$handler->unpack_options($handler->options, $options, NULL, FALSE);
$handler->unpackOptions($handler->options, $options, NULL, FALSE);
// Store the item back on the view
$form_state['view']->setItem($form_state['display_id'], $form_state['type'], $form_state['id'], $handler->options);
......@@ -4658,7 +4658,7 @@ function views_ui_config_style_form($form, &$form_state) {
);
$plugin->init($view, $view->display[$display_id], $handler->options['style_options']);
$plugin->options_form($form['style_options'], $form_state);
$plugin->buildOptionsForm($form['style_options'], $form_state);
}
$form_state['handler'] = &$handler;
......@@ -4674,7 +4674,7 @@ function views_ui_config_style_form($form, &$form_state) {
*/
function views_ui_config_style_form_submit($form, &$form_state) {
// Run it through the handler's submit function.
$form_state['handler']->options_submit($form['style_options'], $form_state);
$form_state['handler']->submitOptionsForm($form['style_options'], $form_state);
$item = $form_state['handler']->options;
// Store the data we're given.
......
......@@ -27,11 +27,11 @@ function __construct($handler) {
$this->handler = $handler;
}
static function option_definition(&$options) {
public static function defineOptions(&$options) {
$options['reduce_duplicates'] = array('default' => FALSE, 'bool' => TRUE);
}
function options_form(&$form, &$form_state) {
public function buildOptionsForm(&$form, &$form_state) {
$form['reduce_duplicates'] = array(
'#type' => 'checkbox',
'#title' => t('Reduce duplicates'),
......
......@@ -110,7 +110,7 @@ function init(&$view, &$options) {
$options['id']
);
$this->unpack_options($this->options, $options);
$this->unpackOptions($this->options, $options);
// This exist on most handlers, but not all. So they are still optional.
if (isset($options['table'])) {
......@@ -135,8 +135,8 @@ function init(&$view, &$options) {
$this->query = &$view->query;
}
function option_definition() {
$options = parent::option_definition();
protected function defineOptions() {
$options = parent::defineOptions();
$options['id'] = array('default' => '');
$options['table'] = array('default' => '');
......@@ -263,12 +263,12 @@ function case_transform($string, $option) {
/**
* Validate the options form.
*/
function options_validate(&$form, &$form_state) { }
public function validateOptionsForm(&$form, &$form_state) { }
/**
* Build the options form.
*/
function options_form(&$form, &$form_state) {
public function buildOptionsForm(&$form, &$form_state) {
// Some form elements belong in a fieldset for presentation, but can't
// be moved into one because of the form_state['values'] hierarchy. Those
// elements can add a #fieldset => 'fieldset_name' property, and they'll
......@@ -300,7 +300,7 @@ function options_form(&$form, &$form_state) {
* Perform any necessary changes to the form values prior to storage.
* There is no need for this function to actually store the data.
*/
function options_submit(&$form, &$form_state) { }
public function submitOptionsForm(&$form, &$form_state) { }
/**
* Provides the handler some groupby.
......@@ -602,14 +602,14 @@ function get_join() {
* Validates the handler against the complete View.
*
* This is called when the complete View is being validated. For validating
* the handler options form use options_validate().
* the handler options form use validateOptionsForm().
*
* @see views_handler::options_validate()
* @see views_handler::validateOptionsForm()
*
* @return
* Empty array if the handler is valid; an array of error strings if it is not.
*/
function validate() { return array(); }
public function validate() { return array(); }
/**
* Determine if the handler is considered 'broken', meaning it's a
......
......@@ -81,31 +81,31 @@ public function __construct(array $configuration, $plugin_id) {
* @return array
* Returns the options of this handler/plugin.
*
* @see Drupal\views\Plugin\views\PluginBase::export_option()
* @see Drupal\views\Plugin\views\PluginBase::unpack_translatable()
* @see Drupal\views\Plugin\views\PluginBase::exportOption()
* @see Drupal\views\Plugin\views\PluginBase::unpackTranslatable()
*/
function option_definition() { return array(); }
protected function defineOptions() { return array(); }
/**
* Views handlers use a special construct function so that we can more
* easily construct them with variable arguments.
*/
function construct() { $this->set_default_options(); }
public function construct() { $this->setDefaultOptions(); }
/**
* Set default options.
* For backward compatibility, it sends the options array; this is a
* feature that will likely disappear at some point.
*/
function set_default_options() {
$this->_set_option_defaults($this->options, $this->option_definition());
protected function setDefaultOptions() {
$this->setOptionDefaults($this->options, $this->defineOptions());
}
function _set_option_defaults(&$storage, $options, $level = 0) {
protected function setOptionDefaults(&$storage, $options, $level = 0) {
foreach ($options as $option => $definition) {
if (isset($definition['contains']) && is_array($definition['contains'])) {
$storage[$option] = array();
$this->_set_option_defaults($storage[$option], $definition['contains'], $level++);
$this->setOptionDefaults($storage[$option], $definition['contains'], $level++);
}
elseif (!empty($definition['translatable']) && !empty($definition['default'])) {
$storage[$option] = t($definition['default']);
......@@ -120,13 +120,13 @@ function _set_option_defaults(&$storage, $options, $level = 0) {
* Unpack options over our existing defaults, drilling down into arrays
* so that defaults don't get totally blown away.
*/
function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) {
public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) {
if ($check && !is_array($options)) {
return;
}
if (!isset($definition)) {
$definition = $this->option_definition();
$definition = $this->defineOptions();
}
if (!empty($this->view)) {
......@@ -165,7 +165,7 @@ function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $c
continue;
}
$this->unpack_options($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE, array_merge($localization_keys, array($key)));
$this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE, array_merge($localization_keys, array($key)));
}
// Don't localize strings during editing. When editing, we need to work with
// the original data, not the translated version.
......@@ -200,7 +200,7 @@ function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $c
/**
* Let the handler know what its full definition is.
*/
function setDefinition($definition) {
public function setDefinition($definition) {
$this->definition = $definition;
if (isset($definition['id'])) {
$this->plugin_id = $definition['id'];
......@@ -210,7 +210,7 @@ function setDefinition($definition) {
}
}
function destroy() {
public function destroy() {
if (isset($this->view)) {
unset($this->view);
}
......@@ -224,16 +224,16 @@ function destroy() {
}
}
function export_options($indent, $prefix) {
public function exportOptions($indent, $prefix) {
$output = '';
foreach ($this->option_definition() as $option => $definition) {
$output .= $this->export_option($indent, $prefix, $this->options, $option, $definition, array());
foreach ($this->defineOptions() as $option => $definition) {
$output .= $this->exportOption($indent, $prefix, $this->options, $option, $definition, array());
}
return $output;
}
function export_option($indent, $prefix, $storage, $option, $definition, $parents) {
protected function exportOption($indent, $prefix, $storage, $option, $definition, $parents) {
// Do not export options for which we have no settings.
if (!isset($storage[$option])) {
return;
......@@ -257,7 +257,7 @@ function export_option($indent, $prefix, $storage, $option, $definition, $parent
// If it has child items, export those separately.
if (isset($definition['contains'])) {
foreach ($definition['contains'] as $sub_option => $sub_definition) {
$output .= $this->export_option($indent, $prefix, $storage[$option], $sub_option, $sub_definition, $parents);
$output .= $this->exportOption($indent, $prefix, $storage[$option], $sub_option, $sub_definition, $parents);
}
}
// Otherwise export just this item.
......@@ -286,9 +286,9 @@ function export_option($indent, $prefix, $storage, $option, $definition, $parent
/**
* Unpacks each handler to store translatable texts.
*/
function unpack_translatables(&$translatable, $parents = array()) {
foreach ($this->option_definition() as $option => $definition) {
$this->unpack_translatable($translatable, $this->options, $option, $definition, $parents, array());
public function unpackTranslatables(&$translatable, $parents = array()) {
foreach ($this->defineOptions() as $option => $definition) {
$this->unpackTranslatable($translatable, $this->options, $option, $definition, $parents, array());
}
}
......@@ -305,7 +305,7 @@ function unpack_translatables(&$translatable, $parents = array()) {
* @param $parents
* @param $keys
*/
function unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) {
protected function unpackTranslatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) {
// Do not export options for which we have no settings.
if (!isset($storage[$option])) {
return;
......@@ -329,7 +329,7 @@ function unpack_translatable(&$translatable, $storage, $option, $definition, $pa
if (isset($definition['contains'])) {
foreach ($definition['contains'] as $sub_option => $sub_definition) {
$translation_keys = array_merge($keys, array($sub_option));
$this->unpack_translatable($translatable, $storage[$option], $sub_option, $sub_definition, $parents, $translation_keys);
$this->unpackTranslatable($translatable, $storage[$option], $sub_option, $sub_definition, $parents, $translation_keys);
}
}
......@@ -339,7 +339,7 @@ function unpack_translatable(&$translatable, $storage, $option, $definition, $pa
foreach ($options as $key => $value) {
$translation_keys = array_merge($keys, array($key));
if (is_array($value)) {
$this->unpack_translatable($translatable, $options, $key, $definition, $parents, $translation_keys);
$this->unpackTranslatable($translatable, $options, $key, $definition, $parents, $translation_keys);
}
else if (!empty($definition[$key]['translatable']) && !empty($value)) {
// Build source data and add to the array
......@@ -378,7 +378,7 @@ function unpack_translatable(&$translatable, $storage, $option, $definition, $pa
/**
* Provide a form to edit options for this plugin.
*/
function options_form(&$form, &$form_state) {
public function buildOptionsForm(&$form, &$form_state) {
// Some form elements belong in a fieldset for presentation, but can't
// be moved into one because of the form_state['values'] hierarchy. Those
// elements can add a #fieldset => 'fieldset_name' property, and they'll
......@@ -389,29 +389,29 @@ function options_form(&$form, &$form_state) {
/**
* Validate the options form.
*/
function options_validate(&$form, &$form_state) { }
public function validateOptionsForm(&$form, &$form_state) { }
/**
* Handle any special handling on the validate form.
*/
function options_submit(&$form, &$form_state) { }
public function submitOptionsForm(&$form, &$form_state) { }
/**
* Add anything to the query that we might need to.
*/
function query() { }
public function query() { }
/**
* Provide a full list of possible theme templates used by this style.
*/
function theme_functions() {
public function themeFunctions() {
return views_theme_functions($this->definition['theme'], $this->view, $this->display);
}
/**
* Provide a list of additional theme functions for the theme information page
*/
function additional_theme_functions() {
public function additionalThemeFunctions() {
$funcs = array();
if (!empty($this->definition['additional themes'])) {
foreach ($this->definition['additional themes'] as $theme => $type) {
......@@ -428,20 +428,21 @@ function additional_theme_functions() {
* An array of error strings to tell the user what is wrong with this
* plugin.
*/
function validate() { return array(); }
public function validate() { return array(); }
/**
* Returns the summary of the settings in the display.
*/
function summary_title() {
public function summaryTitle() {
return t('Settings');
}
/**
* Return the human readable name of the display.
*
* This appears on the ui beside each plugin and beside the settings link.
*/
function plugin_title() {
public function pluginTitle() {
if (isset($this->definition['short_title'])) {
return check_plain($this->definition['short_title']);
}
......
......@@ -37,7 +37,7 @@ function init(&$view, &$display) {
if (is_object($display->handler)) {
$options = $display->handler->getOption('access');
// Overlay incoming options on top of defaults
$this->unpack_options($this->options, $options);
$this->unpackOptions($this->options, $options);
}
}
......@@ -45,28 +45,28 @@ function init(&$view, &$display) {
* Retrieve the options when this is a new access
* control plugin
*/
function option_definition() { return array(); }
protected function defineOptions() { return array(); }
/**
* Provide the default form for setting options.
*/
function options_form(&$form, &$form_state) { }
public function buildOptionsForm(&$form, &$form_state) { }
/**
* Provide the default form form for validating options
*/
function options_validate(&$form, &$form_state) { }
public function validateOptionsForm(&$form, &$form_state) { }
/**
* Provide the default form form for submitting options
*/
function options_submit(&$form, &$form_state) { }
public function submitOptionsForm(&$form, &$form_state) { }
/**
* Return a string to display as the clickable title for the
* access control.
*/
function summary_title() {
public function summaryTitle() {
return t('Unknown');
}
......
......@@ -23,7 +23,7 @@
*/
class None extends AccessPluginBase {
function summary_title() {
public function summaryTitle() {
return t('Unrestricted');
}
......
......@@ -36,7 +36,7 @@ function get_access_callback() {
return array('views_check_perm', array($this->options['perm']));
}
function summary_title() {
public function summaryTitle() {
$permissions = module_invoke_all('permission');
if (isset($permissions[$this->options['perm']])) {
return $permissions[$this->options['perm']]['title'];
......@@ -46,15 +46,15 @@ function summary_title() {
}
function option_definition() {
$options = parent::option_definition();
protected function defineOptions() {
$options = parent::defineOptions();
$options['perm'] = array('default' => 'access content');
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$perms = array();
$module_info = system_get_info('module');
......
......@@ -36,7 +36,7 @@ function get_access_callback() {
return array('views_check_roles', array(array_filter($this->options['role'])));
}
function summary_title() {
public function summaryTitle() {
$count = count($this->options['role']);
if ($count < 1) {
return t('No role(s) selected');
......@@ -52,15 +52,15 @@ function summary_title() {
}
function option_definition() {
$options = parent::option_definition();
protected function defineOptions() {
$options = parent::defineOptions();
$options['role'] = array('default' => array());
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['role'] = array(
'#type' => 'checkboxes',
'#title' => t('Role'),
......@@ -70,13 +70,13 @@ function options_form(&$form, &$form_state) {
);
}
function options_validate(&$form, &$form_state) {
public function validateOptionsForm(&$form, &$form_state) {
if (!array_filter($form_state['values']['access_options']['role'])) {
form_error($form['role'], t('You must select at least one role if type is "by role"'));
}
}
function options_submit(&$form, &$form_state) {
public function submitOptionsForm(&$form, &$form_state) {
// I hate checkboxes.
$form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']);
}
......
......@@ -47,8 +47,8 @@ function label() {
return $this->options['label'];
}
function option_definition() {
$options = parent::option_definition();
protected function defineOptions() {
$options = parent::defineOptions();
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
......@@ -69,8 +69,8 @@ function admin_summary() {