From e29aaabd2eb5ffeaa3b33f33ae0eef865a0b18ea Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 10 Jul 2013 17:18:32 +0100 Subject: [PATCH] Issue #2029677 by afeijo: Convert BLOCK_LABEL_VISIBLE to a constant on the block interface. --- core/modules/block/block.module | 4 ---- core/modules/block/lib/Drupal/block/BlockBase.php | 7 ++++--- core/modules/block/lib/Drupal/block/BlockInterface.php | 5 +++++ .../block/lib/Drupal/block/Tests/BlockInterfaceTest.php | 3 ++- .../block/lib/Drupal/block/Tests/BlockStorageUnitTest.php | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 321f584e5a7d..8683ed565456 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -43,10 +43,6 @@ const BLOCK_VISIBILITY_LISTED = 1; */ const BLOCK_VISIBILITY_PHP = 2; -/** - * Indicates the block label (title) should be displayed to end users. - */ -const BLOCK_LABEL_VISIBLE = 'visible'; /** * Implements hook_help(). diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 6efda890179a..b438dc1c3338 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -8,6 +8,7 @@ namespace Drupal\block; use Drupal\Component\Plugin\PluginBase; +use Drupal\block\BlockInterface; /** * Defines a base block implementation that most blocks plugins will extend. @@ -27,7 +28,7 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface { $this->configuration += $this->settings() + array( 'label' => '', 'module' => $plugin_definition['module'], - 'label_display' => BLOCK_LABEL_VISIBLE, + 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, 'cache' => DRUPAL_NO_CACHE, ); } @@ -127,8 +128,8 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface { $form['label_display'] = array( '#type' => 'checkbox', '#title' => t('Display title'), - '#default_value' => $this->configuration['label_display'] == BLOCK_LABEL_VISIBLE, - '#return_value' => BLOCK_LABEL_VISIBLE, + '#default_value' => $this->configuration['label_display'] == BlockInterface::BLOCK_LABEL_VISIBLE, + '#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE, ); // Add plugin-specific settings for this block type. diff --git a/core/modules/block/lib/Drupal/block/BlockInterface.php b/core/modules/block/lib/Drupal/block/BlockInterface.php index cf049a538a5c..d06f708ef4f1 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -14,6 +14,11 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; */ interface BlockInterface extends ConfigEntityInterface { + /** + * Indicates the block label (title) should be displayed to end users. + */ + const BLOCK_LABEL_VISIBLE = 'visible'; + /** * Returns the plugin instance. * diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php index cd070df91540..327cf454c7cf 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php @@ -8,6 +8,7 @@ namespace Drupal\block\Tests; use Drupal\simpletest\DrupalUnitTestBase; +use Drupal\block\BlockInterface; /** * Test BlockInterface methods to ensure no external dependencies exist. @@ -46,7 +47,7 @@ class BlockInterfaceTest extends DrupalUnitTestBase { 'label' => 'Custom Display Message', 'display_message' => 'no message set', 'module' => 'block_test', - 'label_display' => BLOCK_LABEL_VISIBLE, + 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, 'cache' => DRUPAL_NO_CACHE, ); // Initial configuration of the block at construction time. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index b14ae0e69e31..41b5f4d1ed23 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -14,6 +14,7 @@ use Drupal\Component\Plugin\Exception\PluginException; use Drupal\block\BlockStorageController; use Drupal\Core\Entity\EntityMalformedException; use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\block\BlockInterface; /** * Tests the storage of blocks. @@ -103,7 +104,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase { 'cache' => '1', 'label' => '', 'module' => 'block_test', - 'label_display' => BLOCK_LABEL_VISIBLE, + 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, ), 'visibility' => '', );