diff --git a/core/modules/action/tests/Drupal/action/Tests/Menu/ActionLocalTasksTest.php b/core/modules/action/tests/Drupal/action/Tests/Menu/ActionLocalTasksTest.php index 891db5b..729d314 100644 --- a/core/modules/action/tests/Drupal/action/Tests/Menu/ActionLocalTasksTest.php +++ b/core/modules/action/tests/Drupal/action/Tests/Menu/ActionLocalTasksTest.php @@ -26,7 +26,7 @@ public static function getInfo() { } public function setUp() { - $this->moduleList = array('action' => 'core/modules/action/action.info.yml'); + $this->moduleList = array('action' => 'core/modules/action/action.module'); parent::setUp(); } diff --git a/core/modules/aggregator/tests/Drupal/aggregator/Tests/Menu/AggregatorLocalTasksTest.php b/core/modules/aggregator/tests/Drupal/aggregator/Tests/Menu/AggregatorLocalTasksTest.php index 67bedd8..5119603 100644 --- a/core/modules/aggregator/tests/Drupal/aggregator/Tests/Menu/AggregatorLocalTasksTest.php +++ b/core/modules/aggregator/tests/Drupal/aggregator/Tests/Menu/AggregatorLocalTasksTest.php @@ -26,7 +26,7 @@ public static function getInfo() { } public function setUp() { - $this->moduleList = array('aggregator' => 'core/modules/aggregator/aggregator.info.yml'); + $this->moduleList = array('aggregator' => 'core/modules/aggregator/aggregator.module'); parent::setUp(); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 4d96430..e27af49 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -5,16 +5,12 @@ * Controls the visual building blocks a page is constructed with. */ +use Drupal\block\BlockInterface; use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Utility\NestedArray; use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** - * Denotes that a block is not enabled in any region and should not be shown. - */ -const BLOCK_REGION_NONE = -1; - -/** * Shows this block on every page except the listed pages. */ const BLOCK_VISIBILITY_NOTLISTED = 0; @@ -308,15 +304,15 @@ function _block_rehash($theme = NULL) { $region = $block->get('region'); $status = $block->status(); // Disable blocks in invalid regions. - if (!empty($region) && $region != BLOCK_REGION_NONE && !isset($regions[$region]) && $status) { + if (!empty($region) && $region != BlockInterface::BLOCK_REGION_NONE && !isset($regions[$region]) && $status) { drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block_id, '%region' => $region)), 'warning'); - // Disabled modules are moved into the BLOCK_REGION_NONE later so no - // need to move the block to another region. + // Disabled modules are moved into the BlockInterface::BLOCK_REGION_NONE + // later so no need to move the block to another region. $block->disable()->save(); } // Set region to none if not enabled. if (!$status) { - $block->set('region', BLOCK_REGION_NONE); + $block->set('region', BlockInterface::BLOCK_REGION_NONE); $block->save(); } } diff --git a/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php b/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php index 96866fd..39ddc54 100644 --- a/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php +++ b/core/modules/block/custom_block/tests/Drupal/custom_blocks/Tests/Menu/CustomBlockLocalTasksTest.php @@ -27,8 +27,8 @@ public static function getInfo() { public function setUp() { $this->moduleList = array( - 'block' => 'core/modules/block/block.info.yml', - 'custom_block' => 'core/modules/block/custom_block/custom_block.info.yml', + 'block' => 'core/modules/block/block.module', + 'custom_block' => 'core/modules/block/custom_block/custom_block.module', ); parent::setUp(); } diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 92d3696..e2692a4 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -259,7 +259,7 @@ public function form(array $form, array &$form_state) { '#title' => $this->t('Region'), '#description' => $this->t('Select the region where this block should be displayed.'), '#default_value' => $entity->get('region'), - '#empty_value' => BLOCK_REGION_NONE, + '#empty_value' => BlockInterface::BLOCK_REGION_NONE, '#options' => system_region_list($theme, REGIONS_VISIBLE), '#prefix' => '
', '#suffix' => '
', diff --git a/core/modules/block/lib/Drupal/block/BlockInterface.php b/core/modules/block/lib/Drupal/block/BlockInterface.php index 0ffbcfc..de0d9de 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -20,6 +20,11 @@ const BLOCK_LABEL_VISIBLE = 'visible'; /** + * Denotes that a block is not enabled in any region and should not be shown. + */ + const BLOCK_REGION_NONE = -1; + + /** * Returns the plugin instance. * * @return \Drupal\block\BlockPluginInterface diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 30d0afd..874ff35 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -155,7 +155,7 @@ public function buildForm(array $form, array &$form_state) { $form['#attributes']['class'][] = 'clearfix'; // Add a last region for disabled blocks. - $block_regions_with_disabled = $this->regions + array(BLOCK_REGION_NONE => BLOCK_REGION_NONE); + $block_regions_with_disabled = $this->regions + array(BlockInterface::BLOCK_REGION_NONE => BlockInterface::BLOCK_REGION_NONE); $form['block_regions'] = array( '#type' => 'value', '#value' => $block_regions_with_disabled, @@ -219,7 +219,7 @@ public function buildForm(array $form, array &$form_state) { ), ); $form['blocks'][$region]['title'] = array( - '#markup' => $region != BLOCK_REGION_NONE ? $title : t('Disabled'), + '#markup' => $region != BlockInterface::BLOCK_REGION_NONE ? $title : t('Disabled'), '#wrapper_attributes' => array( 'colspan' => 5, ), @@ -263,7 +263,7 @@ public function buildForm(array $form, array &$form_state) { $form['blocks'][$entity_id]['region-theme']['region'] = array( '#type' => 'select', '#default_value' => $region, - '#empty_value' => BLOCK_REGION_NONE, + '#empty_value' => BlockInterface::BLOCK_REGION_NONE, '#title' => t('Region for @block block', array('@block' => $info['admin_label'])), '#title_display' => 'invisible', '#options' => $this->regions, @@ -404,7 +404,7 @@ public function submitForm(array &$form, array &$form_state) { foreach ($entities as $entity_id => $entity) { $entity->set('weight', $form_state['values']['blocks'][$entity_id]['weight']); $entity->set('region', $form_state['values']['blocks'][$entity_id]['region']); - if ($entity->get('region') == BLOCK_REGION_NONE) { + if ($entity->get('region') == BlockInterface::BLOCK_REGION_NONE) { $entity->disable(); } else { diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index 67d10e4..020b970 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -71,7 +71,7 @@ class Block extends ConfigEntityBase implements BlockInterface { * * @var string */ - protected $region = BLOCK_REGION_NONE; + protected $region = self::BLOCK_REGION_NONE; /** * The block weight. @@ -163,7 +163,7 @@ public static function sort($a, $b) { return $status; } // Sort by weight, unless disabled. - if ($a->get('region') != BLOCK_REGION_NONE) { + if ($a->get('region') != static::BLOCK_REGION_NONE) { $weight = $a->get('weight') - $b->get('weight'); if ($weight) { return $weight; diff --git a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php index e01c9f1..8394d03 100644 --- a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php @@ -10,11 +10,6 @@ use Drupal\block\BlockFormController; use Drupal\Tests\UnitTestCase; -// @todo Remove once the constants are replaced with constants on classes. -if (!defined('BLOCK_REGION_NONE')) { - define('BLOCK_REGION_NONE', -1); -} - /** * Tests the block form controller. * diff --git a/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php index 59b26f8..989a7ec 100644 --- a/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php @@ -26,7 +26,7 @@ public static function getInfo() { } public function setUp() { - $this->moduleList = array('block' => 'core/modules/block/block.info.yml'); + $this->moduleList = array('block' => 'core/modules/block/block.module'); parent::setUp(); $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( diff --git a/core/modules/book/tests/Drupal/book/Tests/Menu/BookLocalTasksTest.php b/core/modules/book/tests/Drupal/book/Tests/Menu/BookLocalTasksTest.php index 2f8d749..c1f1434 100644 --- a/core/modules/book/tests/Drupal/book/Tests/Menu/BookLocalTasksTest.php +++ b/core/modules/book/tests/Drupal/book/Tests/Menu/BookLocalTasksTest.php @@ -27,8 +27,8 @@ public static function getInfo() { public function setUp() { $this->moduleList = array( - 'book' => 'core/modules/book/book.info.yml', - 'node' => 'core/modules/node/node.info.yml', + 'book' => 'core/modules/book/book.module', + 'node' => 'core/modules/node/node.module', ); parent::setUp(); } diff --git a/core/modules/config/tests/Drupal/config/Tests/Menu/ConfigLocalTasksTest.php b/core/modules/config/tests/Drupal/config/Tests/Menu/ConfigLocalTasksTest.php index ad00f10..43640c5 100644 --- a/core/modules/config/tests/Drupal/config/Tests/Menu/ConfigLocalTasksTest.php +++ b/core/modules/config/tests/Drupal/config/Tests/Menu/ConfigLocalTasksTest.php @@ -26,7 +26,7 @@ public static function getInfo() { } public function setUp() { - $this->moduleList = array('config' => 'core/modules/config/config.info.yml'); + $this->moduleList = array('config' => 'core/modules/config/config.module'); parent::setUp(); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php index 558bdfd..f87ff77 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php @@ -120,15 +120,15 @@ public function alterLocalTasks(array &$local_tasks) { * Returns the local task ID of the parent task, otherwise return FALSE. */ protected function getTaskFromRoute($route_name, &$local_tasks) { - $local_task = FALSE; + $parent_local_task = FALSE; foreach ($local_tasks as $plugin_id => $local_task) { if ($local_task['route_name'] == $route_name) { - $local_task = $plugin_id; + $parent_local_task = $plugin_id; break; } } - return $local_task; + return $parent_local_task; } /** diff --git a/core/modules/content_translation/tests/Drupal/content_translation/Tests/Menu/ContentTranslationLocalTasksTest.php b/core/modules/content_translation/tests/Drupal/content_translation/Tests/Menu/ContentTranslationLocalTasksTest.php index cde6985..7b0c1c0 100644 --- a/core/modules/content_translation/tests/Drupal/content_translation/Tests/Menu/ContentTranslationLocalTasksTest.php +++ b/core/modules/content_translation/tests/Drupal/content_translation/Tests/Menu/ContentTranslationLocalTasksTest.php @@ -27,8 +27,8 @@ public static function getInfo() { public function setUp() { $this->moduleList = array( - 'content_translation' => 'core/modules/content_translation/content_translation.info.yml', - 'node' => 'core/modules/node/node.info.yml', + 'content_translation' => 'core/modules/content_translation/content_translation.module', + 'node' => 'core/modules/node/node.module', ); parent::setUp(); diff --git a/core/modules/language/tests/Drupal/language/Tests/Menu/LanguageLocalTasks.php b/core/modules/language/tests/Drupal/language/Tests/Menu/LanguageLocalTasks.php index 36ea469..cd3cd2f 100644 --- a/core/modules/language/tests/Drupal/language/Tests/Menu/LanguageLocalTasks.php +++ b/core/modules/language/tests/Drupal/language/Tests/Menu/LanguageLocalTasks.php @@ -27,7 +27,7 @@ public static function getInfo() { public function setUp() { $this->moduleList = array( - 'language' => 'core/modules/language/language.info.yml', + 'language' => 'core/modules/language/language.module', ); parent::setUp(); } diff --git a/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php b/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php index 4c18831..f8db54f 100644 --- a/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php +++ b/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php @@ -27,7 +27,7 @@ public static function getInfo() { public function setUp() { $this->moduleList = array( - 'locale' => 'core/modules/locale/locale.info.yml', + 'locale' => 'core/modules/locale/locale.module', ); parent::setUp(); } diff --git a/core/modules/shortcut/tests/Drupal/shortcut/Tests/Menu/ShortcutLocalTasksTest.php b/core/modules/shortcut/tests/Drupal/shortcut/Tests/Menu/ShortcutLocalTasksTest.php index ff8bd7e..edc5e8b 100644 --- a/core/modules/shortcut/tests/Drupal/shortcut/Tests/Menu/ShortcutLocalTasksTest.php +++ b/core/modules/shortcut/tests/Drupal/shortcut/Tests/Menu/ShortcutLocalTasksTest.php @@ -27,8 +27,8 @@ public static function getInfo() { public function setUp() { $this->moduleList = array( - 'shortcut' => 'core/modules/shortcut/shortcut.info.yml', - 'user' => 'core/modules/user/user.info.yml', + 'shortcut' => 'core/modules/shortcut/shortcut.module', + 'user' => 'core/modules/user/user.module', ); parent::setUp(); } diff --git a/core/modules/taxonomy/tests/Drupal/taxonomy/Tests/Menu/TaxonomyLocalTasksTest.php b/core/modules/taxonomy/tests/Drupal/taxonomy/Tests/Menu/TaxonomyLocalTasksTest.php index 6151cb2..52708a4 100644 --- a/core/modules/taxonomy/tests/Drupal/taxonomy/Tests/Menu/TaxonomyLocalTasksTest.php +++ b/core/modules/taxonomy/tests/Drupal/taxonomy/Tests/Menu/TaxonomyLocalTasksTest.php @@ -26,7 +26,7 @@ public static function getInfo() { } public function setUp() { - $this->moduleList = array('taxonomy' => 'core/modules/taxonomy/taxonomy.info.yml'); + $this->moduleList = array('taxonomy' => 'core/modules/taxonomy/taxonomy.module'); parent::setUp(); } diff --git a/core/modules/user/tests/Drupal/user/Tests/Menu/UserLocalTasksTest.php b/core/modules/user/tests/Drupal/user/Tests/Menu/UserLocalTasksTest.php index a978178..5fb9f40 100644 --- a/core/modules/user/tests/Drupal/user/Tests/Menu/UserLocalTasksTest.php +++ b/core/modules/user/tests/Drupal/user/Tests/Menu/UserLocalTasksTest.php @@ -26,7 +26,7 @@ public static function getInfo() { } public function setUp() { - $this->moduleList = array('user' => 'core/modules/user/user.info.yml'); + $this->moduleList = array('user' => 'core/modules/user/user.module'); parent::setUp(); }