Commit 0489b631 authored by alexpott's avatar alexpott

Issue #2065721 by tim.plunkett: Add a dedicated @Block plugin annotation.

parent 703e9e47
......@@ -8,16 +8,15 @@
namespace Drupal\aggregator\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides an 'Aggregator category' block for the latest items in a category.
*
* @Plugin(
* @Block(
* id = "aggregator_category_block",
* admin_label = @Translation("Aggregator category"),
* module = "aggregator",
* derivative = "Drupal\aggregator\Plugin\Derivative\AggregatorCategoryBlock"
* )
*/
......
......@@ -8,16 +8,15 @@
namespace Drupal\aggregator\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides an 'Aggregator feed' block with the latest items from the feed.
*
* @Plugin(
* @Block(
* id = "aggregator_feed_block",
* admin_label = @Translation("Aggregator feed"),
* module = "aggregator",
* derivative = "Drupal\aggregator\Plugin\Derivative\AggregatorFeedBlock"
* )
*/
......
......@@ -8,7 +8,7 @@
namespace Drupal\custom_block\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
......@@ -18,10 +18,9 @@
/**
* Defines a generic custom block type.
*
* @Plugin(
* @Block(
* id = "custom_block",
* admin_label = @Translation("Custom block"),
* module = "custom_block",
* derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock"
* )
*/
......
<?php
/**
* @file
* Contains \Drupal\block\Annotation\Block.
*/
namespace Drupal\block\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Block annotation object.
*
* @Annotation
*/
class Block extends Plugin {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* The administrative label of the block.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $admin_label;
}
......@@ -35,7 +35,8 @@ class BlockManager extends DefaultPluginManager {
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/Block', $namespaces);
$annotation_namespaces = array('Drupal\block\Annotation' => $namespaces['Drupal\block']);
parent::__construct('Plugin/Block', $namespaces, $annotation_namespaces, 'Drupal\block\Annotation\Block');
$this->alterInfo($module_handler, 'block');
$this->setCacheBackend($cache_backend, $language_manager, 'block_plugins');
}
......@@ -48,6 +49,7 @@ public function processDefinition(&$definition, $plugin_id) {
// Ensure that every block has a category.
$definition += array(
'module' => $definition['provider'],
'category' => $definition['provider'],
);
}
......
......@@ -8,16 +8,15 @@
namespace Drupal\block_test\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a basic block for testing block instantiation and configuration.
*
* @Plugin(
* @Block(
* id = "test_block_instantiation",
* admin_label = @Translation("Display message"),
* module = "block_test"
* admin_label = @Translation("Display message")
* )
*/
class TestBlockInstantiation extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\block_test\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a block to test caching.
*
* @Plugin(
* @Block(
* id = "test_cache",
* admin_label = @Translation("Test block caching"),
* module = "block_test"
* admin_label = @Translation("Test block caching")
* )
*/
class TestCacheBlock extends BlockBase {
......
......@@ -7,17 +7,15 @@
namespace Drupal\block_test\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a block to test HTML IDs.
*
* @Plugin(
* @Block(
* id = "test_html_id",
* admin_label = @Translation("Test block html id"),
* module = "block_test"
* admin_label = @Translation("Test block html id")
* )
*/
class TestHtmlIdBlock extends TestCacheBlock {
......
......@@ -7,15 +7,14 @@
namespace Drupal\block_test\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
/**
* Provides a block to test XSS in title.
*
* @Plugin(
* @Block(
* id = "test_xss_title",
* admin_label = "<script>alert('XSS subject');</script>",
* module = "block_test"
* admin_label = "<script>alert('XSS subject');</script>"
* )
*/
class TestXSSTitleBlock extends TestCacheBlock {
......
......@@ -8,16 +8,15 @@
namespace Drupal\book\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Book navigation' block.
*
* @Plugin(
* @Block(
* id = "book_navigation",
* admin_label = @Translation("Book navigation"),
* module = "book"
* admin_label = @Translation("Book navigation")
* )
*/
class BookNavigationBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\comment\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Recent comments' block.
*
* @Plugin(
* @Block(
* id = "recent_comments",
* admin_label = @Translation("Recent comments"),
* module = "comment"
* admin_label = @Translation("Recent comments")
* )
*/
class RecentCommentsBlock extends BlockBase {
......
......@@ -7,16 +7,15 @@
namespace Drupal\forum\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides an 'Active forum topics' block.
*
* @Plugin(
* @Block(
* id = "forum_active_block",
* admin_label = @Translation("Active forum topics"),
* module = "forum"
* admin_label = @Translation("Active forum topics")
* )
*/
class ActiveTopicsBlock extends ForumBlockBase {
......
......@@ -7,16 +7,15 @@
namespace Drupal\forum\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'New forum topics' block.
*
* @Plugin(
* @Block(
* id = "forum_new_block",
* admin_label = @Translation("New forum topics"),
* module = "forum"
* admin_label = @Translation("New forum topics")
* )
*/
class NewTopicsBlock extends ForumBlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\language\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Language switcher' block.
*
* @Plugin(
* @Block(
* id = "language_block",
* admin_label = @Translation("Language switcher"),
* module = "language",
* derivative = "Drupal\language\Plugin\Derivative\LanguageBlock"
* )
*/
......
......@@ -8,16 +8,15 @@
namespace Drupal\menu\Plugin\Block;
use Drupal\system\Plugin\Block\SystemMenuBlock;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a generic Menu block.
*
* @Plugin(
* @Block(
* id = "menu_menu_block",
* admin_label = @Translation("Menu"),
* module = "menu",
* derivative = "Drupal\menu\Plugin\Derivative\MenuBlock"
* )
*/
......
......@@ -8,16 +8,15 @@
namespace Drupal\node\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Recent content' block.
*
* @Plugin(
* @Block(
* id = "node_recent_block",
* admin_label = @Translation("Recent content"),
* module = "node"
* admin_label = @Translation("Recent content")
* )
*/
class RecentContentBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\node\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Syndicate' block that links to the site's RSS feed.
*
* @Plugin(
* @Block(
* id = "node_syndicate_block",
* admin_label = @Translation("Syndicate"),
* module = "node"
* admin_label = @Translation("Syndicate")
* )
*/
class SyndicateBlock extends BlockBase {
......
......@@ -8,7 +8,7 @@
namespace Drupal\search\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\search\Form\SearchBlockForm;
......@@ -18,10 +18,9 @@
/**
* Provides a 'Search form' block.
*
* @Plugin(
* @Block(
* id = "search_form_block",
* admin_label = @Translation("Search form"),
* module = "search"
* admin_label = @Translation("Search form")
* )
*/
class SearchBlock extends BlockBase implements ContainerFactoryPluginInterface {
......
......@@ -8,16 +8,15 @@
namespace Drupal\shortcut\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Shortcut' block.
*
* @Plugin(
* @Block(
* id = "shortcuts",
* admin_label = @Translation("Shortcuts"),
* module = "shortcut"
* admin_label = @Translation("Shortcuts")
* )
*/
class ShortcutsBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\statistics\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Popular content' block.
*
* @Plugin(
* @Block(
* id = "statistics_popular_block",
* admin_label = @Translation("Popular content"),
* module = "statistics"
* admin_label = @Translation("Popular content")
* )
*/
class StatisticsPopularBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\system\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a block to display the breadcrumbs.
*
* @Plugin(
* @Block(
* id = "system_breadcrumb_block",
* admin_label = @Translation("Breadcrumbs"),
* module = "system"
* admin_label = @Translation("Breadcrumbs")
* )
*/
class SystemBreadcrumbBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\system\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'System Help' block.
*
* @Plugin(
* @Block(
* id = "system_help_block",
* admin_label = @Translation("System Help"),
* module = "system"
* admin_label = @Translation("System Help")
* )
*/
class SystemHelpBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\system\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Main page content' block.
*
* @Plugin(
* @Block(
* id = "system_main_block",
* admin_label = @Translation("Main page content"),
* module = "system"
* admin_label = @Translation("Main page content")
* )
*/
class SystemMainBlock extends BlockBase {
......
......@@ -8,16 +8,15 @@
namespace Drupal\system\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'System Menu' block.
*
* @Plugin(
* @Block(
* id = "system_menu_block",
* admin_label = @Translation("System Menu"),
* module = "system",
* category = "menu",
* derivative = "Drupal\system\Plugin\Derivative\SystemMenuBlock"
* )
......
......@@ -8,16 +8,15 @@
namespace Drupal\system\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Powered by Drupal' block.
*
* @Plugin(
* @Block(
* id = "system_powered_by_block",
* admin_label = @Translation("Powered by Drupal"),
* module = "system"
* admin_label = @Translation("Powered by Drupal")
* )
*/
class SystemPoweredByBlock extends BlockBase {
......
......@@ -8,21 +8,19 @@
namespace Drupal\user\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\user\Form\UserLoginForm;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides a 'User login' block.
*
* @Plugin(
* @Block(
* id = "user_login_block",
* admin_label = @Translation("User login"),
* module = "user"
* admin_label = @Translation("User login")
* )
*/
class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterface {
......
......@@ -8,16 +8,15 @@
namespace Drupal\user\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a "Who's new" block.
*
* @Plugin(
* @Block(
* id = "user_new_block",
* admin_label = @Translation("Who's new"),
* module = "user"
* admin_label = @Translation("Who's new")
* )
*/
class UserNewBlock extends BlockBase {
......
......@@ -8,7 +8,7 @@
namespace Drupal\user\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
......@@ -17,10 +17,9 @@
* @todo Move this block to the Statistics module and remove its dependency on
* {users}.access.
*
* @Plugin(
* @Block(
* id = "user_online_block",
* admin_label = @Translation("Who's online"),
* module = "user"
* admin_label = @Translation("Who's online")
* )
*/
class UserOnlineBlock extends BlockBase {
......
......@@ -7,7 +7,7 @@
namespace Drupal\views\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Component\Utility\Xss;
......@@ -16,10 +16,9 @@
/**
* Provides a generic Views block.
*
* @Plugin(
* @Block(
* id = "views_block",
* admin_label = @Translation("Views Block"),
* module = "views",
* derivative = "Drupal\views\Plugin\Derivative\ViewsBlock"
* )
*/
......
......@@ -7,16 +7,15 @@
namespace Drupal\views\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Views Exposed Filter' block.
*
* @Plugin(
* @Block(
* id = "views_exposed_filter_block",
* admin_label = @Translation("Views Exposed Filter Block"),
* module = "views",
* derivative = "Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock"
* )
*/
......
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