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) { ...@@ -86,32 +86,14 @@ function _views_data_process_entity_types(&$data) {
/** /**
* Fetch the plugin data from cache. * Fetch the plugin data from cache.
*/ */
function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) { function _views_fetch_plugin_data($type = NULL, $plugin_id = NULL, $reset = FALSE) {
static $cache = NULL; $manager = views_get_plugin_manager($type);
if (!isset($cache) || $reset) { if (!$plugin_id) {
$start = microtime(TRUE); return $manager->getDefinitions();
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];
}
} }
elseif (isset($cache[$type][$plugin])) { else {
return $cache[$type][$plugin]; return $manager->getDefinition($plugin_id);
} }
// Return an empty array if there is no match.
return array();
} }
/** /**
......
...@@ -20,11 +20,12 @@ ...@@ -20,11 +20,12 @@
*/ */
function _views_create_plugin($type, $plugin_id, $definition) { function _views_create_plugin($type, $plugin_id, $definition) {
$manager = views_get_plugin_manager($type); $manager = views_get_plugin_manager($type);
$instance = $manager->createInstance($plugin_id); $instance = $manager->createInstance($plugin_id);
$instance->is_plugin = TRUE; $instance->is_plugin = TRUE;
$instance->plugin_type = $type; $instance->plugin_type = $type;
$instance->plugin_name = $definition['name']; $instance->plugin_name = $plugin_id;
$instance->set_definition($definition); $instance->set_definition($definition);
......
This diff is collapsed.
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class AccessPluginManager extends PluginManagerBase { class AccessPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'access'); $this->discovery = new AnnotatedClassDiscovery('views', 'access');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\views\Plugins\Discovery\ViewsDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class ArgumentValidatorPluginManager extends PluginManagerBase { class ArgumentValidatorPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'argument validator'); $this->discovery = new AnnotatedClassDiscovery('views', 'argument_validator');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; 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 { class CachePluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'cache'); $this->discovery = new AnnotatedClassDiscovery('views', 'cache');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; 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() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'display_extender'); $this->discovery = new AnnotatedClassDiscovery('views', 'display_extender');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class DisplayPluginManager extends PluginManagerBase { class DisplayPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'display'); $this->discovery = new AnnotatedClassDiscovery('views', 'display');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class ExposedFormPluginManager extends PluginManagerBase { class ExposedFormPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'exposed_form'); $this->discovery = new AnnotatedClassDiscovery('views', 'exposed_form');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class LocalizationPluginManager extends PluginManagerBase { class LocalizationPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'localization'); $this->discovery = new AnnotatedClassDiscovery('views', 'localization');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class PagerPluginManager extends PluginManagerBase { class PagerPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'pager'); $this->discovery = new AnnotatedClassDiscovery('views', 'pager');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class QueryPluginManager extends PluginManagerBase { class QueryPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'query'); $this->discovery = new AnnotatedClassDiscovery('views', 'query');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class RowPluginManager extends PluginManagerBase { class RowPluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'row'); $this->discovery = new AnnotatedClassDiscovery('views', 'row');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\ViewsDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class StylePluginManager extends PluginManagerBase { class StylePluginManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new ViewsDiscovery('views_plugins', 'style'); $this->discovery = new AnnotatedClassDiscovery('views', 'style');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
} }
} }
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\WizardDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class WizardManager extends PluginManagerBase { class WizardManager extends PluginManagerBase {
public function __construct() { public function __construct() {
$this->discovery = new WizardDiscovery('views_wizard'); $this->discovery = new AnnotatedClassDiscovery('views', 'wizard');
$this->factory = new DefaultFactory($this->discovery); $this->factory = new DefaultFactory($this->discovery);
} }
} }
......
...@@ -434,8 +434,8 @@ function summary_title() { ...@@ -434,8 +434,8 @@ function summary_title() {
* This appears on the ui beside each plugin and beside the settings link. * This appears on the ui beside each plugin and beside the settings link.
*/ */
function plugin_title() { function plugin_title() {
if (isset($this->definition['short title'])) { if (isset($this->definition['short_title'])) {
return check_plain($this->definition['short title']); return check_plain($this->definition['short_title']);
} }
return check_plain($this->definition['title']); return check_plain($this->definition['title']);
} }
......
...@@ -7,11 +7,23 @@ ...@@ -7,11 +7,23 @@
namespace Drupal\views\Plugins\views\access; namespace Drupal\views\Plugins\views\access;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Annotation\Plugin;
/** /**
* Access plugin that provides no access control at all. * Access plugin that provides no access control at all.
* *
* @ingroup views_access_plugins * @ingroup views_access_plugins
*/ */
/**
* @Plugin(
* plugin_id = "none",
* title = @Translation("None"),
* help = @Translation("Will be available to all users."),
* help_topic = "access-none"
* )
*/
class None extends AccessPluginBase { class None extends AccessPluginBase {
function summary_title() { function summary_title() {
return t('Unrestricted'); return t('Unrestricted');
......
...@@ -7,11 +7,24 @@ ...@@ -7,11 +7,24 @@
namespace Drupal\views\Plugins\views\access; namespace Drupal\views\Plugins\views\access;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* Access plugin that provides permission-based access control. * Access plugin that provides permission-based access control.
* *
* @ingroup views_access_plugins * @ingroup views_access_plugins
*/ */
/**
* @Plugin(
* plugin_id = "permission",
* title = @Translation("Permission"),
* help = @Translation("Access will be granted to users with the specified permission string."),
* help_topic = "access-perm",
* uses_options = TRUE
* )
*/
class Permission extends AccessPluginBase { class Permission extends AccessPluginBase {
function access($account) { function access($account) {
return views_check_perm($this->options['perm'], $account); return views_check_perm($this->options['perm'], $account);
......
...@@ -7,11 +7,24 @@ ...@@ -7,11 +7,24 @@
namespace Drupal\views\Plugins\views\access; namespace Drupal\views\Plugins\views\access;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* Access plugin that provides role-based access control. * Access plugin that provides role-based access control.
* *
* @ingroup views_access_plugins * @ingroup views_access_plugins
*/ */
/**
* @Plugin(
* plugin_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
* )
*/
class Role extends AccessPluginBase { class Role extends AccessPluginBase {
function access($account) { function access($account) {
return views_check_roles(array_filter($this->options['role']), $account); return views_check_roles(array_filter($this->options['role']), $account);
......
...@@ -367,7 +367,7 @@ function options_form(&$form, &$form_state) { ...@@ -367,7 +367,7 @@ function options_form(&$form, &$form_state) {
$validate_types = array('none' => t('- Basic validation -')); $validate_types = array('none' => t('- Basic validation -'));
$plugins = views_fetch_plugin_data('argument validator'); $plugins = views_fetch_plugin_data('argument validator');
foreach ($plugins as $id => $info) { foreach ($plugins as $id => $info) {
if (!empty($info['no ui'])) { if (!empty($info['no_ui'])) {
continue; continue;
} }
...@@ -588,7 +588,7 @@ function default_argument_form(&$form, &$form_state) { ...@@ -588,7 +588,7 @@ function default_argument_form(&$form, &$form_state) {
); );
foreach ($plugins as $id => $info) { foreach ($plugins as $id => $info) {
if (!empty($info['no ui'])) { if (!empty($info['no_ui'])) {
continue; continue;
} }
$plugin = $this->get_plugin('argument default', $id); $plugin = $this->get_plugin('argument default', $id);
......
...@@ -7,11 +7,21 @@ ...@@ -7,11 +7,21 @@
namespace Drupal\views\Plugins\views\argument_default; namespace Drupal\views\Plugins\views\argument_default;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* The fixed argument default handler. * The fixed argument default handler.
* *
* @ingroup views_argument_default_plugins * @ingroup views_argument_default_plugins
*/ */
/**
* @Plugin(
* plugin_id = "fixed",
* title = @Translation("Fixed"),
* )
*/
class Fixed extends ArgumentDefaultPluginBase { class Fixed extends ArgumentDefaultPluginBase {
function option_definition() { function option_definition() {
$options = parent::option_definition(); $options = parent::option_definition();
......
...@@ -7,11 +7,21 @@ ...@@ -7,11 +7,21 @@
namespace Drupal\views\Plugins\views\argument_default; namespace Drupal\views\Plugins\views\argument_default;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* Default argument plugin to provide a PHP code block. * Default argument plugin to provide a PHP code block.
* *
* @ingroup views_argument_default_plugins * @ingroup views_argument_default_plugins
*/ */
/**
* @Plugin(
* plugin_id = "php",
* title = @Translation("PHP Code")
* )
*/
class Php extends ArgumentDefaultPluginBase { class Php extends ArgumentDefaultPluginBase {
function option_definition() { function option_definition() {
$options = parent::option_definition(); $options = parent::option_definition();
......
...@@ -7,11 +7,21 @@ ...@@ -7,11 +7,21 @@
namespace Drupal\views\Plugins\views\argument_default; namespace Drupal\views\Plugins\views\argument_default;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* Default argument plugin to use the raw value from the URL. * Default argument plugin to use the raw value from the URL.
* *
* @ingroup views_argument_default_plugins * @ingroup views_argument_default_plugins
*/ */
/**
* @Plugin(
* plugin_id = "raw",
* title = @Translation("Raw value from URL")
* )
*/
class Raw extends ArgumentDefaultPluginBase { class Raw extends ArgumentDefaultPluginBase {
function option_definition() { function option_definition() {
$options = parent::option_definition(); $options = parent::option_definition();
......
...@@ -7,11 +7,21 @@ ...@@ -7,11 +7,21 @@
namespace Drupal\views\Plugins\views\argument_validator; namespace Drupal\views\Plugins\views\argument_validator;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* Validate whether an argument is numeric or not. * Validate whether an argument is numeric or not.
* *
* @ingroup views_argument_validate_plugins * @ingroup views_argument_validate_plugins
*/ */
/**
* @Plugin(
* plugin_id = "numeric",
* title = @Translation("Numeric"),
* )
*/
class Numeric extends ArgumentValidatorPluginBase { class Numeric extends ArgumentValidatorPluginBase {
function validate_argument($argument) { function validate_argument($argument) {
return is_numeric($argument); return is_numeric($argument);
......
...@@ -7,11 +7,21 @@ ...@@ -7,11 +7,21 @@
namespace Drupal\views\Plugins\views\argument_validator; namespace Drupal\views\Plugins\views\argument_validator;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/** /**
* Provide PHP code to validate whether or not an argument is ok. * Provide PHP code to validate whether or not an argument is ok.
* *
* @ingroup views_argument_validate_plugins * @ingroup views_argument_validate_plugins
*/ */
/**
* @Plugin(
* plugin_id = "php",
* title = @Translation("PHP Code"),
* )
*/
class Php extends ArgumentValidatorPluginBase { class Php extends ArgumentValidatorPluginBase {
function option_definition() { function option_definition() {
$options = parent::option_definition(); $options = parent::option_definition();
......
...@@ -7,11 +7,23 @@ ...@@ -7,11 +7,23 @@
namespace Drupal\views\Plugins\views\cache; namespace Drupal\views\Plugins\views\cache;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;