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 10bc52e034b..acf85200194 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 @@ -62,9 +62,9 @@ class AggregatorCategoryBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 afcef0e815f..335c3700539 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 @@ -62,9 +62,9 @@ class AggregatorFeedBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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/CustomBlockBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php index 9219264f310..ab8c65e8651 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php @@ -73,9 +73,9 @@ class CustomBlockBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected function blockBuild() { // @todo Clean up when http://drupal.org/node/1874498 lands. list(, $uuid) = explode(':', $this->getPluginId()); if ($block = entity_load_by_uuid('custom_block', $uuid)) { diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 4de2a59add5..0909345e805 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -496,4 +496,21 @@ abstract class BlockBase extends PluginBase implements BlockInterface { */ public function blockSubmit($form, &$form_state) {} + /** + * Implements \Drupal\block\BlockInterface::build(). + */ + public function build() { + // @todo Move block rendering code common to all blocks from + // BlockRenderController to here: http://drupal.org/node/1927608. + return $this->blockBuild(); + } + + /** + * Adds block-type-specific render handling for the block plugin. + * + * @return array + * A renderable array representing the content of this block. + */ + abstract protected function blockBuild(); + } 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 dd7a4233c84..14dfd9d6907 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 @@ -34,9 +34,9 @@ class TestCacheBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 165c798fe78..e3b8162fee4 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 @@ -59,9 +59,9 @@ class BookNavigationBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 bd7b49b0fde..a55c8e17847 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 @@ -59,9 +59,9 @@ class RecentCommentsBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected function blockBuild() { return array( '#theme' => 'comment_block', '#number' => $this->configuration['block_count'], 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 e3ff7dd0852..c4fab8cb87b 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 @@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation; class ActiveTopicsBlock extends ForumBlockBase { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 71d4c3b0153..1ef73118d8e 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 @@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation; class NewTopicsBlock extends ForumBlockBase { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 53c58e7f47a..efe4b7980a4 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 @@ -31,9 +31,9 @@ class LanguageBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 c535fc60a73..2044087705e 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 @@ -24,9 +24,9 @@ use Drupal\Core\Annotation\Translation; class MenuBlock extends SystemMenuBlock { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 083a0960c90..10644617fe4 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 @@ -59,9 +59,9 @@ class RecentContentBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 af627a23f9a..49d0eb4df4c 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 @@ -39,9 +39,9 @@ class SyndicateBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected function blockBuild() { return array( '#theme' => 'feed_icon', '#url' => 'rss.xml', 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 bb06d352606..10760215554 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 @@ -30,9 +30,9 @@ class SearchBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 f6107170fb6..7a56d761df9 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 @@ -23,9 +23,9 @@ use Drupal\Core\Annotation\Translation; class ShortcutsBlock extends BlockBase { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 7417bd88914..9a740acd539 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 @@ -116,9 +116,9 @@ class StatisticsPopularBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 a5476c33e7b..140b0920c29 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 @@ -38,9 +38,9 @@ class SystemHelpBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 80510b09b9f..89e3a9cd938 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 @@ -23,9 +23,9 @@ use Drupal\Core\Annotation\Translation; class SystemMainBlock extends BlockBase { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 01aa4706301..8a2e11f5a09 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 @@ -33,9 +33,9 @@ class SystemMenuBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 958edc08a15..9e29c1e1812 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 @@ -23,9 +23,9 @@ use Drupal\Core\Annotation\Translation; class SystemPoweredByBlock extends BlockBase { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 716a315a69d..4d57119c5b6 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 @@ -30,9 +30,9 @@ class UserLoginBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 5f88f7fa7bc..b32714adcdc 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 @@ -62,9 +62,9 @@ class UserNewBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 d88568acbe1..65dbe222b04 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 @@ -76,9 +76,9 @@ class UserOnlineBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected 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 8a77f18ee3b..6b87904d290 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 @@ -71,9 +71,9 @@ class ViewsBlock extends BlockBase { } /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected function blockBuild() { $output = $this->view->executeDisplay($this->displayID); // Set the label to the title configured in the view. $this->entity->set('label', filter_xss_admin($this->view->getTitle())); 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 cb9d37c525a..97037bbd6cf 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 @@ -23,9 +23,9 @@ use Drupal\Core\Annotation\Translation; class ViewsExposedFilterBlock extends ViewsBlock { /** - * Implements \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockBase::blockBuild(). */ - public function build() { + protected function blockBuild() { $output = $this->view->display_handler->viewExposedFormBlocks(); // Before returning the block output, convert it to a renderable array with // contextual links.