abstract class DisplayBase

Base class for 'display' and 'unbound_display' configuration entities.

Hierarchy

Expanded class hierarchy of DisplayBase

See also

\Drupal\layout\Config\DisplayInterface

2 files declare their use of DisplayBase
Display.php in drupal/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/Display.php
Definition of Drupal\layout\Plugin\Core\Entity\Display.
UnboundDisplay.php in drupal/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/UnboundDisplay.php
Definition of Drupal\layout\Plugin\Core\Entity\Display.

File

drupal/core/modules/layout/lib/Drupal/layout/Config/DisplayBase.php, line 18
Definition of Drupal\layout\Config\DisplayBase.

Namespace

Drupal\layout\Config
View source
abstract class DisplayBase extends ConfigEntityBase implements DisplayInterface {

  /**
   * The ID (config name) identifying a specific display object.
   *
   * @var string
   */
  public $id;

  /**
   * The UUID identifying a specific display object.
   *
   * @var string
   */
  public $uuid;

  /**
   * Contains all block configuration.
   *
   * There are two levels to the configuration contained herein: display-level
   * block configuration, and then block instance configuration.
   *
   * Block instance configuration is stored in a separate config object. This
   * array is keyed by the config name that uniquely identifies each block
   * instance. At runtime, various object methods will retrieve this additional
   * config and return it to calling code.
   *
   * Display-level block configuration is data that determines the behavior of
   * a block *in this display*. The most important examples of this are the
   * region to which the block is assigned, and its weighting in that region.
   *
   * @code
   *    array(
   *      'block1-configkey' => array(
   *        'region' => 'content',
   *        // store the region type name here so that we can do type conversion w/out
   *        // needing to have access to the original layout plugin
   *        'region-type' => 'content',
   *        // increment by 100 so there is ALWAYS plenty of space for manual insertion
   *        'weight' => -100,
   *      ),
   *      'block2-configkey' => array(
   *        'region' => 'sidebar_first',
   *        'region-type' => 'aside',
   *        'weight' => -100,
   *      ),
   *      'block2-configkey' => array(
   *        'region' => 'sidebar_first',
   *        'region-type' => 'aside',
   *        'weight' => 0,
   *      ),
   *      'maincontent' => array(
   *        'region' => 'content',
   *        'region-type' => 'content',
   *        'weight' => -200,
   *      ),
   *    );
   * @endcode
   *
   * @var array
   */
  protected $blockInfo = array();

  /**
   * Implements DisplayInterface::getAllBlockInfo().
   */
  public function getAllBlockInfo() {
    return $this->blockInfo;
  }

  /**
   * Implements DisplayInterface::mapBlocksToLayout().
   *
   * @todo Decouple this implementation from this class, so that it could be
   *   more easily customized.
   */
  public function mapBlocksToLayout(LayoutInterface $layout) {
    $types = array();
    $layout_regions = $layout
      ->getRegions();
    $layout_regions_indexed = array_keys($layout_regions);
    foreach ($layout_regions as $name => $info) {
      $types[$info['type']][] = $name;
    }
    $remapped_config = array();
    foreach ($this->blockInfo as $name => $info) {

      // First, if there's a direct region name match, use that.
      if (!empty($info['region']) && isset($layout_regions[$info['region']])) {

        // No need to do anything.
      }
      else {
        if (!empty($types[$info['region-type']])) {
          $info['region'] = reset($types[$info['region-type']]);
        }
        else {
          if (!isset($first_region)) {
            reset($layout_regions);
            $first_region = key($layout_regions);
          }
          $info['region'] = $first_region;
        }
      }
      $remapped_config[$name] = $info;
    }
    return $remapped_config;
  }

  /**
   * Implements DisplayInterface::getAllRegionTypes().
   */
  public function getAllRegionTypes() {
    $types = array();
    foreach ($this->blockInfo as $info) {
      $types[] = $info['region-type'];
    }
    return array_unique($types);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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::get public function Overrides Entity::get(). Overrides Entity::get 2
ConfigEntityBase::getExportProperties public function Overrides \Drupal\Core\Entity\Entity::getExportProperties(). Overrides Entity::getExportProperties 9
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
ConfigEntityBase::__construct public function Overrides Entity::__construct(). Overrides Entity::__construct 9
DisplayBase::$blockInfo protected property Contains all block configuration.
DisplayBase::$id public property The ID (config name) identifying a specific display object.
DisplayBase::$uuid public property The UUID identifying a specific display object.
DisplayBase::getAllBlockInfo public function Implements DisplayInterface::getAllBlockInfo(). Overrides DisplayInterface::getAllBlockInfo
DisplayBase::getAllRegionTypes public function Implements DisplayInterface::getAllRegionTypes(). Overrides DisplayInterface::getAllRegionTypes
DisplayBase::mapBlocksToLayout public function Implements DisplayInterface::mapBlocksToLayout(). Overrides DisplayInterface::mapBlocksToLayout
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::label public function Implements \Drupal\Core\Entity\EntityInterface::label(). Overrides EntityInterface::label 4
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::uri public function Implements \Drupal\Core\Entity\EntityInterface::uri(). Overrides EntityInterface::uri 8
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