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 de5d4bd..aa1036c 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 @@ -24,25 +24,27 @@ class AggregatorCategoryBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { + // By default, the block will contain 10 feed items. return array( 'block_count' => 10, ); } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { + // Only grant access to users with the 'access news feeds' permission. return user_access('access news feeds'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of news items in block'), @@ -53,14 +55,14 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $id = $this->getPluginId(); 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 284831c..58391d7 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 @@ -24,25 +24,27 @@ class AggregatorFeedBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { + // By default, the block will contain 10 feed items. return array( 'block_count' => 10, ); } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { + // Only grant access to users with the 'access news feeds' permission. return user_access('access news feeds'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of news items in block'), @@ -53,14 +55,14 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { // Plugin IDs look something like this: aggregator_feed_block:1. diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index 0bbadf2..8750744 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -266,7 +266,7 @@ function block_admin_configure($form, &$form_state, $plugin_id, $theme = NULL) { '#type' => 'value', '#value' => $theme, ); - $form += $instance->configureWrapper($form, $form_state); + $form += $instance->form($form, $form_state); return $form; } @@ -277,7 +277,7 @@ function block_admin_configure($form, &$form_state, $plugin_id, $theme = NULL) { * @see block_admin_configure_submit() */ function block_admin_configure_validate($form, &$form_state) { - $form['#instance']->configureValidateWrapper($form, $form_state); + $form['#instance']->validate($form, $form_state); } /** @@ -287,7 +287,7 @@ function block_admin_configure_validate($form, &$form_state) { * @see block_admin_configure_validate() */ function block_admin_configure_submit($form, &$form_state) { - $form['#instance']->configureSubmitWrapper($form, $form_state); + $form['#instance']->submit($form, $form_state); $config_values = $form['#instance']->getConfig(); $machine_name = 'plugin.core.block.' . $form_state['values']['theme'] . '.' . $form_state['values']['machine_name']; $config = config($machine_name); diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 420d38a..b1a5f52 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -514,7 +514,7 @@ function _block_load_blocks() { function _block_get_renderable_block($element) { $block = $element['#block']; // Don't bother to build blocks that aren't accessible. - if ($element['#access'] = $block->accessWrapper()) { + if ($element['#access'] = $block->access()) { $build = block_build($block); if ($build) { if (isset($build['#title'])) { 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 18b13b8..f4d3375 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 @@ -19,12 +19,12 @@ * module = "custom_block", * derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock", * custom = "TRUE", - * settings = { + * settings = { * "status" = TRUE, * "info" = "", * "body" = "", * "format" = NULL - * } + * } * ) */ class CustomBlock extends BlockBase { @@ -43,12 +43,11 @@ public function getConfig() { } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). * * Adds body and description fields to the block configuration form. */ - public function configure($form, &$form_state) { - $form = parent::configure($form, $form_state); + public function blockForm($form, &$form_state) { $form['custom_block']['info'] = array( '#type' => 'textfield', '#title' => t('Block description'), @@ -76,10 +75,9 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { - parent::configureSubmit($form, $form_state); + public function blockSubmit($form, &$form_state) { list(, $bid) = explode(':', $this->getPluginId()); $block = array( 'info' => $form_state['values']['info'], @@ -92,9 +90,10 @@ public function configureSubmit($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::build(); + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { + // Populate the block with the user-defined block body. return array( '#theme' => 'custom_block_block', '#body' => $this->configuration['body'], diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 74b51e6..d1f0e40 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -19,13 +19,12 @@ abstract class BlockBase extends PluginBase implements BlockInterface { /** - * Implements \Drupal\block\BlockInterface::settingsWrapper(). + * Implements \Drupal\block\BlockInterface::settings(). * - * @todo This method is not actually on the interface. Add it there if it - * should be required, or correct this documentation. + * @see \Drupal\block\BlockBase::blockSettings() */ - public function settingsWrapper() { - $settings = $this->settings(); + public function settings() { + $settings = $this->blockSettings(); // By default, blocks are enabled and not cached. $settings += array( 'status' => TRUE, @@ -35,24 +34,38 @@ public function settingsWrapper() { } /** - * Implements \Drupal\block\BlockInterface::settings(). + * Returns plugin-specific settings for the block. * * Block plugins only need to implement this method if they override the - * defaults provided in BlockInterface::settingsWrapper(). + * defaults provided in BlockBase::settings(). + * + * @return array + * An array of block-specific settings to override the defaults provided in + * BlockBase::settings(). + * + * @see \Drupal\block\BlockBase::settings(). */ - public function settings() { + public function blockSettings() { return array(); } /** - * Implements \Drupal\block\BlockInterface::getConfig(). + * Returns the configuration data for the block plugin. + * + * @return array + * The plugin configuration array from PluginBase::$configuration. + * + * @todo This doesn't belong here. Move this into a new base class in + * http://drupal.org/node/1764380. + * @todo This does not return a config object, so the name is confusing. * - * @todo This method is not actually on the interface. Add it there if it - * should be required, or correct this documentation. + * @see \Drupal\Component\Plugin\PluginBase::$configuration */ public function getConfig() { if (empty($this->configuration)) { - $this->configuration = $this->settingsWrapper(); + // If the plugin configuration is not already set, initialize it with the + // default settings for the block plugin. + $this->configuration = $this->settings(); // @todo This loads the default subject. Is this the right place to do so? $definition = $this->getDefinition(); @@ -64,41 +77,60 @@ public function getConfig() { } /** - * @todo Document this method. + * Sets a particular value in the block settings. + * + * @param string $key + * The key of PluginBase::$configuration to set. + * @param mixed $value + * The value to set for the provided key. + * + * @todo This doesn't belong here. Move this into a new base class in + * http://drupal.org/node/1764380. + * @todo This does not set a value in config(), so the name is confusing. + * + * @see \Drupal\Component\Plugin\PluginBase::$configuration */ public function setConfig($key, $value) { $this->configuration[$key] = $value; } /** - * Implements \Drupal\block\BlockInterface::access(). + * Indicates whether block-specific criteria allow access to the block. * - * Block plugins should override this method to add access restrictions - * specific to the block type. + * Blocks with access restrictions that should always be applied, + * regardless of user-configured settings, should implement this method + * with that access control logic. + * + * @return bool + * FALSE to deny access to the block, or TRUE to allow + * BlockBase::access() to make the access determination. + * + * @see \Drupal\block\BlockBase::access() */ - public function access() { + public function blockAccess() { // By default, the block is visible unless user-configured rules indicate // that it should be hidden. return TRUE; } /** - * Implements \Drupal\block\BlockInterface::accessWrapper(). + * Implements \Drupal\block\BlockInterface::access(). * * Adds the user-configured per-role, per-path, and per-language visibility * settings to all blocks, and invokes hook_block_access(). * * Most plugins should not override this method unless they need to remove * the user-defined access restrictions. To add specific access - * restrictions for a particular block type, override BlockBase::access() - * instead. + * restrictions for a particular block type, override + * BlockBase::blockAccess() instead. * * @see hook_block_access() + * @see \Drupal\block\BlockBase::blockAccess() */ - public function accessWrapper() { + public function access() { // If the block-specific access restrictions indicate the block is not // accessible, always deny access. - if (!$this->access()) { + if (!$this->blockAccess()) { return FALSE; } @@ -175,13 +207,15 @@ public function accessWrapper() { } /** - * Implements \Drupal\block\BlockInterface::configureWrapper(). + * Implements \Drupal\block\BlockInterface::form(). * * Creates a generic configuration form for all block types. Individual - * block plugins can add elements to this form by implementing - * BlockInterface::configure(). + * block plugins can add elements to this form by overriding + * BlockBase::blockForm(). + * + * @see \Drupal\block\BlockBase::blockForm() */ - public function configureWrapper($form, &$form_state) { + public function form($form, &$form_state) { $definition = $this->getDefinition(); $config = $this->getConfig(); $form['id'] = array( @@ -384,7 +418,7 @@ public function configureWrapper($form, &$form_state) { ); // Add specific configuration for this block type. - $form += $this->configure($form, $form_state); + $form += $this->blockForm($form, $form_state); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( @@ -396,18 +430,33 @@ public function configureWrapper($form, &$form_state) { } /** - * Implements \Drupal\block\BlockInterface::configure(). + * Returns the configuration form elements specific to this block plugin. + * + * Blocks that need to add form elements to the normal block configuration + * form should implement this method. + * + * @param array $form + * The form definition array for the block configuration form. + * @param array $form_state + * An array containing the current state of the configuration form. + * + * @return array $form + * The renderable form array representing the entire configuration form. + * + * @see \Drupal\block\BlockBase::form() */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { return array(); } /** - * Implements \Drupal\block\BlockInterface::configureValidateWrapper(). + * Implements \Drupal\block\BlockInterface::validate(). * * @todo Add inline documentation to this method. + * + * @see \Drupal\block\BlockBase::blockValidate() */ - public function configureValidateWrapper($form, &$form_state) { + public function validate($form, &$form_state) { if (empty($form['settings']['machine_name']['#disabled'])) { if (preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['machine_name'])) { form_set_error('machine_name', t('Block name must be alphanumeric or underscores only.')); @@ -431,21 +480,36 @@ public function configureValidateWrapper($form, &$form_state) { } $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']); - // Validate block type-specific form elements. - $this->configureValidate($form, $form_state); + // Perform block type-specific validation. + $this->blockValidate($form, $form_state); } /** - * Implements \Drupal\block\BlockInterface::configureValidate(). + * Adds block type-specific validation for the block form. + * + * Note that this method takes the form structure and form state arrays for + * the full block configuration form as arguments, not just the elements + * defined in BlockBase::blockForm(). + * + * @param array $form + * The form definition array for the full block configuration form. + * @param array $form_state + * An array containing the current state of the configuration form. + * + * @see \Drupal\block\BlockBase::blockForm() + * @see \Drupal\block\BlockBase::blockSubmit() + * @see \Drupal\block\BlockBase::validate() */ - public function configureValidate($form, &$form_state) {} + public function blockValidate($form, &$form_state) {} /** - * Implements \Drupal\block\BlockInterface::configureSubmitWrapper(). + * Implements \Drupal\block\BlockInterface::submit(). * * @todo Add inline documentation to this method. + * + * @see \Drupal\block\BlockBase::blockSubmit() */ - public function configureSubmitWrapper($form, &$form_state) { + public function submit($form, &$form_state) { if (!form_get_errors()) { $transaction = db_transaction(); try { @@ -471,18 +535,33 @@ public function configureSubmitWrapper($form, &$form_state) { if (empty($this->configuration['weight'])) { $this->configuration['weight'] = 0; } + // @todo Move this to the procedural code. drupal_set_message(t('The block configuration has been saved.')); + // @todo Move this to the procedural code and possibly just invalidate + // the content cache rather than forcing a cache clear. drupal_flush_all_caches(); - // Handle submissions for block type-specific form elements. - $this->configureSubmit($form, $form_state); + // Perform block type-specific validation. + $this->blockSubmit($form, $form_state); } } /** - * Implements \Drupal\block\BlockInterface::configureSubmit(). + * Adds block type-specific submission handling for the block form. + * + * Note that this method takes the form structure and form state arrays for + * the full block configuration form as arguments, not just the elements + * defined in BlockBase::blockForm(). + * + * @param array $form + * The form definition array for the full block configuration form. + * @param array $form_state + * An array containing the current state of the configuration form. + * + * @see \Drupal\block\BlockBase::blockForm() + * @see \Drupal\block\BlockBase::blockValidate() + * @see \Drupal\block\BlockBase::submit() */ - public function configureSubmit($form, &$form_state) { - } + public function blockSubmit($form, &$form_state) {} } diff --git a/core/modules/block/lib/Drupal/block/BlockInterface.php b/core/modules/block/lib/Drupal/block/BlockInterface.php index d0ab023..b419b27 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -8,7 +8,7 @@ /** * Defines the required interface for all block plugins. - + * * @todo Add detailed documentation here explaining the block system's * architecture and the relationships between the various objects, including * brif references to the important components that are not coupled to the @@ -24,6 +24,9 @@ * @return array * An associative array of block settings for this block, keyed by the * setting name. + * + * @todo Consider merging this with the general plugin configuration member + * variable and its getter/setter in http://drupal.org/node/1764380. */ public function settings(); @@ -31,82 +34,18 @@ public function settings(); * Indicates whether the block should be shown. * * This method allows base implementations to add general access restrictions - * that should apply to all extending block plugins, and is typically the - * access check used externally. Base implementations of this method should - * generally check BlockInterface::access() so that extending classes can - * add their own access restrictions. + * that should apply to all extending block plugins. * * @return bool * TRUE if the block should be shown, or FALSE otherwise. - * - * @see \Drupal\block\BlockInterace::access() - */ - public function accessWrapper(); - - /** - * Indicates whether block-specific criteria allow access to the block. - * - * Blocks with access restrictions that should always be applied, - * regardless of user-configured settings, should implement this method - * with that access control logic. - * - * @return bool - * FALSE to deny access to the block, or TRUE to allow - * BlockInterface::accessWrapper() to make the access determination. - * - * @see \Drupal\block\BlockInterace::accessWrapper() */ public function access(); /** - * Returns the configuration form elements specific to this block plugin. - * - * Blocks that need to add form elements to the normal block configuration - * form should implement this method. - * - * @param array $form - * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. - * - * @return array $form - * The renderable form array representing the entire configuration form. - * - * @see \Drupal\block\BlockInterace::configureWrapper() - */ - public function configure($form, &$form_state); - - /** - * The validation wrapper for the configuration form. - * - * @param array $form - * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. - * - * @todo Clarify documentation for this method. - */ - public function configureValidate($form, &$form_state); - - /** - * The submission wrapper for the configuration form. - * - * @param array $form - * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. - * - * @todo Clarify documentation for this method. - */ - public function configureSubmit($form, &$form_state); - - /** - * Returns the full form for block configuration. + * Constructs the block configuration form. * * This method allows base implementations to add a generic configuration - * form for extending block plugins. Base implementations of this method - * should generally embed the result of BlockInterface::configure() in the - * form so that extending classes can add their own configuration options. + * form for extending block plugins. * * @param array $form * The form definition array for the block configuration form. @@ -115,34 +54,37 @@ public function configureSubmit($form, &$form_state); * * @return array $form * The renderable form array representing the entire configuration form. + * + * @see \Drupal\block\BlockInterace::validate() + * @see \Drupal\block\BlockInterace::submit() */ - public function configureWrapper($form, &$form_state); + public function form($form, &$form_state); /** - * The validation for the configuration form. + * Handles form validation for the block configuration form. * * @param array $form * The form definition array for the block configuration form. * @param array $form_state * An array containing the current state of the configuration form. * - * @see \Drupal\block\BlockInterace::configure() - * - * @todo Clarify documentation for this method. + * @see \Drupal\block\BlockInterace::form() + * @see \Drupal\block\BlockInterace::submit() */ - public function configureValidateWrapper($form, &$form_state); + public function validate($form, &$form_state); /** - * The submission for the configuration form. + * Handles form submissions for the block configuration form. * * @param array $form * The form definition array for the block configuration form. * @param array $form_state * An array containing the current state of the configuration form. * - * @todo Clarify documentation for this method. + * @see \Drupal\block\BlockInterace::form() + * @see \Drupal\block\BlockInterace::validate() */ - public function configureSubmitWrapper($form, &$form_state); + public function submit($form, &$form_state); /** * Builds and returns the renderable array for this block. 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 878806a..57a7ac8 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 @@ -23,16 +23,18 @@ class TestCacheBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). + * + * Sets a different caching strategy for testing purposes. */ - public function settings() { + public function blockSettings() { return array( 'cache' => DRUPAL_CACHE_PER_ROLE, ); } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { return array( 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 c4b1f5c..edaae57 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 @@ -23,9 +23,9 @@ class BookNavigationBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'cache' => DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE, 'block_mode' => "all pages", @@ -33,9 +33,9 @@ public function settings() { } /** - * Overrides \Drupal\block\BlockBase::configure() + * Overrides \Drupal\block\BlockBase::blockForm() */ - function configure($form, &$form_state) { + function blockForm($form, &$form_state) { $options = array( 'all pages' => t('Show block on all pages'), 'book pages' => t('Show block only on book pages'), @@ -52,14 +52,14 @@ function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['block_mode'] = $form_state['values']['book_block_mode']; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $current_bid = 0; 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 694591d..e9ce19b 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 @@ -23,9 +23,9 @@ class RecentCommentsBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'block_count' => 10, ); @@ -34,14 +34,14 @@ public function settings() { /** * Overrides \Drupal\block\BlockBase::access(). */ - public function access() { + public function blockAccess() { return user_access('access comments'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of recent comments'), @@ -52,14 +52,14 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } /** - * Overrides \Drupal\block\BlockBase::build(); + * Implements \Drupal\block\BlockInterface::build(); */ public function build() { return array( 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 eb22043..9b8cda5 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,7 +22,7 @@ class ActiveTopicsBlock extends ForumBlockBase { /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $query = db_select('forum_index', 'f') diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php index d11a9e4..c888178 100644 --- a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php +++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php @@ -15,9 +15,9 @@ abstract class ForumBlockBase extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'cache' => DRUPAL_CACHE_CUSTOM, 'properties' => array( @@ -28,16 +28,16 @@ public function settings() { } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return user_access('access content'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of topics'), @@ -48,9 +48,9 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } 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 1086ff5..1b5d9b4 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,7 +22,7 @@ class NewTopicsBlock extends ForumBlockBase { /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $query = db_select('forum_index', 'f') 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 32897cb..f303211 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 @@ -24,14 +24,14 @@ class LanguageBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - function access() { + function blockAccess() { return language_multilingual(); } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ function build() { $path = drupal_is_front_page() ? '' : current_path(); 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 156c757..f7003b4 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 @@ -23,25 +23,25 @@ class RecentContentBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'block_count' => 10, ); } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return user_access('access content'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of recent content items to display'), @@ -52,14 +52,14 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } /** - * Overrides \Drupal\block\BlockBase::build(); + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { if ($nodes = node_get_recent($this->configuration['block_count'])) { 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 edb6e78..460045a 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 @@ -23,23 +23,23 @@ class SyndicateBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'block_count' => 10, ); } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return user_access('access content'); } /** - * Overrides \Drupal\block\BlockBase::build(); + * Implements \Drupal\block\BlockInterface::build(); */ public function build() { return array( 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 d9b08e4..f9de24e 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 @@ -30,9 +30,9 @@ class PollRecentBlock extends BlockBase { protected $record; /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'properties' => array( 'administrative' => TRUE, @@ -41,9 +41,9 @@ public function settings() { } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { if (user_access('access content')) { // Retrieve the latest poll. $select = db_select('node', 'n'); @@ -65,7 +65,7 @@ public function access() { } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $poll = node_load($this->record); 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 cd24ac6..a6fbb04 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 @@ -23,14 +23,14 @@ class SearchBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return user_access('search content'); } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { 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 e9f445d..7638a29 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,7 +23,7 @@ class ShortcutsBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { return array( 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 6465a2a..cb82dcc 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 @@ -44,9 +44,9 @@ class StatisticsPopularBlock extends BlockBase { protected $last_list; /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'top_day_num' => 0, 'top_all_num' => 0, @@ -55,9 +55,9 @@ public function settings() { } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { if (user_access('access content')) { $daytop = $this->configuration['top_day_num']; if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, t("Today's:")))) { @@ -77,9 +77,9 @@ public function access() { } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { // Popular content block settings. $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40)); $form['statistics_block_top_day_num'] = array( @@ -107,16 +107,16 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['top_day_num'] = $form_state['values']['statistics_block_top_day_num']; $this->configuration['top_all_num'] = $form_state['values']['statistics_block_top_all_num']; $this->configuration['top_last_num'] = $form_state['values']['statistics_block_top_last_num']; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $content = array(); 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 34b68ad..ac50042 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 @@ -30,15 +30,15 @@ class SystemHelpBlock extends BlockBase { protected $help; /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { $this->help = menu_get_active_help(); return (bool) $this->help; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { return array( 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 b2cffa6..21e4268 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,7 +23,7 @@ class SystemMainBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { return array( 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 5c95a5f..6d3b837 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 @@ -24,16 +24,16 @@ class SystemMenuBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { // @todo The 'Tools' menu should be available to anonymous users. list($plugin, $derivative) = explode(':', $this->getPluginId()); return ($GLOBALS['user']->uid || in_array($derivative, array('menu-tools', 'menu-footer'))); } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { list($plugin, $derivative) = explode(':', $this->getPluginId()); 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 82bf742..4b94df0 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,7 +23,7 @@ class SystemPoweredByBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { return array( 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 63e4be4..4ca502c 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 @@ -23,14 +23,14 @@ class UserLoginBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return (!$GLOBALS['user']->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))); } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $form = drupal_get_form('user_login_form'); 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 89b9131..742cd89 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 @@ -23,9 +23,9 @@ class UserNewBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'properties' => array( 'administrative' => TRUE @@ -35,16 +35,16 @@ public function settings() { } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return user_access('access content'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $form['user_block_whois_new_count'] = array( '#type' => 'select', '#title' => t('Number of users to display'), @@ -55,14 +55,14 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['whois_new_count'] = $form_state['values']['user_block_whois_new_count']; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { // Retrieve a list of new users who have accessed the site successfully. 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 1253c71..017a56f 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 @@ -26,9 +26,9 @@ class UserOnlineBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::settings(). + * Overrides \Drupal\block\BlockBase::blockSettings(). */ - public function settings() { + public function blockSettings() { return array( 'properties' => array( 'administrative' => TRUE @@ -39,16 +39,16 @@ public function settings() { } /** - * Overrides \Drupal\block\BlockBase::access(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function access() { + public function blockAccess() { return user_access('access content'); } /** - * Overrides \Drupal\block\BlockBase::configure(). + * Overrides \Drupal\block\BlockBase::blockForm(). */ - public function configure($form, &$form_state) { + public function blockForm($form, &$form_state) { $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval'); $form['user_block_seconds_online'] = array( '#type' => 'select', @@ -68,15 +68,15 @@ public function configure($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::configureSubmit(). + * Overrides \Drupal\block\BlockBase::blockSubmit(). */ - public function configureSubmit($form, &$form_state) { + public function blockSubmit($form, &$form_state) { $this->configuration['seconds_online'] = $form_state['values']['user_block_seconds_online']; $this->configuration['max_list_count'] = $form_state['values']['user_block_max_list_count']; } /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { // Count users active within the defined period. 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 98330e3..4131651 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 @@ -52,11 +52,16 @@ public function __construct(array $configuration, $plugin_id, DiscoveryInterface } /** - * Overrides \Drupal\block\BlockBase::configureWrapper(). + * Overrides \Drupal\block\BlockBase::blockAccess(). */ - public function configureWrapper($form, &$form_state) { - $form = parent::configureWrapper($form, $form_state); + public function blockAccess() { + return $this->view->access($this->displayID); + } + /** + * Overrides \Drupal\block\BlockBase::blockForm(). + */ + public function blockForm($form, &$form_state) { // Set the default subject to '' so the views internal title is used. $form['settings']['title']['#default_value'] = ''; $form['settings']['title']['#access'] = FALSE; @@ -64,14 +69,7 @@ public function configureWrapper($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::access(). - */ - public function access() { - return $this->view->access($this->displayID); - } - - /** - * Overrides \Drupal\block\BlockBase::build(). + * Implements \Drupal\block\BlockInterface::build(). */ public function build() { $output = $this->view->executeDisplay($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 835978a..f274913 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,7 +23,7 @@ class ViewsExposedFilterBlock extends ViewsBlock { /** - * Overrides \Drupal\block\BlockBase::build(). + * Overrides \Drupal\views\Plugin\block\block\ViewsBlock::build(). */ public function build() { $type = 'exp';