diff --git a/core/lib/Drupal/Core/Cache/CacheableHelper.php b/core/lib/Drupal/Core/Cache/CacheableHelper.php index be1f402..88cc9af 100644 --- a/core/lib/Drupal/Core/Cache/CacheableHelper.php +++ b/core/lib/Drupal/Core/Cache/CacheableHelper.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Cache; +use Drupal\Core\Database\Query\SelectInterface; + /** * A helper class that contains methods that could be useful to any object using * the Drupal Cache API. @@ -24,7 +26,7 @@ class CacheableHelper { * @return string * A hash of the query arguments. */ - function keyFromQuery($query) { + function keyFromQuery(SelectInterface $query) { $query->preExecute(); $keys = array((string) $query, $query->getArguments()); return hash('sha256', serialize($keys)); @@ -50,7 +52,7 @@ function addCacheContextsToKeys($keys) { * Provides the string representaton of a cache context. * * @todo Document this properly once the input arguments are decided on, - * assuming the reuse of existing cache constants is temporary. + * assuming the reuse of existing cache constants is temporary. * * @return string * The string representaton of a cache context. diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php index 79ea257..4547527 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php @@ -79,7 +79,7 @@ public static function create(ContainerInterface $container, array $configuratio */ public function defaultConfiguration() { // By default, the block will contain 10 feed items. - return parent::defaultConfiguration() + array( + return array( 'block_count' => 10, 'feed' => NULL, ); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php index c6df55d..fe7f461 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php @@ -89,7 +89,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function defaultConfiguration() { - return parent::defaultConfiguration() + array( + return array( 'status' => TRUE, 'info' => '', 'view_mode' => 'full', diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 6e99c48..c5b2d4a 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -30,11 +30,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->configuration += $this->defaultConfiguration() + array( - 'label' => '', - 'module' => $plugin_definition['module'], - 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, - ); + $this->setConfiguration($configuration); } /** @@ -48,14 +44,14 @@ public function getConfiguration() { * {@inheritdoc} */ public function setConfiguration(array $configuration) { - $this->configuration = $configuration; + $this->configuration = $configuration + $this->baseConfigurationDefaults() + $this->defaultConfiguration(); } - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { + protected function baseConfigurationDefaults() { return array( + 'label' => '', + 'module' => $this->pluginDefinition['module'], + 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, 'cache' => array( 'max_age' => 0, ), @@ -65,6 +61,13 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ + public function defaultConfiguration() { + return array(); + } + + /** + * {@inheritdoc} + */ public function setConfigurationValue($key, $value) { $this->configuration[$key] = $value; } diff --git a/core/modules/block/tests/modules/block_test/lib/Drupal/block_test/Plugin/Block/TestBlockInstantiation.php b/core/modules/block/tests/modules/block_test/lib/Drupal/block_test/Plugin/Block/TestBlockInstantiation.php index 2834393..85856a3 100644 --- a/core/modules/block/tests/modules/block_test/lib/Drupal/block_test/Plugin/Block/TestBlockInstantiation.php +++ b/core/modules/block/tests/modules/block_test/lib/Drupal/block_test/Plugin/Block/TestBlockInstantiation.php @@ -24,7 +24,7 @@ class TestBlockInstantiation extends BlockBase { * {@inheritdoc} */ public function defaultConfiguration() { - return parent::defaultConfiguration() + array( + return array( 'display_message' => 'no message set', ); } diff --git a/core/modules/book/lib/Drupal/book/Plugin/Block/BookNavigationBlock.php b/core/modules/book/lib/Drupal/book/Plugin/Block/BookNavigationBlock.php index 1542a4d..e2cf674 100644 --- a/core/modules/book/lib/Drupal/book/Plugin/Block/BookNavigationBlock.php +++ b/core/modules/book/lib/Drupal/book/Plugin/Block/BookNavigationBlock.php @@ -64,7 +64,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function defaultConfiguration() { - return parent::defaultConfiguration() + array( + return array( 'block_mode' => "all pages", ); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Block/SyndicateBlock.php b/core/modules/node/lib/Drupal/node/Plugin/Block/SyndicateBlock.php index 6fd195e..ebcacf6 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Block/SyndicateBlock.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Block/SyndicateBlock.php @@ -25,7 +25,7 @@ class SyndicateBlock extends BlockBase { * {@inheritdoc} */ public function defaultConfiguration() { - return parent::defaultConfiguration() + array( + return array( 'block_count' => 10, ); } diff --git a/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php b/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php index 256fd40..1a19761 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php +++ b/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php @@ -45,7 +45,7 @@ class StatisticsPopularBlock extends BlockBase { * {@inheritdoc} */ public function defaultConfiguration() { - return parent::defaultConfiguration() + array( + return array( 'top_day_num' => 0, 'top_all_num' => 0, 'top_last_num' => 0 diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php index 8a5e372..7d91859 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php @@ -33,7 +33,6 @@ public function build() { * {@inheritdoc} */ public function defaultConfiguration() { - $default_configuration = parent::defaultConfiguration(); // Modify the default max age for menu blocks: modifications made to menus, // menu links and menu blocks will automatically invalidate corresponding // cache tags, therefor allowing us to cache menu blocks forever. This is @@ -42,8 +41,7 @@ public function defaultConfiguration() { // 1) it is possible to set a different max age for individual blocks, since // this is just the default value. // 2) modules can modify caching by implementing hook_block_view_alter() - $default_configuration['cache']['max_age'] = \Drupal\Core\Cache\Cache::PERMANENT; - return $default_configuration; + return array('cache' => array('max_age' => \Drupal\Core\Cache\Cache::PERMANENT)); } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php index 2648919..422e495 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -61,7 +61,7 @@ public function getConfiguration() { * {@inheritdoc} */ public function defaultConfiguration() { - $settings = parent::defaultConfiguration(); + $settings = array(); if ($this->displaySet) { $settings += $this->view->display_handler->blockSettings($settings); diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php index ded2b0c..3c228d1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php @@ -99,7 +99,7 @@ public function access(AccountInterface $account) { * {@inheritdoc} */ public function defaultConfiguration() { - return parent::defaultConfiguration() + array('views_label' => ''); + return array('views_label' => ''); } /**