Commit 9ac1406a authored by dawehner's avatar dawehner Committed by tim.plunkett

annotationasation: Convert basically every core plugin.

parent 6c84c8d2
......@@ -86,32 +86,14 @@ function _views_data_process_entity_types(&$data) {
/**
* Fetch the plugin data from cache.
*/
function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) {
static $cache = NULL;
if (!isset($cache) || $reset) {
$start = microtime(TRUE);
views_include('plugins');
views_include_handlers();
$cache = views_discover_plugins();
}
if (!$type && !$plugin) {
return $cache;
}
elseif (!$plugin) {
// Not in the if above so the else below won't run
if (isset($cache[$type])) {
return $cache[$type];
}
function _views_fetch_plugin_data($type = NULL, $plugin_id = NULL, $reset = FALSE) {
$manager = views_get_plugin_manager($type);
if (!$plugin_id) {
return $manager->getDefinitions();
}
elseif (isset($cache[$type][$plugin])) {
return $cache[$type][$plugin];
else {
return $manager->getDefinition($plugin_id);
}
// Return an empty array if there is no match.
return array();
}
/**
......
......@@ -20,11 +20,12 @@
*/
function _views_create_plugin($type, $plugin_id, $definition) {
$manager = views_get_plugin_manager($type);
$instance = $manager->createInstance($plugin_id);
$instance->is_plugin = TRUE;
$instance->plugin_type = $type;
$instance->plugin_name = $definition['name'];
$instance->plugin_name = $plugin_id;
$instance->set_definition($definition);
......
......@@ -7,402 +7,6 @@
use Drupal\views\ViewsObject;
/**
* Implements hook_views_plugins().
*/
function views_views_plugins() {
$js_path = drupal_get_path('module', 'ctools') . '/js';
$plugins = array(
// display, style, row, argument default, argument validator and access.
'display' => array(
// Default settings for all display plugins.
'default' => array(
'title' => t('Master'),
'help' => t('Default settings for this view.'),
'class' => 'Drupal\views\Plugins\views\display\DefaultDisplay',
'theme' => 'views_view',
'no ui' => TRUE,
'no remove' => TRUE,
// @todo: replace this with proper libraries.
// @TODO: figure out whether this is still needed, or at least remove depedent.js.
'js' => array('core/misc/form.js', 'core/misc/collapse.js', 'core/misc/textarea.js', 'core/misc/tabledrag.js', 'core/misc/autocomplete.js', "$js_path/dependent.js"),
'use ajax' => TRUE,
'use pager' => TRUE,
'use more' => TRUE,
'accept attachments' => TRUE,
'help topic' => 'display-default',
),
'page' => array(
'title' => t('Page'),
'help' => t('Display the view as a page, with a URL and menu links.'),
'class' => 'Drupal\views\Plugins\views\display\Page',
'theme' => 'views_view',
'uses hook menu' => TRUE,
'contextual links locations' => array('page'),
'use ajax' => TRUE,
'use pager' => TRUE,
'use more' => TRUE,
'accept attachments' => TRUE,
'admin' => t('Page'),
'help topic' => 'display-page',
),
'block' => array(
'title' => t('Block'),
'help' => t('Display the view as a block.'),
'class' => 'Drupal\views\Plugins\views\display\Block',
'theme' => 'views_view',
'uses hook block' => TRUE,
'contextual links locations' => array('block'),
'use ajax' => TRUE,
'use pager' => TRUE,
'use more' => TRUE,
'accept attachments' => TRUE,
'admin' => t('Block'),
'help topic' => 'display-block',
),
'attachment' => array(
'title' => t('Attachment'),
'help' => t('Attachments added to other displays to achieve multiple views in the same view.'),
'class' => 'Drupal\views\Plugins\views\display\Attachment',
'theme' => 'views_view',
'contextual links locations' => array(),
'use ajax' => TRUE,
'use pager' => FALSE,
'use more' => TRUE,
'accept attachments' => FALSE,
'help topic' => 'display-attachment',
),
'feed' => array(
'title' => t('Feed'),
'help' => t('Display the view as a feed, such as an RSS feed.'),
'class' => 'Drupal\views\Plugins\views\display\Feed',
'uses hook menu' => TRUE,
'use ajax' => FALSE,
'use pager' => FALSE,
'accept attachments' => FALSE,
'admin' => t('Feed'),
'help topic' => 'display-feed',
),
'embed' => array(
'title' => t('Embed'),
'help' => t('Provide a display which can be embedded using the views api.'),
'class' => 'Drupal\views\Plugins\views\display\Embed',
'theme' => 'views_view',
'uses hook menu' => FALSE,
'use ajax' => TRUE,
'use pager' => TRUE,
'accept attachments' => FALSE,
'admin' => t('Embed'),
'no ui' => !config('views.settings')->get('views_ui_display_embed'),
),
),
'display_extender' => array(
// Default settings for all display_extender plugins.
'default' => array(
'title' => t('Empty display extender'),
'help' => t('Default settings for this view.'),
'class' => 'Drupal\views\Plugins\views\display_extender\DisplayExtenderPluginBase',
// You can force the plugin to be enabled
'enabled' => FALSE,
'no ui' => TRUE,
),
),
'style' => array(
// Default settings for all style plugins.
'default' => array(
'title' => t('Unformatted list'),
'help' => t('Displays rows one after another.'),
'class' => 'Drupal\views\Plugins\views\style\DefaultStyle',
'theme' => 'views_view_unformatted',
'uses row plugin' => TRUE,
'uses row class' => TRUE,
'uses grouping' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-unformatted',
),
'list' => array(
'title' => t('HTML list'),
'help' => t('Displays rows as an HTML list.'),
'class' => 'Drupal\views\Plugins\views\style\List',
'theme' => 'views_view_list',
'uses row plugin' => TRUE,
'uses row class' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-list',
),
'grid' => array(
'title' => t('Grid'),
'help' => t('Displays rows in a grid.'),
'class' => 'Drupal\views\Plugins\views\style\Grid',
'theme' => 'views_view_grid',
'uses fields' => FALSE,
'uses row plugin' => TRUE,
'uses row class' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-grid',
),
'table' => array(
'title' => t('Table'),
'help' => t('Displays rows in a table.'),
'class' => 'Drupal\views\Plugins\views\style\Table',
'theme' => 'views_view_table',
'uses row plugin' => FALSE,
'uses row class' => TRUE,
'uses fields' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-table',
),
'default_summary' => array(
'title' => t('List'),
'help' => t('Displays the default summary as a list.'),
'class' => 'Drupal\views\Plugins\views\style\StyleSummaryPluginBase',
'theme' => 'views_view_summary',
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
'help topic' => 'style-summary',
),
'unformatted_summary' => array(
'title' => t('Unformatted'),
'help' => t('Displays the summary unformatted, with option for one after another or inline.'),
'class' => 'Drupal\views\Plugins\views\style\UnformattedSummary',
'theme' => 'views_view_summary_unformatted',
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
'help topic' => 'style-summary-unformatted',
),
'rss' => array(
'title' => t('RSS Feed'),
'help' => t('Generates an RSS feed from a view.'),
'class' => 'Drupal\views\Plugins\views\style\Rss',
'theme' => 'views_view_rss',
'uses row plugin' => TRUE,
'uses options' => TRUE,
'type' => 'feed',
'help topic' => 'style-rss',
),
),
'row' => array(
'fields' => array(
'title' => t('Fields'),
'help' => t('Displays the fields with an optional template.'),
'class' => 'Drupal\views\Plugins\views\row\Fields',
'theme' => 'views_view_fields',
'uses fields' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-row-fields',
),
'rss_fields' => array(
'title' => t('Fields'),
'help' => t('Display fields as RSS items.'),
'class' => 'Drupal\views\Plugins\views\row\RssFields',
'theme' => 'views_view_row_rss',
'uses fields' => TRUE,
'uses options' => TRUE,
'type' => 'feed',
'help topic' => 'style-row-fields',
),
),
'argument default' => array(
'parent' => array(
'no ui' => TRUE,
'class' => 'Drupal\views\Plugins\views\argument_default\ArgumentDefaultPluginBase',
'parent' => '',
),
'fixed' => array(
'title' => t('Fixed value'),
'class' => 'Drupal\views\Plugins\views\argument_default\Fixed',
),
'php' => array(
'title' => t('PHP Code'),
'class' => 'Drupal\views\Plugins\views\argument_default\Fixed',
),
'raw' => array(
'title' => t('Raw value from URL'),
'class' => 'Drupal\views\Plugins\views\argument_default\Raw',
),
),
'argument validator' => array(
'php' => array(
'title' => t('PHP Code'),
'class' => 'Drupal\views\Plugins\views\argument_validator\Php',
),
'numeric' => array(
'title' => t('Numeric'),
'class' => 'Drupal\views\Plugins\views\argument_validator\Numeric',
),
),
'access' => array(
'none' => array(
'title' => t('None'),
'help' => t('Will be available to all users.'),
'class' => 'Drupal\views\Plugins\views\access\None',
'help topic' => 'access-none',
),
'role' => array(
'title' => t('Role'),
'help' => t('Access will be granted to users with any of the specified roles.'),
'class' => 'Drupal\views\Plugins\views\access\Role',
'uses options' => TRUE,
'help topic' => 'access-role',
),
'perm' => array(
'title' => t('Permission'),
'help' => t('Access will be granted to users with the specified permission string.'),
'class' => 'Drupal\views\Plugins\views\access\Permission',
'uses options' => TRUE,
'help topic' => 'access-perm',
),
),
'query' => array(
'parent' => array(
'no ui' => TRUE,
'class' => 'Drupal\views\Plugins\views\query\QueryPlugin',
'parent' => '',
),
'views_query' => array(
'title' => t('SQL Query'),
'help' => t('Query will be generated and run using the Drupal database API.'),
'class' => 'views_plugin_query_default',
'class' => 'Drupal\views\Plugins\views\query\Sql',
),
),
'cache' => array(
'parent' => array(
'no ui' => TRUE,
'class' => 'Drupal\views\Plugins\views\cache\CachePluginBase',
'parent' => '',
),
'none' => array(
'title' => t('None'),
'help' => t('No caching of Views data.'),
'class' => 'Drupal\views\Plugins\views\cache\None',
'help topic' => 'cache-none',
),
'time' => array(
'title' => t('Time-based'),
'help' => t('Simple time-based caching of data.'),
'class' => 'Drupal\views\Plugins\views\cache\Time',
'uses options' => TRUE,
'help topic' => 'cache-time',
),
),
'exposed_form' => array(
'parent' => array(
'no ui' => TRUE,
'class' => 'Drupal\views\Plugins\views\exposed_form\ExposedFormPluginBase',
'parent' => '',
),
'basic' => array(
'title' => t('Basic'),
'help' => t('Basic exposed form'),
'class' => 'Drupal\views\Plugins\views\exposed_form\Basic',
'uses options' => TRUE,
'help topic' => 'exposed-form-basic',
),
'input_required' => array(
'title' => t('Input required'),
'help' => t('An exposed form that only renders a view if the form contains user input.'),
'class' => 'Drupal\views\Plugins\views\exposed_form\InputRequired',
'uses options' => TRUE,
'help topic' => 'exposed-form-input-required',
),
),
'pager' => array(
'parent' => array(
'no ui' => TRUE,
'class' => 'Drupal\views\Plugins\views\pager\PagerPluginBase',
'parent' => '',
),
'none' => array(
'title' => t('Display all items'),
'help' => t("Display all items that this view might find"),
'class' => 'Drupal\views\Plugins\views\pager\None',
'help topic' => 'pager-none',
'uses options' => TRUE,
'type' => 'basic',
),
'some' => array(
'title' => t('Display a specified number of items'),
'help' => t('Display a limited number items that this view might find.'),
'class' => 'Drupal\views\Plugins\views\pager\Some',
'help topic' => 'pager-some',
'uses options' => TRUE,
'type' => 'basic',
),
'full' => array(
'title' => t('Paged output, full pager'),
'short title' => t('Full'),
'help' => t('Paged output, full Drupal style'),
'class' => 'Drupal\views\Plugins\views\pager\Full',
'help topic' => 'pager-full',
'uses options' => TRUE,
),
'mini' => array(
'title' => t('Paged output, mini pager'),
'short title' => t('Mini'),
'help' => t('Use the mini pager output.'),
'class' => 'Drupal\views\Plugins\views\pager\Mini',
'help topic' => 'pager-mini',
'uses options' => TRUE,
'parent' => 'full',
),
),
'localization' => array(
'parent' => array(
'no ui' => TRUE,
'class' => 'Drupal\views\Plugins\views\localization\LocalizationPluginBase',
'parent' => '',
),
'none' => array(
'title' => t('None'),
'help' => t('Do not pass admin strings for translation.'),
'class' => 'Drupal\views\Plugins\views\localization\None',
'help topic' => 'localization-none',
),
'core' => array(
'title' => t('Core'),
'help' => t("Use Drupal core t() function. Not recommended, as it doesn't support updates to existing strings."),
'class' => 'Drupal\views\Plugins\views\localization\Core',
'help topic' => 'localization-core',
),
),
);
// Add a help message pointing to the i18views module if it is not present.
if (!module_exists('i18nviews')) {
$plugins['localization']['core']['help'] .= ' ' . t('If you need to translate Views labels into other languages, consider installing the <a href="!path">Internationalization</a> package\'s Views translation module.', array('!path' => url('http://drupal.org/project/i18n', array('absolute' => TRUE))));
}
if (module_invoke('ctools', 'api_version', '1.3')) {
$plugins['style']['jump_menu_summary'] = array(
'title' => t('Jump menu'),
'help' => t('Puts all of the results into a select box and allows the user to go to a different page based upon the results.'),
'class' => 'Drupal\views\Plugins\views\style\JumpMenuSummary',
'theme' => 'views_view_summary_jump_menu',
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
'help topic' => 'style-summary-jump-menu',
);
$plugins['style']['jump_menu'] = array(
'title' => t('Jump menu'),
'help' => t('Puts all of the results into a select box and allows the user to go to a different page based upon the results.'),
'class' => 'Drupal\views\Plugins\views\style\JumpMenu',
'theme' => 'views_view_jump_menu',
'uses row plugin' => TRUE,
'uses fields' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-jump-menu',
);
}
return $plugins;
}
/**
* Builds and return a list of all plugins available in the system.
*
......@@ -565,22 +169,9 @@ function summary_title() {
* This appears on the ui beside each plugin and beside the settings link.
*/
function plugin_title() {
if (isset($this->definition['short title'])) {
return check_plain($this->definition['short title']);
if (isset($this->definition['short_title'])) {
return check_plain($this->definition['short_title']);
}
return check_plain($this->definition['title']);
}
}
/**
* Get enabled display extenders.
*/
function views_get_enabled_display_extenders() {
$enabled = array_filter((array) config('views.settings')->get('views_display_extenders'));
$options = views_fetch_plugin_names('display_extender');
foreach ($options as $name => $plugin) {
$enabled[$name] = $name;
}
return $enabled;
}
......@@ -10,10 +10,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class AccessPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'access');
$this->discovery = new AnnotatedClassDiscovery('views', 'access');
$this->factory = new DefaultFactory($this);
}
}
......@@ -10,10 +10,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class ArgumentValidatorPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'argument validator');
$this->discovery = new AnnotatedClassDiscovery('views', 'argument_validator');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\views\Discovery\ViewsDiscovery;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class CachePluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'cache');
$this->discovery = new AnnotatedClassDiscovery('views', 'cache');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\views\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class DisplayPluginManager extends PluginManagerBase {
class DisplayExtenderPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'display_extender');
$this->discovery = new AnnotatedClassDiscovery('views', 'display_extender');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class DisplayPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'display');
$this->discovery = new AnnotatedClassDiscovery('views', 'display');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class ExposedFormPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'exposed_form');
$this->discovery = new AnnotatedClassDiscovery('views', 'exposed_form');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class LocalizationPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'localization');
$this->discovery = new AnnotatedClassDiscovery('views', 'localization');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class PagerPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'pager');
$this->discovery = new AnnotatedClassDiscovery('views', 'pager');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class QueryPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'query');
$this->discovery = new AnnotatedClassDiscovery('views', 'query');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class RowPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'row');
$this->discovery = new AnnotatedClassDiscovery('views', 'row');
$this->factory = new DefaultFactory($this);
}
}
......@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class StylePluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'style');
$this->discovery = new AnnotatedClassDiscovery('views', 'style');
$this->factory = new DefaultFactory($this);
}
}