diff --git a/core/modules/block/lib/Drupal/block/BlockStorageController.php b/core/modules/block/lib/Drupal/block/BlockStorageController.php index 3997704..02374ff 100644 --- a/core/modules/block/lib/Drupal/block/BlockStorageController.php +++ b/core/modules/block/lib/Drupal/block/BlockStorageController.php @@ -16,6 +16,24 @@ class BlockStorageController extends ConfigStorageController { /** + * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::create(). + */ + public function create(array $values) { + $entity = parent::create($values); + + if (!$entity->get('module')) { + $definition = $entity->getPlugin()->getDefinition(); + $entity->set('module', $definition['module']); + } + $configuration = $entity->get('configuration'); + if (isset($configuration['cache'])) { + $entity->set('cache', $configuration['cache']); + } + + return $entity; + } + + /** * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::load(). */ public function load(array $ids = NULL) { @@ -45,6 +63,13 @@ public function loadByProperties(array $values = array()) { protected function preSave(EntityInterface $entity) { parent::preSave($entity); + // Ensure that the theme is stored directly on the entity, to simplify + // \Drupal\Core\Config\Entity\ConfigStorageController::loadByProperties(). + if (!$entity->get('theme')) { + list($theme) = explode('.', $entity->id()); + $entity->set('theme', $theme); + } + // Cache settings are stored directly on the block, remove them from // configuration. $configuration = $entity->get('configuration'); 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 775ecfa..7f27640 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 @@ -128,44 +128,25 @@ class Block extends ConfigEntityBase { protected $plugin; /** - * Overrides \Drupal\Core\Entity\Entity::__construct(). - */ - public function __construct(array $values, $entity_type) { - parent::__construct($values, $entity_type); - - // @todo Consider moving to Block::getPlugin(). - try { - $this->instance = drupal_container()->get('plugin.manager.block')->createInstance($this->plugin, $this->configuration); - $this->configuration += $this->instance->getConfig(); - } - catch (PluginException $e) { - // Ignore blocks belonging to disabled modules, but re-throw valid - // exceptions when the module is enabled and the plugin is misconfigured. - if (module_exists($this->module)) { - throw $e; - } - } - - // @todo Consider moving to \Drupal\block\BlockStorageController::create(). - if (!$this->module) { - $definition = $this->instance->getDefinition(); - $this->module = $definition['module']; - } - if (isset($this->configuration['cache'])) { - $this->cache = $this->configuration['cache']; - } - if (!isset($this->theme) && $id = $this->id()) { - list($this->theme) = explode('.', $id); - } - } - - /** * Returns the plugin instance. * * @return \Drupal\block\BlockInterface * The plugin instance for this block. */ public function getPlugin() { + if (!$this->instance) { + try { + $this->instance = drupal_container()->get('plugin.manager.block')->createInstance($this->plugin, $this->configuration); + $this->configuration += $this->instance->getConfig(); + } + catch (PluginException $e) { + // Ignore blocks belonging to disabled modules, but re-throw valid + // exceptions when the module is enabled and the plugin is misconfigured. + if (module_exists($this->module)) { + throw $e; + } + } + } return $this->instance; } diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php index 27b2a10..5c654a5 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/OverrideDisplaysTest.php @@ -80,7 +80,7 @@ function testOverrideDisplays() { /** * Tests that the wizard correctly sets up default and overridden displays. */ - function _testWizardMixedDefaultOverriddenDisplays() { + function testWizardMixedDefaultOverriddenDisplays() { // Create a basic view with a page, block, and feed. Give the page and feed // identical titles, but give the block a different one, so we expect the // page and feed to inherit their titles from the default display, but the @@ -163,7 +163,7 @@ function _testWizardMixedDefaultOverriddenDisplays() { /** * Tests that the revert to all displays select-option works as expected. */ - function _testRevertAllDisplays() { + function testRevertAllDisplays() { // Create a basic view with a page, block. // Because there is both a title on page and block we expect the title on // the block be overriden. diff --git a/core/profiles/standard/config/plugin.core.block.bartik.content.yml b/core/profiles/standard/config/plugin.core.block.bartik.content.yml index d48bd7a..1406a59 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.content.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.content.yml @@ -1,5 +1,6 @@ id: bartik.content plugin: system_main_block +theme: bartik status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.bartik.footer.yml b/core/profiles/standard/config/plugin.core.block.bartik.footer.yml index 910dfa3..4d03200 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.footer.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.footer.yml @@ -1,5 +1,6 @@ id: bartik.footer plugin: 'system_menu_block:menu-footer' +theme: bartik status: '1' cache: '-1' label: 'Footer menu' diff --git a/core/profiles/standard/config/plugin.core.block.bartik.help.yml b/core/profiles/standard/config/plugin.core.block.bartik.help.yml index b40a88f..0f46023 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.help.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.help.yml @@ -1,5 +1,6 @@ id: bartik.help plugin: system_help_block +theme: bartik status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.bartik.login.yml b/core/profiles/standard/config/plugin.core.block.bartik.login.yml index 09526b8..1e780b6 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.login.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.login.yml @@ -18,4 +18,5 @@ module: user region: sidebar_first weight: '0' plugin: user_login_block +theme: bartik langcode: und diff --git a/core/profiles/standard/config/plugin.core.block.bartik.powered.yml b/core/profiles/standard/config/plugin.core.block.bartik.powered.yml index 6fb1f5d..165d5d0 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.powered.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.powered.yml @@ -1,5 +1,6 @@ id: bartik.powered plugin: system_powered_by_block +theme: bartik status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.bartik.search.yml b/core/profiles/standard/config/plugin.core.block.bartik.search.yml index 6d11ee3..d69e7bb 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.search.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.search.yml @@ -1,5 +1,6 @@ id: bartik.search plugin: search_form_block +theme: bartik status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.bartik.tools.yml b/core/profiles/standard/config/plugin.core.block.bartik.tools.yml index 002402e..40df6d9 100644 --- a/core/profiles/standard/config/plugin.core.block.bartik.tools.yml +++ b/core/profiles/standard/config/plugin.core.block.bartik.tools.yml @@ -1,5 +1,6 @@ id: bartik.tools plugin: 'system_menu_block:menu-tools' +theme: bartik status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.seven.content.yml b/core/profiles/standard/config/plugin.core.block.seven.content.yml index a0a3d71..8a826c1 100644 --- a/core/profiles/standard/config/plugin.core.block.seven.content.yml +++ b/core/profiles/standard/config/plugin.core.block.seven.content.yml @@ -1,5 +1,6 @@ id: seven.content plugin: system_main_block +theme: seven status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.seven.help.yml b/core/profiles/standard/config/plugin.core.block.seven.help.yml index 9d20b69..5b3ad82 100644 --- a/core/profiles/standard/config/plugin.core.block.seven.help.yml +++ b/core/profiles/standard/config/plugin.core.block.seven.help.yml @@ -1,5 +1,6 @@ id: bartik.content plugin: system_help_block +theme: seven status: '1' cache: '-1' visibility: diff --git a/core/profiles/standard/config/plugin.core.block.seven.login.yml b/core/profiles/standard/config/plugin.core.block.seven.login.yml index 4cfd3d4..7f19040 100644 --- a/core/profiles/standard/config/plugin.core.block.seven.login.yml +++ b/core/profiles/standard/config/plugin.core.block.seven.login.yml @@ -1,5 +1,6 @@ id: seven.login plugin: user_login_block +theme: seven status: '1' cache: '-1' visibility: diff --git a/core/profiles/testing/config/plugin.core.block.stark.admin.yml b/core/profiles/testing/config/plugin.core.block.stark.admin.yml index 83ea3b1..e7d832d 100644 --- a/core/profiles/testing/config/plugin.core.block.stark.admin.yml +++ b/core/profiles/testing/config/plugin.core.block.stark.admin.yml @@ -1,5 +1,6 @@ id: stark.admin plugin: 'system_menu_block:menu-admin' +theme: stark status: '1' cache: '-1' visibility: diff --git a/core/profiles/testing/config/plugin.core.block.stark.online.yml b/core/profiles/testing/config/plugin.core.block.stark.online.yml index 71996b5..db1f2cc 100644 --- a/core/profiles/testing/config/plugin.core.block.stark.online.yml +++ b/core/profiles/testing/config/plugin.core.block.stark.online.yml @@ -1,6 +1,7 @@ id: stark.online label: 'Who''s online' plugin: user_online_block +theme: stark configuration: properties: administrative: '1' diff --git a/core/profiles/testing/config/plugin.core.block.stark.tools.yml b/core/profiles/testing/config/plugin.core.block.stark.tools.yml index b043215..bda5f0f 100644 --- a/core/profiles/testing/config/plugin.core.block.stark.tools.yml +++ b/core/profiles/testing/config/plugin.core.block.stark.tools.yml @@ -1,5 +1,6 @@ id: stark.tools plugin: 'system_menu_block:menu-tools' +theme: stark status: '1' cache: '-1' visibility: