diff --git a/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php b/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php index 356967b..168d5d7 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php +++ b/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php @@ -41,7 +41,7 @@ public function __construct(DiscoveryInterface $discovery) { * Implements Drupal\Component\Plugin\Factory\FactoryInterface::createInstance(). */ public function createInstance($plugin_id, array $configuration) { - $plugin_class = $this->getPluginClass($plugin_id); + $plugin_class = static::getPluginClass($plugin_id, $this->discovery); return new $plugin_class($configuration, $plugin_id, $this->discovery); } @@ -50,12 +50,14 @@ public function createInstance($plugin_id, array $configuration) { * * @param array $plugin_id * The id of a plugin. + * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $discovery + * The discovery object. * * @return string * The appropriate class name. */ - protected function getPluginClass($plugin_id) { - $plugin_definition = $this->discovery->getDefinition($plugin_id); + public static function getPluginClass($plugin_id, DiscoveryInterface $discovery) { + $plugin_definition = $discovery->getDefinition($plugin_id); if (empty($plugin_definition['class'])) { throw new PluginException(sprintf('The plugin (%s) did not specify an instance class.', $plugin_id)); } diff --git a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php index a81b868..50b3868 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php +++ b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php @@ -20,7 +20,7 @@ class ReflectionFactory extends DefaultFactory { * Implements Drupal\Component\Plugin\Factory\FactoryInterface::createInstance(). */ public function createInstance($plugin_id, array $configuration) { - $plugin_class = $this->getPluginClass($plugin_id); + $plugin_class = static::getPluginClass($plugin_id, $this->discovery); // Lets figure out of there's a constructor for this class and pull // arguments from the $options array if so to populate it. diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorCategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorCategoryBlock.php index d281731..4c2df27 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorCategoryBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorCategoryBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides an 'Aggregator category' block for the latest items in a category. @@ -65,7 +64,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $id = $this->getPluginId(); if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchObject()) { $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $this->configuration['block_count'], array(':cid' => $category->cid)); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorFeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorFeedBlock.php index 528c7db..e902eb5 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/AggregatorFeedBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides an 'Aggregator feed' block with the latest items from the feed. @@ -65,7 +64,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { // Plugin IDs look something like this: aggregator_feed_block:1. list(, $id) = explode(':', $this->getPluginId()); if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php index e09a3ab..6f7be2e 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php @@ -9,7 +9,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Defines a generic custom block type. @@ -108,7 +107,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { // Populate the block with the user-defined block body. return array( '#theme' => 'custom_block_block', diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index b2fb291..1b1fd9e 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -9,6 +9,7 @@ use Drupal\Component\Plugin\PluginBase; use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\Component\Plugin\Discovery\DiscoveryInterface; /** * Defines a base block implementation that most blocks plugins will extend. @@ -20,6 +21,22 @@ abstract class BlockBase extends PluginBase implements BlockInterface { /** + * The entity using this plugin. + * + * @var \Drupal\block\Plugin\Core\Entity\Block + */ + protected $entity; + + /** + * Overrides \Drupal\Component\Plugin\PluginBase::__construct(). + */ + public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery, Block $entity) { + parent::__construct($configuration, $plugin_id, $discovery); + + $this->entity = $entity; + } + + /** * Returns plugin-specific settings for the block. * * Block plugins only need to override this method if they override the @@ -115,7 +132,7 @@ public function blockAccess() { * @see hook_block_access() * @see \Drupal\block\BlockBase::blockAccess() */ - public function access(Block $entity) { + public function access() { // If the block-specific access restrictions indicate the block is not // accessible, always deny access. if (!$this->blockAccess()) { @@ -126,7 +143,7 @@ public function access(Block $entity) { global $user; // Deny access to disabled blocks. - if (!$entity->get('status')) { + if (!$this->entity->get('status')) { return FALSE; } @@ -134,7 +151,7 @@ public function access(Block $entity) { // If a block has no roles associated, it is displayed for every role. // For blocks with roles associated, if none of the user's roles matches // the settings from this block, access is denied. - $visibility = $entity->get('visibility'); + $visibility = $this->entity->get('visibility'); if (!empty($visibility['role']['roles']) && !array_intersect(array_filter($visibility['role']['roles']), array_keys($user->roles))) { // No match. return FALSE; @@ -186,7 +203,7 @@ public function access(Block $entity) { // Check other modules for block access rules. foreach (module_implements('block_access') as $module) { - if (module_invoke($module, 'block_access', $entity) === FALSE) { + if (module_invoke($module, 'block_access', $this->entity) === FALSE) { return FALSE; } } @@ -205,7 +222,8 @@ public function access(Block $entity) { * * @see \Drupal\block\BlockBase::blockForm() */ - public function form($form, &$form_state, Block $entity) { + public function form($form, &$form_state) { + $entity = $form_state['entity']; $definition = $this->getDefinition(); $form['id'] = array( '#type' => 'value', @@ -412,7 +430,7 @@ public function validate($form, &$form_state) { } $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']); if ($form_state['entity']->isNew()) { - form_set_value($form['id'], $form_state['values']['theme'] . '.' . $form_state['values']['machine_name'], $form_state); + form_set_value($form['id'], $form_state['entity']->get('theme') . '.' . $form_state['values']['machine_name'], $form_state); } $this->blockValidate($form, $form_state); } diff --git a/core/modules/block/lib/Drupal/block/BlockInterface.php b/core/modules/block/lib/Drupal/block/BlockInterface.php index 4707b9b..ec3c145 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -7,8 +7,6 @@ namespace Drupal\block; -use Drupal\block\Plugin\Core\Entity\Block; - /** * Defines the required interface for all block plugins. * @@ -39,15 +37,12 @@ public function blockSettings(); * This method allows base implementations to add general access restrictions * that should apply to all extending block plugins. * - * @param \Drupal\block\Plugin\Core\Entity\Block $entity - * The block entity. - * * @return bool * TRUE if the block should be shown, or FALSE otherwise. * * @see \Drupal\block\BlockAccessController */ - public function access(Block $entity); + public function access(); /** * Constructs the block configuration form. @@ -59,8 +54,6 @@ public function access(Block $entity); * The form definition array for the block configuration form. * @param array $form_state * An array containing the current state of the configuration form. - * @param \Drupal\block\Plugin\Core\Entity\Block $entity - * The block entity. * * @return array $form * The renderable form array representing the entire configuration form. @@ -69,7 +62,7 @@ public function access(Block $entity); * @see \Drupal\block\BlockInterace::validate() * @see \Drupal\block\BlockInterace::submit() */ - public function form($form, &$form_state, Block $entity); + public function form($form, &$form_state); /** * Handles form validation for the block configuration form. @@ -102,14 +95,11 @@ public function submit($form, &$form_state); /** * Builds and returns the renderable array for this block plugin. * - * @param \Drupal\block\Plugin\Core\Entity\Block $entity - * The block entity containing this plugin. - * * @return array * A renderable array representing the content of the block. * * @see \Drupal\block\BlockRenderController */ - public function blockBuild(Block $entity); + public function blockBuild(); } diff --git a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php index 9dffe3c..1c78697 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -129,7 +129,7 @@ public function getPlugin() { // Create a plugin instance and store its configuration as settings. try { - $this->instance = drupal_container()->get('plugin.manager.block')->createInstance($this->plugin, $this->settings); + $this->instance = drupal_container()->get('plugin.manager.block')->createInstance($this->plugin, $this->settings, $this); $this->settings += $this->instance->getConfig(); } catch (PluginException $e) { diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index 181d32c..c977756 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -12,6 +12,7 @@ use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\CacheDecorator; use Drupal\Component\Plugin\Factory\DefaultFactory; +use Drupal\block\Plugin\Core\Entity\Block; /** * Manages discovery and instantiation of block plugins. @@ -30,7 +31,14 @@ public function __construct() { $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'block'); $this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache_block'); - $this->factory = new DefaultFactory($this); + } + + /** + * Overrides \Drupal\Component\Plugin\PluginManagerBase::createInstance(). + */ + public function createInstance($plugin_id, array $configuration = array(), Block $entity = NULl) { + $plugin_class = DefaultFactory::getPluginClass($plugin_id, $this->discovery); + return new $plugin_class($configuration, $plugin_id, $this->discovery, $entity); } } diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php index 5f7b980..aeb7709 100644 --- a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php +++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a block to test caching. @@ -37,7 +36,7 @@ public function blockSettings() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( '#children' => state()->get('block_test.content'), ); diff --git a/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php b/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php index 1f43782..c1823e1 100644 --- a/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php +++ b/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Book navigation' block. @@ -62,7 +61,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $current_bid = 0; if ($node = menu_get_object()) { $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid']; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentCommentsBlock.php b/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentCommentsBlock.php index 77114fe..d5c3d7b 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentCommentsBlock.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentCommentsBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Recent comments' block. @@ -62,7 +61,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( '#theme' => 'comment_block', '#number' => $this->configuration['block_count'], diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterFactory.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterFactory.php index bb7d066..a0bf0c2 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterFactory.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterFactory.php @@ -18,7 +18,7 @@ class FormatterFactory extends DefaultFactory { * Overrides Drupal\Component\Plugin\Factory\DefaultFactory::createInstance(). */ public function createInstance($plugin_id, array $configuration) { - $plugin_class = $this->getPluginClass($plugin_id); + $plugin_class = static::getPluginClass($plugin_id, $this->discovery); return new $plugin_class($plugin_id, $this->discovery, $configuration['instance'], $configuration['settings'], $configuration['label'], $configuration['view_mode']); } } diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetFactory.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetFactory.php index 851cbea..4b6e7dc 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetFactory.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetFactory.php @@ -18,7 +18,7 @@ class WidgetFactory extends DefaultFactory { * Overrides Drupal\Component\Plugin\Factory\DefaultFactory::createInstance(). */ public function createInstance($plugin_id, array $configuration) { - $plugin_class = $this->getPluginClass($plugin_id); + $plugin_class = static::getPluginClass($plugin_id, $this->discovery); return new $plugin_class($plugin_id, $this->discovery, $configuration['instance'], $configuration['settings'], $configuration['weight']); } } diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveTopicsBlock.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveTopicsBlock.php index 7ac7010..afa7117 100644 --- a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveTopicsBlock.php +++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveTopicsBlock.php @@ -9,7 +9,6 @@ use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides an 'Active forum topics' block. @@ -25,7 +24,7 @@ class ActiveTopicsBlock extends ForumBlockBase { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $query = db_select('forum_index', 'f') ->fields('f') ->addTag('node_access') diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewTopicsBlock.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewTopicsBlock.php index 2cfcb8b..083469c 100644 --- a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewTopicsBlock.php +++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewTopicsBlock.php @@ -9,7 +9,6 @@ use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'New forum topics' block. @@ -25,7 +24,7 @@ class NewTopicsBlock extends ForumBlockBase { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $query = db_select('forum_index', 'f') ->fields('f') ->addTag('node_access') diff --git a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php index 89d6562..a698695 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php +++ b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Language switcher' block. @@ -34,7 +33,7 @@ function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $build = array(); $path = drupal_is_front_page() ? '' : current_path(); list($plugin_id, $type) = explode(':', $this->getPluginId()); diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php index 2924bee..7134dc50 100644 --- a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php +++ b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php @@ -10,7 +10,6 @@ use Drupal\system\Plugin\block\block\SystemMenuBlock; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a generic Menu block. @@ -27,7 +26,7 @@ class MenuBlock extends SystemMenuBlock { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { list($plugin, $menu) = explode(':', $this->getPluginId()); return menu_tree($menu); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/block/block/RecentContentBlock.php b/core/modules/node/lib/Drupal/node/Plugin/block/block/RecentContentBlock.php index d9abc2d..cb05c5c 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/block/block/RecentContentBlock.php +++ b/core/modules/node/lib/Drupal/node/Plugin/block/block/RecentContentBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Recent content' block. @@ -62,7 +61,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { if ($nodes = node_get_recent($this->configuration['block_count'])) { return array( '#theme' => 'node_recent_block', diff --git a/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php b/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php index b83d9f4..5c83e27 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php +++ b/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Syndicate' block that links to the site's RSS feed. @@ -42,7 +41,7 @@ public function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( '#theme' => 'feed_icon', '#url' => 'rss.xml', diff --git a/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php index 5b96e3b..b597741 100644 --- a/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php +++ b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Most recent poll' block. @@ -68,7 +67,7 @@ public function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $poll = node_load($this->record); if ($poll->nid) { $poll = poll_block_latest_poll_view($poll); diff --git a/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php b/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php index 4cdc83f..d9bdb7c 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php +++ b/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Search form' block. @@ -33,7 +32,7 @@ public function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array(drupal_get_form('search_block_form')); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/block/block/ShortcutsBlock.php b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/block/block/ShortcutsBlock.php index 818650b..d236a19 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/block/block/ShortcutsBlock.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/block/block/ShortcutsBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Shortcut' block. @@ -26,7 +25,7 @@ class ShortcutsBlock extends BlockBase { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( shortcut_renderable_links(shortcut_current_displayed_set()), ); diff --git a/core/modules/statistics/lib/Drupal/statistics/Plugin/block/block/StatisticsPopularBlock.php b/core/modules/statistics/lib/Drupal/statistics/Plugin/block/block/StatisticsPopularBlock.php index 3fc4099..8c9fdf6 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Plugin/block/block/StatisticsPopularBlock.php +++ b/core/modules/statistics/lib/Drupal/statistics/Plugin/block/block/StatisticsPopularBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Popular content' block. @@ -119,7 +118,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $content = array(); if ($this->day_list) { diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php index 9b8d75c..6026f83 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'System Help' block. @@ -41,7 +40,7 @@ public function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( '#children' => $this->help, ); diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php index 0c8a708..8b40092 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Main page content' block. @@ -26,7 +25,7 @@ class SystemMainBlock extends BlockBase { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( drupal_set_page_content() ); diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php index 6087fa7..0307257 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'System Menu' block. @@ -36,7 +35,7 @@ public function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { list($plugin, $derivative) = explode(':', $this->getPluginId()); // Derivatives are prefixed with 'menu-'. $menu = substr($derivative, 5); diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php index 7fe9d29..b363725 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Powered by Drupal' block. @@ -26,7 +25,7 @@ class SystemPoweredByBlock extends BlockBase { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { return array( '#children' => theme('system_powered_by'), ); diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php index 996e15d..51bc8ee 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'User login' block. @@ -33,7 +32,7 @@ public function blockAccess() { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $form = drupal_get_form('user_login_form'); unset($form['name']['#attributes']['autofocus']); unset($form['name']['#description']); diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php index 2ea4b89..7f97df6 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a "Who's new" block. @@ -65,7 +64,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { // Retrieve a list of new users who have accessed the site successfully. $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])->fetchAll(); $build = array( diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php index aee6ce1..75f23f0 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php @@ -10,7 +10,6 @@ use Drupal\block\BlockBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a "Who's online" block. @@ -79,7 +78,7 @@ public function blockSubmit($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { // Count users active within the defined period. $interval = REQUEST_TIME - $this->configuration['seconds_online']; diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php index 7939f5c..b50c4b5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php @@ -11,7 +11,6 @@ use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a generic Views block. @@ -72,10 +71,10 @@ public function blockForm($form, &$form_state) { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $block) { + public function blockBuild() { $output = $this->view->executeDisplay($this->displayID); // Set the label to the title configured in the view. - $block->set('label', filter_xss_admin($this->view->getTitle())); + $this->entity->set('label', filter_xss_admin($this->view->getTitle())); // Before returning the block output, convert it to a renderable array // with contextual links. views_add_block_contextual_links($output, $this->view, $this->displayID); diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php index 40baebb..2d51c25 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php @@ -9,7 +9,6 @@ use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; -use Drupal\block\Plugin\Core\Entity\Block; /** * Provides a 'Views Exposed Filter' block. @@ -26,7 +25,7 @@ class ViewsExposedFilterBlock extends ViewsBlock { /** * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function blockBuild(Block $entity) { + public function blockBuild() { $type = 'exp'; $output = $this->view->display_handler->viewSpecialBlocks($type); // Before returning the block output, convert it to a renderable array with