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);
......
This diff is collapsed.
......@@ -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);
}
}
......@@ -9,11 +9,11 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugins\Discovery\WizardDiscovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
class WizardManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new WizardDiscovery('views_wizard');
$this->discovery = new AnnotatedClassDiscovery('views', 'wizard');
$this->factory = new DefaultFactory($this->discovery);
}
}
......
......@@ -434,8 +434,8 @@ 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']);
}
......
......@@ -7,11 +7,23 @@
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.
*
* @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 {
function summary_title() {
return t('Unrestricted');
......
......@@ -7,11 +7,24 @@
namespace Drupal\views\Plugins\views\access;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Access plugin that provides permission-based access control.
*
* @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 {
function access($account) {
return views_check_perm($this->options['perm'], $account);
......
......@@ -7,11 +7,24 @@
namespace Drupal\views\Plugins\views\access;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Access plugin that provides role-based access control.
*
* @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 {
function access($account) {
return views_check_roles(array_filter($this->options['role']), $account);
......
......@@ -367,7 +367,7 @@ function options_form(&$form, &$form_state) {
$validate_types = array('none' => t('- Basic validation -'));
$plugins = views_fetch_plugin_data('argument validator');
foreach ($plugins as $id => $info) {
if (!empty($info['no ui'])) {
if (!empty($info['no_ui'])) {
continue;
}
......@@ -588,7 +588,7 @@ function default_argument_form(&$form, &$form_state) {
);
foreach ($plugins as $id => $info) {
if (!empty($info['no ui'])) {
if (!empty($info['no_ui'])) {
continue;
}
$plugin = $this->get_plugin('argument default', $id);
......
......@@ -7,11 +7,21 @@
namespace Drupal\views\Plugins\views\argument_default;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* The fixed argument default handler.
*
* @ingroup views_argument_default_plugins
*/
/**
* @Plugin(
* plugin_id = "fixed",
* title = @Translation("Fixed"),
* )
*/
class Fixed extends ArgumentDefaultPluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,11 +7,21 @@
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.
*
* @ingroup views_argument_default_plugins
*/
/**
* @Plugin(
* plugin_id = "php",
* title = @Translation("PHP Code")
* )
*/
class Php extends ArgumentDefaultPluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,11 +7,21 @@
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.
*
* @ingroup views_argument_default_plugins
*/
/**
* @Plugin(
* plugin_id = "raw",
* title = @Translation("Raw value from URL")
* )
*/
class Raw extends ArgumentDefaultPluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,11 +7,21 @@
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.
*
* @ingroup views_argument_validate_plugins
*/
/**
* @Plugin(
* plugin_id = "numeric",
* title = @Translation("Numeric"),
* )
*/
class Numeric extends ArgumentValidatorPluginBase {
function validate_argument($argument) {
return is_numeric($argument);
......
......@@ -7,11 +7,21 @@
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.
*
* @ingroup views_argument_validate_plugins
*/
/**
* @Plugin(
* plugin_id = "php",
* title = @Translation("PHP Code"),
* )
*/
class Php extends ArgumentValidatorPluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,11 +7,23 @@
namespace Drupal\views\Plugins\views\cache;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Caching plugin that provides no caching at all.
*
* @ingroup views_cache_plugins
*/
/**
* @Plugin(
* plugin_id = "none",
* title = @Translation("None"),
* help = @Translation("No caching of Views data."),
* help_topic = "cache-none"
* )
*/
class None extends CachePluginBase {
function cache_start() { /* do nothing */ }
......
......@@ -7,11 +7,24 @@
namespace Drupal\views\Plugins\views\cache;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Simple caching of query results for Views displays.
*
* @ingroup views_cache_plugins
*/
/**
* @Plugin(
* plugin_id = "time",
* title = @Translation("Time-based"),
* help = @Translation("Simple time-based caching of data."),
* help_topic = "cache-time",
* uses_options = TRUE
* )
*/
class Time extends CachePluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,6 +7,9 @@
namespace Drupal\views\Plugins\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* The plugin that handles an attachment display.
*
......@@ -16,6 +19,21 @@
*
* @ingroup views_display_plugins
*/
/**
* @Plugin(
* plugin_id = "attachment",
* title = @Translation("Attachment"),
* help = @Translation("Attachments added to other displays to achieve multiple views in the same view."),
* theme = "views_view",
* contextual_links_locations = {""},
* use_ajax = TRUE,
* use_pager = FALSE,
* use_more = TRUE,
* accept_attachments = FALSE,
* help_topic = "display-attachment"
* )
*/
class Attachment extends DisplayPluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,11 +7,31 @@
namespace Drupal\views\Plugins\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* The plugin that handles a block.
*
* @ingroup views_display_plugins
*/
/**
* @Plugin(
* plugin_id = "block",
* title = @Translation("Block"),
* help = @Translation("Display the view as a block."),
* theme = "views_view",
* uses_hook_block = TRUE,
* contextual_links_locations = {"block"},
* use_ajax = TRUE,
* use_pager = TRUE,
* use_more = TRUE,
* accept_attachments = TRUE,
* admin = @Translation("Block"),
* help_topic = "display-block"
* )
*/
class Block extends DisplayPluginBase {
function option_definition() {
$options = parent::option_definition();
......
......@@ -7,11 +7,30 @@
namespace Drupal\views\Plugins\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* A plugin to handle defaults on a view.
*
* @ingroup views_display_plugins
*/
/**
* @Plugin(
* plugin_id = "standard",
* title = @Translation("Master"),
* help = @Translation("Default settings for this view."),
* theme = "views_view",
* no_ui = TRUE,
* no_remove = TRUE,
* use_ajax = TRUE,
* use_pager = TRUE,
* use_more = TRUE,
* accept_attachments = TRUE,
* help_topic = "display-default"
* )
*/
class DefaultDisplay extends DisplayPluginBase {
/**
* Determine if this display is the 'default' display which contains
......
......@@ -7,10 +7,30 @@
namespace Drupal\views\Plugins\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* The plugin that handles an embed display.
*
* @ingroup views_display_plugins
*
* @todo: Wait until annotations/plugins support access mehtods.
* no ui => !config('views.settings')->get('views_ui_display_embed'),
*/
/**
* @Plugin(
* plugin_id = "embed",
* title = @Translation("Embed"),
* help = @Translation("Provide a display which can be embedded using the views api."),
* theme = "views_view",
* uses_hook_menu = FALSE,
* use_ajax = TRUE,
* use_pager = TRUE,
* accept_attachments = FALSE,
* help_topic = "display-embed"
* )
*/
class Embed extends DisplayPluginBase {
// This display plugin does nothing apart from exist.
......
......@@ -8,6 +8,8 @@
namespace Drupal\views\Plugins\views\display;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* The plugin that handles a feed, such as RSS or atom.
......@@ -16,6 +18,20 @@
*
* @ingroup views_display_plugins
*/
/**
* @Plugin(
* plugin_id = "feed",
* title = @Translation("Feed"),
* help = @Translation("Display the view as a feed, such as an RSS feed."),
* uses_hook_menu = TRUE,
* use_ajax = FALSE,
* use_pager = FALSE,
* accept_attachments = FALSE,
* admin = @Translation("Feed"),
* help_topic = "display-feed"
* )
*/
class Feed extends Page {
function init(&$view, &$display, $options = NULL) {
parent::init($view, $display, $options);
......
......@@ -7,11 +7,31 @@
namespace Drupal\views\Plugins\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* The plugin that handles a full page.
*
* @ingroup views_display_plugins
*/
/**
* @Plugin(
* plugin_id = "page",
* title = @Translation("Page"),
* help = @Translation("Display the view as a page, with a URL and menu links."),
* uses_hook_menu = TRUE,
* contextual_links_locations = {"page"},
* theme = "views_view",
* use_ajax = TRUE,
* use_pager = TRUE,
* use_more = TRUE,
* accept_attachments = TRUE,
* admin = @Translation("Page"),
* help_topic = "display-page"
* )
*/
class Page extends DisplayPluginBase {
/**
* The page display has a path.
......