class Block

Same name in this branch

Defines a Block configuration entity class.

Plugin annotation


@EntityType(
  id = "block",
  label = @Translation("Block"),
  module = "block",
  controllers = {
    "storage" = "Drupal\block\BlockStorageController",
    "access" = "Drupal\block\BlockAccessController",
    "render" = "Drupal\block\BlockRenderController",
    "list" = "Drupal\block\BlockListController",
    "form" = {
      "default" = "Drupal\block\BlockFormController"
    }
  },
  config_prefix = "block.block",
  fieldable = FALSE,
  entity_keys = {
    "id" = "id",
    "label" = "label",
    "uuid" = "uuid",
    "status" = "status"
  }
)

Hierarchy

Expanded class hierarchy of Block

7 files declare their use of Block
AdminBlockDeleteForm.php in drupal/core/modules/block/lib/Drupal/block/Form/AdminBlockDeleteForm.php
Contains \Drupal\block\Form\AdminBlockDeleteForm.
block.admin.inc in drupal/core/modules/block/block.admin.inc
Admin page callbacks for the block module.
BlockListController.php in drupal/core/modules/block/lib/Drupal/block/BlockListController.php
Contains \Drupal\block\BlockListController.
BlockPluginBag.php in drupal/core/modules/block/lib/Drupal/block/BlockPluginBag.php
Contains \Drupal\block\BlockPluginBag.
BlockStorageUnitTest.php in drupal/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
Contains \Drupal\block\Tests\BlockStorageUnitTest.

... See full list

32 string references to 'Block'
block.info.yml in drupal/core/modules/block/block.info.yml
drupal/core/modules/block/block.info.yml
block.schema.yml in drupal/core/modules/block/config/schema/block.schema.yml
drupal/core/modules/block/config/schema/block.schema.yml
BlockAdminThemeTest::getInfo in drupal/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php
BlockCacheTest::getInfo in drupal/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
BlockHiddenRegionTest::getInfo in drupal/core/modules/block/lib/Drupal/block/Tests/BlockHiddenRegionTest.php

... See full list

File

drupal/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php, line 42
Contains \Drupal\block\Plugin\Core\Entity\Block.

Namespace

Drupal\block\Plugin\Core\Entity
View source
class Block extends ConfigEntityBase implements BlockInterface {

  /**
   * The ID of the block.
   *
   * @var string
   */
  public $id;

  /**
   * The block UUID.
   *
   * @var string
   */
  public $uuid;

  /**
   * The plugin instance settings.
   *
   * @var array
   */
  protected $settings = array();

  /**
   * The region this block is placed in.
   *
   * @var string
   */
  protected $region = BLOCK_REGION_NONE;

  /**
   * The block weight.
   *
   * @var int
   */
  public $weight;

  /**
   * The plugin instance ID.
   *
   * @var string
   */
  protected $plugin;

  /**
   * The plugin bag that holds the block plugin for this entity.
   *
   * @var \Drupal\block\BlockPluginBag
   */
  protected $pluginBag;

  /**
   * The visibility settings.
   *
   * @var array
   */
  protected $visibility;

  /**
   * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::__construct();
   */
  public function __construct(array $values, $entity_type) {
    parent::__construct($values, $entity_type);
    $this->pluginBag = new BlockPluginBag(\Drupal::service('plugin.manager.block'), array(
      $this->plugin,
    ), $this);
  }

  /**
   * {@inheritdoc}
   */
  public function getPlugin() {
    return $this->pluginBag
      ->get($this->plugin);
  }

  /**
   * Overrides \Drupal\Core\Entity\Entity::uri();
   */
  public function uri() {
    return array(
      'path' => 'admin/structure/block/manage/' . $this
        ->id(),
      'options' => array(
        'entity_type' => $this->entityType,
        'entity' => $this,
      ),
    );
  }

  /**
   * Overrides \Drupal\Core\Entity\Entity::label();
   */
  public function label($langcode = NULL) {
    $settings = $this
      ->get('settings');
    return $settings['label'];
  }

  /**
   * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::get();
   */
  public function get($property_name, $langcode = NULL) {

    // The theme is stored in the entity ID.
    $value = parent::get($property_name, $langcode);
    if ($property_name == 'theme' && !$value) {
      list($value) = explode('.', $this
        ->id());
    }
    return $value;
  }

  /**
   * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties();
   */
  public function getExportProperties() {
    $properties = parent::getExportProperties();
    $names = array(
      'region',
      'weight',
      'plugin',
      'settings',
      'visibility',
    );
    foreach ($names as $name) {
      $properties[$name] = $this
        ->get($name);
    }
    return $properties;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Block::$id public property The ID of the block.
Block::$plugin protected property The plugin instance ID.
Block::$pluginBag protected property The plugin bag that holds the block plugin for this entity.
Block::$region protected property The region this block is placed in.
Block::$settings protected property The plugin instance settings.
Block::$uuid public property The block UUID.
Block::$visibility protected property The visibility settings.
Block::$weight public property The block weight.
Block::get public function Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::get(); Overrides ConfigEntityBase::get
Block::getExportProperties public function Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties(); Overrides ConfigEntityBase::getExportProperties
Block::getPlugin public function Returns the plugin instance. Overrides BlockInterface::getPlugin
Block::label public function Overrides \Drupal\Core\Entity\Entity::label(); Overrides Entity::label
Block::uri public function Overrides \Drupal\Core\Entity\Entity::uri(); Overrides Entity::uri
Block::__construct public function Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::__construct(); Overrides ConfigEntityBase::__construct
ConfigEntityBase::$originalID protected property The original ID of the configuration entity.
ConfigEntityBase::$status public property The enabled/disabled status of the configuration entity. 1
ConfigEntityBase::createDuplicate public function Overrides Entity::createDuplicate(). Overrides Entity::createDuplicate 2
ConfigEntityBase::disable public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::disable(). Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::enable(). Overrides ConfigEntityInterface::enable
ConfigEntityBase::getOriginalID public function Implements ConfigEntityInterface::getOriginalID(). Overrides ConfigEntityInterface::getOriginalID
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides Entity::isNew
ConfigEntityBase::set public function Overrides Entity::set(). Overrides Entity::set
ConfigEntityBase::setOriginalID public function Implements ConfigEntityInterface::setOriginalID(). Overrides ConfigEntityInterface::setOriginalID
ConfigEntityBase::setStatus public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::setStatus(). Overrides ConfigEntityInterface::setStatus
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 2
ConfigEntityBase::status public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::status(). Overrides ConfigEntityInterface::status 1
Entity::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
Entity::$entityType protected property The entity type.
Entity::$isDefaultRevision protected property Indicates whether this is the default revision. 1
Entity::$langcode public property The language code of the entity's default language. 7
Entity::$newRevision protected property Boolean indicating whether a new revision should be created on save.
Entity::access public function Implements \Drupal\Core\TypedData\AccessibleInterface::access(). Overrides AccessibleInterface::access
Entity::bundle public function Implements \Drupal\Core\Entity\EntityInterface::bundle(). Overrides EntityInterface::bundle 4
Entity::delete public function Implements \Drupal\Core\Entity\EntityInterface::delete(). Overrides EntityInterface::delete 3
Entity::enforceIsNew public function Implements \Drupal\Core\Entity\EntityInterface::enforceIsNew(). Overrides EntityInterface::enforceIsNew
Entity::entityInfo public function Implements \Drupal\Core\Entity\EntityInterface::entityInfo(). Overrides EntityInterface::entityInfo
Entity::entityType public function Implements \Drupal\Core\Entity\EntityInterface::entityType(). Overrides EntityInterface::entityType
Entity::getBCEntity public function Implements \Drupal\Core\Entity\EntityInterface::getBCEntity(). Overrides EntityInterface::getBCEntity 1
Entity::getConstraints public function Implements \Drupal\Core\TypedData\TypedDataInterface::getConstraints(). Overrides TypedDataInterface::getConstraints
Entity::getDefinition public function Implements \Drupal\Core\TypedData\TypedDataInterface::getDefinition(). Overrides TypedDataInterface::getDefinition
Entity::getIterator public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getIterator(). 1
Entity::getName public function Implements \Drupal\Core\TypedData\TypedDataInterface::getName(). Overrides TypedDataInterface::getName
Entity::getNGEntity public function Implements \Drupal\Core\Entity\EntityInterface::getNGEntity(). Overrides EntityInterface::getNGEntity
Entity::getParent public function Implements \Drupal\Core\TypedData\TypedDataInterface::getParent(). Overrides TypedDataInterface::getParent
Entity::getProperties public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getProperties(). Overrides ComplexDataInterface::getProperties 1
Entity::getPropertyDefinition public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinition(). Overrides ComplexDataInterface::getPropertyDefinition 1
Entity::getPropertyDefinitions public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). Overrides ComplexDataInterface::getPropertyDefinitions 1
Entity::getPropertyPath public function Implements \Drupal\Core\TypedData\TypedDataInterface::getPropertyPath(). Overrides TypedDataInterface::getPropertyPath
Entity::getPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyValues(). Overrides ComplexDataInterface::getPropertyValues 1
Entity::getRevisionId public function Implements \Drupal\Core\Entity\EntityInterface::getRevisionId(). Overrides EntityInterface::getRevisionId 4
Entity::getRoot public function Implements \Drupal\Core\TypedData\TypedDataInterface::getRoot(). Overrides TypedDataInterface::getRoot
Entity::getString public function Implements \Drupal\Core\TypedData\TypedDataInterface::getString(). Overrides TypedDataInterface::getString
Entity::getTranslation public function Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslation(). Overrides TranslatableInterface::getTranslation 1
Entity::getTranslationLanguages public function Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslationLanguages(). Overrides TranslatableInterface::getTranslationLanguages 1
Entity::getType public function Implements \Drupal\Core\TypedData\TypedDataInterface::getType(). Overrides TypedDataInterface::getType 2
Entity::getValue public function Implements \Drupal\Core\TypedData\TypedDataInterface::getValue(). Overrides TypedDataInterface::getValue
Entity::id public function Implements \Drupal\Core\Entity\EntityInterface::id(). Overrides EntityInterface::id 11
Entity::isDefaultRevision public function Implements \Drupal\Core\Entity\EntityInterface::isDefaultRevision(). Overrides EntityInterface::isDefaultRevision 1
Entity::isEmpty public function Implements \Drupal\Core\TypedData\ComplexDataInterface::isEmpty(). Overrides ComplexDataInterface::isEmpty 1
Entity::isNewRevision public function Implements \Drupal\Core\Entity\EntityInterface::isNewRevision(). Overrides EntityInterface::isNewRevision
Entity::isTranslatable public function Implements \Drupal\Core\Entity\EntityInterface::isTranslatable(). Overrides EntityInterface::isTranslatable
Entity::language public function Implements \Drupal\Core\TypedData\TranslatableInterface::language(). Overrides TranslatableInterface::language 1
Entity::onChange public function Implements \Drupal\Core\TypedData\ComplexDataInterface::onChange(). Overrides ComplexDataInterface::onChange
Entity::save public function Implements \Drupal\Core\Entity\EntityInterface::save(). Overrides EntityInterface::save 6
Entity::setContext public function Implements \Drupal\Core\TypedData\TypedDataInterface::setContext(). Overrides TypedDataInterface::setContext
Entity::setNewRevision public function Implements \Drupal\Core\Entity\EntityInterface::setNewRevision(). Overrides EntityInterface::setNewRevision
Entity::setPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::setPropertyValues(). Overrides ComplexDataInterface::setPropertyValues 1
Entity::setValue public function Implements \Drupal\Core\TypedData\TypedDataInterface::setValue(). Overrides TypedDataInterface::setValue
Entity::translations public function Returns the languages the entity is translated to. 1
Entity::uriRelationships public function Returns a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
Entity::uuid public function Implements \Drupal\Core\Entity\EntityInterface::uuid(). Overrides EntityInterface::uuid 1
Entity::validate public function Implements \Drupal\Core\TypedData\TypedDataInterface::validate(). Overrides TypedDataInterface::validate 1