Issue #2029677 by afeijo: Convert BLOCK_LABEL_VISIBLE to a constant on the block interface.

8.0.x
Alex Pott 2013-07-10 17:18:32 +01:00
parent 9306022ca0
commit e29aaabd2e
5 changed files with 13 additions and 9 deletions

View File

@ -43,10 +43,6 @@ const BLOCK_VISIBILITY_LISTED = 1;
*/ */
const BLOCK_VISIBILITY_PHP = 2; const BLOCK_VISIBILITY_PHP = 2;
/**
* Indicates the block label (title) should be displayed to end users.
*/
const BLOCK_LABEL_VISIBLE = 'visible';
/** /**
* Implements hook_help(). * Implements hook_help().

View File

@ -8,6 +8,7 @@
namespace Drupal\block; namespace Drupal\block;
use Drupal\Component\Plugin\PluginBase; use Drupal\Component\Plugin\PluginBase;
use Drupal\block\BlockInterface;
/** /**
* Defines a base block implementation that most blocks plugins will extend. * 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( $this->configuration += $this->settings() + array(
'label' => '', 'label' => '',
'module' => $plugin_definition['module'], 'module' => $plugin_definition['module'],
'label_display' => BLOCK_LABEL_VISIBLE, 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
'cache' => DRUPAL_NO_CACHE, 'cache' => DRUPAL_NO_CACHE,
); );
} }
@ -127,8 +128,8 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface {
$form['label_display'] = array( $form['label_display'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Display title'), '#title' => t('Display title'),
'#default_value' => $this->configuration['label_display'] == BLOCK_LABEL_VISIBLE, '#default_value' => $this->configuration['label_display'] == BlockInterface::BLOCK_LABEL_VISIBLE,
'#return_value' => BLOCK_LABEL_VISIBLE, '#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE,
); );
// Add plugin-specific settings for this block type. // Add plugin-specific settings for this block type.

View File

@ -14,6 +14,11 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
*/ */
interface BlockInterface extends 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. * Returns the plugin instance.
* *

View File

@ -8,6 +8,7 @@
namespace Drupal\block\Tests; namespace Drupal\block\Tests;
use Drupal\simpletest\DrupalUnitTestBase; use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\block\BlockInterface;
/** /**
* Test BlockInterface methods to ensure no external dependencies exist. * Test BlockInterface methods to ensure no external dependencies exist.
@ -46,7 +47,7 @@ class BlockInterfaceTest extends DrupalUnitTestBase {
'label' => 'Custom Display Message', 'label' => 'Custom Display Message',
'display_message' => 'no message set', 'display_message' => 'no message set',
'module' => 'block_test', 'module' => 'block_test',
'label_display' => BLOCK_LABEL_VISIBLE, 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
'cache' => DRUPAL_NO_CACHE, 'cache' => DRUPAL_NO_CACHE,
); );
// Initial configuration of the block at construction time. // Initial configuration of the block at construction time.

View File

@ -14,6 +14,7 @@ use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\block\BlockStorageController; use Drupal\block\BlockStorageController;
use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityMalformedException;
use Drupal\block\Plugin\Core\Entity\Block; use Drupal\block\Plugin\Core\Entity\Block;
use Drupal\block\BlockInterface;
/** /**
* Tests the storage of blocks. * Tests the storage of blocks.
@ -103,7 +104,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
'cache' => '1', 'cache' => '1',
'label' => '', 'label' => '',
'module' => 'block_test', 'module' => 'block_test',
'label_display' => BLOCK_LABEL_VISIBLE, 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
), ),
'visibility' => '', 'visibility' => '',
); );