From 694d95f65e10e94816be94368b6ada25cdabbd25 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Mon, 12 Jan 2015 17:47:19 +0000 Subject: [PATCH] Issue #2030571 by calebtr, daffie, filijonka, YesCT, Thomas Brekelmans, alexpott, Mile23, tadityar, Sharique, tim.plunkett, boztek: Expand Block with methods --- core/modules/block/block.api.php | 4 +- core/modules/block/block.module | 14 ++-- core/modules/block/src/BlockForm.php | 6 +- core/modules/block/src/BlockInterface.php | 66 ++++++++++++++++ core/modules/block/src/BlockListBuilder.php | 10 +-- core/modules/block/src/BlockRepository.php | 2 +- core/modules/block/src/BlockViewBuilder.php | 2 +- core/modules/block/src/Entity/Block.php | 79 +++++++++++++++++-- .../src/Tests/BlockInvalidRegionTest.php | 4 +- .../block/src/Tests/BlockRenderOrderTest.php | 4 +- .../block/src/Tests/BlockStorageUnitTest.php | 6 +- core/modules/block/src/Tests/BlockTest.php | 2 +- .../tests/src/Unit/BlockRepositoryTest.php | 11 +-- .../ConfigTranslationBlockListBuilder.php | 2 +- core/modules/language/language.module | 2 +- .../src/Tests/d6/MigrateBlockTest.php | 48 +++++------ core/modules/system/system.module | 2 +- 17 files changed, 194 insertions(+), 70 deletions(-) mode change 100644 => 100755 core/modules/block/block.module mode change 100644 => 100755 core/modules/block/src/BlockRepository.php mode change 100644 => 100755 core/modules/block/src/Entity/Block.php mode change 100644 => 100755 core/modules/block/tests/src/Unit/BlockRepositoryTest.php diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index 954402ab9822966..7f5269f521a67ff 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -154,8 +154,8 @@ function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\B function hook_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\user\Entity\User $account, $langcode) { // Example code that would prevent displaying the 'Powered by Drupal' block in // a region different than the footer. - if ($operation == 'view' && $block->get('plugin') == 'system_powered_by_block') { - return AccessResult::forbiddenIf($block->get('region') != 'footer')->cacheUntilEntityChanges($block); + if ($operation == 'view' && $block->getPluginId() == 'system_powered_by_block') { + return AccessResult::forbiddenIf($block->getRegion() != 'footer')->cacheUntilEntityChanges($block); } // No opinion. diff --git a/core/modules/block/block.module b/core/modules/block/block.module old mode 100644 new mode 100755 index 85d295e4f1bacfe..4ad7bedcfff406b --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -103,7 +103,7 @@ function _block_rehash($theme = NULL) { unset($blocks[$block_id]); continue; } - $region = $block->get('region'); + $region = $block->getRegion(); $status = $block->status(); // Disable blocks in invalid regions. if (!empty($region) && $region != BlockInterface::BLOCK_REGION_NONE && !isset($regions[$region]) && $status) { @@ -114,7 +114,7 @@ function _block_rehash($theme = NULL) { } // Set region to none if not enabled. if (!$status && $region != BlockInterface::BLOCK_REGION_NONE) { - $block->set('region', BlockInterface::BLOCK_REGION_NONE); + $block->setRegion(BlockInterface::BLOCK_REGION_NONE); $block->save(); } } @@ -159,13 +159,11 @@ function block_theme_initialize($theme) { else { $id = $theme . '_' . $default_theme_block_id; } - $block = $default_theme_block->createDuplicate(); - $block->set('id', $id); - $block->set('theme', $theme); + $block = $default_theme_block->createDuplicateBlock($id, $theme); // If the region isn't supported by the theme, assign the block to the // theme's default region. - if (!isset($regions[$block->get('region')])) { - $block->set('region', system_default_region($theme)); + if (!isset($regions[$block->getRegion()])) { + $block->setRegion(system_default_region($theme)); } $block->save(); } @@ -282,7 +280,7 @@ function block_user_role_delete($role) { function block_menu_delete(Menu $menu) { if (!$menu->isSyncing()) { foreach (Block::loadMultiple() as $block) { - if ($block->get('plugin') == 'system_menu_block:' . $menu->id()) { + if ($block->getPluginId() == 'system_menu_block:' . $menu->id()) { $block->delete(); } } diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index fd8eeab37e97b93..6b95cbd26a53201 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -98,7 +98,7 @@ class BlockForm extends EntityForm { $entity = $this->entity; // Store theme settings in $form_state for use below. - if (!$theme = $entity->get('theme')) { + if (!$theme = $entity->getTheme()) { $theme = $this->config('system.theme')->get('default'); } $form_state->set('block_theme', $theme); @@ -127,7 +127,7 @@ class BlockForm extends EntityForm { ); // Theme settings. - if ($entity->get('theme')) { + if ($entity->getTheme()) { $form['theme'] = array( '#type' => 'value', '#value' => $theme, @@ -157,7 +157,7 @@ class BlockForm extends EntityForm { '#type' => 'select', '#title' => $this->t('Region'), '#description' => $this->t('Select the region where this block should be displayed.'), - '#default_value' => $entity->get('region'), + '#default_value' => $entity->getRegion(), '#empty_value' => BlockInterface::BLOCK_REGION_NONE, '#options' => system_region_list($theme, REGIONS_VISIBLE), '#prefix' => '
', diff --git a/core/modules/block/src/BlockInterface.php b/core/modules/block/src/BlockInterface.php index d5dd321ea6c4b59..909621120edaddd 100644 --- a/core/modules/block/src/BlockInterface.php +++ b/core/modules/block/src/BlockInterface.php @@ -32,6 +32,30 @@ interface BlockInterface extends ConfigEntityInterface { */ public function getPlugin(); + /** + * Returns the plugin ID. + * + * @return string + * The plugin ID for this block. + */ + public function getPluginId(); + + /** + * Returns the region this block is placed in. + * + * @return string + * The region this block is placed in. + */ + public function getRegion(); + + /** + * Returns the theme ID. + * + * @return string + * The theme ID for this block instance. + */ + public function getTheme(); + /** * Returns an array of visibility condition configurations. * @@ -89,4 +113,46 @@ interface BlockInterface extends ConfigEntityInterface { */ public function setContexts(array $contexts); + /** + * Returns the weight of this block (used for sorting). + * + * @return int + * The block weight. + */ + public function getWeight(); + + /** + * Sets the region this block is placed in. + * + * @param string $region + * The region to place this block in. + * + * @return $this + */ + public function setRegion($region); + + /** + * Sets the block weight. + * + * @param int $weight + * The desired weight. + * + * @return $this + */ + public function setWeight($weight); + + /** + * Creates a duplicate of the block entity. + * + * @param string $new_id + * (optional) The new ID on the duplicate block. + * @param string $new_theme + * (optional) The theme on the duplicate block. + * + * @return static + * A clone of $this with all identifiers unset, so saving it inserts a new + * entity into the storage system. + */ + public function createDuplicateBlock($new_id = NULL, $new_theme = NULL); + } diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 444d98956aaa762..293f088a30f444b 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -183,10 +183,10 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface // Build blocks first for each region. foreach ($entities as $entity_id => $entity) { $definition = $entity->getPlugin()->getPluginDefinition(); - $blocks[$entity->get('region')][$entity_id] = array( + $blocks[$entity->getRegion()][$entity_id] = array( 'label' => $entity->label(), 'entity_id' => $entity_id, - 'weight' => $entity->get('weight'), + 'weight' => $entity->getWeight(), 'entity' => $entity, 'category' => $definition['category'], ); @@ -401,9 +401,9 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface $entities = $this->storage->loadMultiple(array_keys($form_state->getValue('blocks'))); foreach ($entities as $entity_id => $entity) { $entity_values = $form_state->getValue(array('blocks', $entity_id)); - $entity->set('weight', $entity_values['weight']); - $entity->set('region', $entity_values['region']); - if ($entity->get('region') == BlockInterface::BLOCK_REGION_NONE) { + $entity->setWeight($entity_values['weight']); + $entity->setRegion($entity_values['region']); + if ($entity->getRegion() == BlockInterface::BLOCK_REGION_NONE) { $entity->disable(); } else { diff --git a/core/modules/block/src/BlockRepository.php b/core/modules/block/src/BlockRepository.php old mode 100644 new mode 100755 index c11a4fe08020392..485a66fedd0b5da --- a/core/modules/block/src/BlockRepository.php +++ b/core/modules/block/src/BlockRepository.php @@ -78,7 +78,7 @@ class BlockRepository implements BlockRepositoryInterface { /** @var \Drupal\block\BlockInterface $block */ // Set the contexts on the block before checking access. if ($block->setContexts($contexts)->access('view')) { - $full[$block->get('region')][$block_id] = $block; + $full[$block->getRegion()][$block_id] = $block; } } diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php index 8c781c1e41a5ca8..6f2a71d4cd24946 100644 --- a/core/modules/block/src/BlockViewBuilder.php +++ b/core/modules/block/src/BlockViewBuilder.php @@ -57,7 +57,7 @@ class BlockViewBuilder extends EntityViewBuilder { 'route_parameters' => array('block' => $entity->id()), ), ), - '#weight' => $entity->get('weight'), + '#weight' => $entity->getWeight(), '#configuration' => $configuration, '#plugin_id' => $plugin_id, '#base_plugin_id' => $base_id, diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php old mode 100644 new mode 100755 index 0edc9616fcbab31..1f1b05922dfaed3 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -48,7 +48,7 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin * * @var string */ - public $id; + protected $id; /** * The plugin instance settings. @@ -69,7 +69,7 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin * * @var int */ - public $weight; + protected $weight; /** * The plugin instance ID. @@ -113,6 +113,13 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin */ protected $conditionPluginManager; + /** + * The theme that includes the block plugin for this entity. + * + * @var string + */ + protected $theme; + /** * {@inheritdoc} */ @@ -144,7 +151,35 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin } /** - * Overrides \Drupal\Core\Entity\Entity::label(); + * {@inheritdoc} + */ + public function getPluginId() { + return $this->plugin; + } + + /** + * {@inheritdoc} + */ + public function getRegion() { + return $this->region; + } + + /** + * {@inheritdoc} + */ + public function getTheme() { + return $this->theme; + } + + /** + * {@inheritdoc} + */ + public function getWeight() { + return $this->weight; + } + + /** + * {@inheritdoc} */ public function label() { $settings = $this->get('settings'); @@ -162,13 +197,13 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin */ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { // Separate enabled from disabled. - $status = $b->get('status') - $a->get('status'); - if ($status) { + $status = (int) $b->status() - (int) $a->status(); + if ($status !== 0) { return $status; } // Sort by weight, unless disabled. - if ($a->get('region') != static::BLOCK_REGION_NONE) { - $weight = $a->get('weight') - $b->get('weight'); + if ($a->getRegion() != static::BLOCK_REGION_NONE) { + $weight = $a->getWeight() - $b->getWeight(); if ($weight) { return $weight; } @@ -283,4 +318,34 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin return $this->conditionPluginManager; } + /** + * {@inheritdoc} + */ + public function setRegion($region) { + $this->region = $region; + return $this; + } + + /** + * {@inheritdoc} + */ + public function setWeight($weight) { + $this->weight = $weight; + return $this; + } + + /** + * {@inheritdoc} + */ + public function createDuplicateBlock($new_id = NULL, $new_theme = NULL) { + $duplicate = parent::createDuplicate(); + if (!empty($new_id)) { + $duplicate->id = $new_id; + } + if (!empty($new_theme)) { + $duplicate->theme = $new_theme; + } + return $duplicate; + } + } diff --git a/core/modules/block/src/Tests/BlockInvalidRegionTest.php b/core/modules/block/src/Tests/BlockInvalidRegionTest.php index 0f5d38da2e67025..722b6eb50bb28a6 100644 --- a/core/modules/block/src/Tests/BlockInvalidRegionTest.php +++ b/core/modules/block/src/Tests/BlockInvalidRegionTest.php @@ -42,7 +42,7 @@ class BlockInvalidRegionTest extends WebTestBase { function testBlockInInvalidRegion() { // Enable a test block and place it in an invalid region. $block = $this->drupalPlaceBlock('test_html'); - $block->set('region', 'invalid_region'); + $block->setRegion('invalid_region'); $block->save(); $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block->id(), '%region' => 'invalid_region')); @@ -57,7 +57,7 @@ class BlockInvalidRegionTest extends WebTestBase { // Place disabled test block in the invalid region of the default theme. $block = Block::load($block->id()); - $block->set('region', 'invalid_region'); + $block->setRegion('invalid_region'); $block->save(); // Clear the cache to check if the warning message is not triggered. diff --git a/core/modules/block/src/Tests/BlockRenderOrderTest.php b/core/modules/block/src/Tests/BlockRenderOrderTest.php index a926864d1b7d49f..11da1919e8e13b8 100644 --- a/core/modules/block/src/Tests/BlockRenderOrderTest.php +++ b/core/modules/block/src/Tests/BlockRenderOrderTest.php @@ -72,8 +72,8 @@ class BlockRenderOrderTest extends WebTestBase { $controller = $this->container->get('entity.manager')->getStorage('block'); foreach ($controller->loadMultiple() as $return_block) { - $id = $return_block->get('id'); - if ($return_block_weight = $return_block->get('weight')) { + $id = $return_block->id(); + if ($return_block_weight = $return_block->getWeight()) { $this->assertTrue($test_blocks[$id]['weight'] == $return_block_weight, 'Block weight is set as "' . $return_block_weight . '" for ' . $id . ' block.'); $position[$id] = strpos($test_content, Html::getClass('block-' . $test_blocks[$id]['id'])); } diff --git a/core/modules/block/src/Tests/BlockStorageUnitTest.php b/core/modules/block/src/Tests/BlockStorageUnitTest.php index 86f7d2f42ca9ffa..ff4ba29a2d354b8 100644 --- a/core/modules/block/src/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/src/Tests/BlockStorageUnitTest.php @@ -120,9 +120,9 @@ class BlockStorageUnitTest extends KernelTestBase { $this->assertTrue($entity instanceof Block, 'The loaded entity is a Block.'); // Verify several properties of the block. - $this->assertEqual($entity->get('region'), '-1'); - $this->assertTrue($entity->get('status')); - $this->assertEqual($entity->get('theme'), 'stark'); + $this->assertEqual($entity->getRegion(), '-1'); + $this->assertTrue($entity->status()); + $this->assertEqual($entity->getTheme(), 'stark'); $this->assertTrue($entity->uuid()); } diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index 9c30e1000a35cab..53d1e5736aa3365 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -348,7 +348,7 @@ class BlockTest extends BlockTestBase { $this->assertIdentical($cache_entry->tags, $expected_cache_tags); // The "Powered by Drupal" block is modified; verify a cache miss. - $block->set('region', 'content'); + $block->setRegion('content'); $block->save(); $this->drupalGet(''); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); diff --git a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php old mode 100644 new mode 100755 index 68a30085959a769..f589e82bad0c0e4 --- a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php +++ b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php @@ -93,12 +93,8 @@ class BlockRepositoryTest extends UnitTestCase { ->method('access') ->will($this->returnValue($block_config[0])); $block->expects($block_config[0] ? $this->atLeastOnce() : $this->never()) - ->method('get') - ->will($this->returnValueMap(array( - array('region', $block_config[1]), - array('weight', $block_config[2]), - array('status', TRUE), - ))); + ->method('getRegion') + ->willReturn($block_config[1]); $blocks[$block_id] = $block; } @@ -159,8 +155,7 @@ class BlockRepositoryTest extends UnitTestCase { ->method('access') ->willReturn(TRUE); $block->expects($this->once()) - ->method('get') - ->with('region') + ->method('getRegion') ->willReturn('top'); $blocks['block_id'] = $block; diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php index 332f8941d6c46b5..c14db12adc7fe53 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php @@ -61,7 +61,7 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $theme = $entity->get('theme'); + $theme = $entity->getTheme(); $plugin_definition = $entity->getPlugin()->getPluginDefinition(); $row['label'] = array( diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 0da7ed84076c090..ddf580403110da7 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -77,7 +77,7 @@ function language_help($route_name, RouteMatchInterface $route_match) { return $output; case 'entity.block.edit_form': - if (($block = $route_match->getParameter('block')) && $block->get('plugin') == 'language_block:language_interface') { + if (($block = $route_match->getParameter('block')) && $block->getPluginId() == 'language_block:language_interface') { return '

' . t('With multiple languages added, registered users can select their preferred language and authors can assign a specific language to content.') . '

'; } break; diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php index 9198ce50ad047af..e556cf2803b6876 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php @@ -88,69 +88,69 @@ class MigrateBlockTest extends MigrateDrupalTestBase { // User blocks $test_block_user = $blocks['user']; $this->assertNotNull($test_block_user); - $this->assertEqual('sidebar_first', $test_block_user->get('region')); - $this->assertEqual('bartik', $test_block_user->get('theme')); + $this->assertEqual('sidebar_first', $test_block_user->getRegion()); + $this->assertEqual('bartik', $test_block_user->getTheme()); $visibility = $test_block_user->getVisibility(); $this->assertTrue(empty($visibility['request_path']['pages'])); - $this->assertEqual(0, $test_block_user->weight); + $this->assertEqual(0, $test_block_user->getWeight()); $test_block_user_1 = $blocks['user_1']; $this->assertNotNull($test_block_user_1); - $this->assertEqual('sidebar_first', $test_block_user_1->get('region')); - $this->assertEqual('bartik', $test_block_user_1->get('theme')); + $this->assertEqual('sidebar_first', $test_block_user_1->getRegion()); + $this->assertEqual('bartik', $test_block_user_1->getTheme()); $visibility = $test_block_user_1->getVisibility(); $this->assertTrue(empty($visibility['request_path']['pages'])); - $this->assertEqual(0, $test_block_user_1->weight); + $this->assertEqual(0, $test_block_user_1->getWeight()); // Check system block $test_block_system = $blocks['system']; $this->assertNotNull($test_block_system); - $this->assertEqual('footer', $test_block_system->get('region')); - $this->assertEqual('bartik', $test_block_system->get('theme')); + $this->assertEqual('footer', $test_block_system->getRegion()); + $this->assertEqual('bartik', $test_block_system->getTheme()); $visibility = $test_block_system->getVisibility(); $this->assertTrue(empty($visibility['request_path']['pages'])); - $this->assertEqual(-5, $test_block_system->weight); + $this->assertEqual(-5, $test_block_system->getWeight()); // Check menu blocks $test_block_menu = $blocks['menu']; $this->assertNotNull($test_block_menu); - $this->assertEqual('header', $test_block_menu->get('region')); - $this->assertEqual('bartik', $test_block_menu->get('theme')); + $this->assertEqual('header', $test_block_menu->getRegion()); + $this->assertEqual('bartik', $test_block_menu->getTheme()); $visibility = $test_block_menu->getVisibility(); $this->assertTrue(empty($visibility['request_path']['pages'])); - $this->assertEqual(-5, $test_block_menu->weight); + $this->assertEqual(-5, $test_block_menu->getWeight()); // Check custom blocks $test_block_block = $blocks['block']; $this->assertNotNull($test_block_block); - $this->assertEqual('content', $test_block_block->get('region')); - $this->assertEqual('bartik', $test_block_block->get('theme')); + $this->assertEqual('content', $test_block_block->getRegion()); + $this->assertEqual('bartik', $test_block_block->getTheme()); $visibility = $test_block_block->getVisibility(); $this->assertEqual($visibility['request_path']['pages'], ''); - $this->assertEqual(0, $test_block_block->weight); + $this->assertEqual(0, $test_block_block->getWeight()); $test_block_block_1 = $blocks['block_1']; $this->assertNotNull($test_block_block_1); - $this->assertEqual('right', $test_block_block_1->get('region')); - $this->assertEqual('bluemarine', $test_block_block_1->get('theme')); + $this->assertEqual('right', $test_block_block_1->getRegion()); + $this->assertEqual('bluemarine', $test_block_block_1->getTheme()); $visibility = $test_block_block_1->getVisibility(); $this->assertEqual($visibility['request_path']['pages'], 'node'); - $this->assertEqual(-4, $test_block_block_1->weight); + $this->assertEqual(-4, $test_block_block_1->getWeight()); $test_block_block_2 = $blocks['block_2']; $this->assertNotNull($test_block_block_2); - $this->assertEqual('right', $test_block_block_2->get('region')); - $this->assertEqual('test_theme', $test_block_block_2->get('theme')); + $this->assertEqual('right', $test_block_block_2->getRegion()); + $this->assertEqual('test_theme', $test_block_block_2->getTheme()); $visibility = $test_block_block_2->getVisibility(); $this->assertTrue(empty($visibility['request_path']['pages'])); - $this->assertEqual(-7, $test_block_block_2->weight); + $this->assertEqual(-7, $test_block_block_2->getWeight()); $test_block_block_3 = $blocks['block_3']; $this->assertNotNull($test_block_block_3); - $this->assertEqual('left', $test_block_block_3->get('region')); - $this->assertEqual('test_theme', $test_block_block_3->get('theme')); + $this->assertEqual('left', $test_block_block_3->getRegion()); + $this->assertEqual('test_theme', $test_block_block_3->getTheme()); $visibility = $test_block_block_3->getVisibility(); $this->assertTrue(empty($visibility['request_path']['pages'])); - $this->assertEqual(-2, $test_block_block_3->weight); + $this->assertEqual(-2, $test_block_block_3->getWeight()); } } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8f2a8aba2ace73b..c1e4d5bce24347a 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -126,7 +126,7 @@ function system_help($route_name, RouteMatchInterface $route_match) { return '

' . t('The uninstall process removes all data related to a module.') . '

'; case 'entity.block.edit_form': - if (($block = $route_match->getParameter('block')) && $block->get('plugin') == 'system_powered_by_block') { + if (($block = $route_match->getParameter('block')) && $block->getPluginId() == 'system_powered_by_block') { return '

' . t('The Powered by Drupal block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '

'; } break;