Base class for 'display' and 'unbound_display' configuration entities.
Expanded class hierarchy of DisplayBase
\Drupal\layout\Config\DisplayInterface
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);
}
}
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigEntityBase:: |
protected | property | The original ID of the configuration entity. | |
ConfigEntityBase:: |
public | function |
Overrides Entity::createDuplicate(). Overrides Entity:: |
1 |
ConfigEntityBase:: |
public | function |
Overrides Entity::get(). Overrides Entity:: |
1 |
ConfigEntityBase:: |
public | function |
Implements ConfigEntityInterface::getOriginalID(). Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
final public | function |
Overrides Entity::isNew(). Overrides Entity:: |
|
ConfigEntityBase:: |
public | function |
Overrides Entity::set(). Overrides Entity:: |
|
ConfigEntityBase:: |
public | function |
Implements ConfigEntityInterface::setOriginalID(). Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public static | function | Helper callback for uasort() to sort configuration entities by weight and label. | |
ConfigEntityBase:: |
public | function |
Overrides Entity::__construct(). Overrides Entity:: |
2 |
DisplayBase:: |
protected | property | Contains all block configuration. | |
DisplayBase:: |
public | property | The ID (config name) identifying a specific display object. | |
DisplayBase:: |
public | property | The UUID identifying a specific display object. | |
DisplayBase:: |
public | function |
Implements DisplayInterface::getAllBlockInfo(). Overrides DisplayInterface:: |
|
DisplayBase:: |
public | function |
Implements DisplayInterface::getAllRegionTypes(). Overrides DisplayInterface:: |
|
DisplayBase:: |
public | function |
Implements DisplayInterface::mapBlocksToLayout(). Overrides DisplayInterface:: |
|
Entity:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
Entity:: |
protected | property | The entity type. | |
Entity:: |
protected | property | Indicates whether this is the default revision. | 1 |
Entity:: |
public | property | The language code of the entity's default language. | 4 |
Entity:: |
protected | property | Boolean indicating whether a new revision should be created on save. | |
Entity:: |
public | function |
Implements AccessibleInterface::access(). Overrides AccessibleInterface:: |
|
Entity:: |
public | function |
Implements EntityInterface::bundle(). Overrides EntityInterface:: |
4 |
Entity:: |
public | function |
Implements EntityInterface::delete(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Implements EntityInterface::enforceIsNew(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Implements EntityInterface::entityInfo(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Implements EntityInterface::entityType(). Overrides EntityInterface:: |
|
Entity:: |
public | function | Implements ComplexDataInterface::getIterator(). | 1 |
Entity:: |
public | function |
Implements ComplexDataInterface::getProperties(). Overrides ComplexDataInterface:: |
1 |
Entity:: |
public | function |
Implements ComplexDataInterface::getPropertyDefinition(). Overrides ComplexDataInterface:: |
1 |
Entity:: |
public | function |
Implements ComplexDataInterface::getPropertyDefinitions(). Overrides ComplexDataInterface:: |
1 |
Entity:: |
public | function |
Implements ComplexDataInterface::getPropertyValues(). Overrides ComplexDataInterface:: |
1 |
Entity:: |
public | function |
Implements Drupal\Core\Entity\EntityInterface::getRevisionId(). Overrides EntityInterface:: |
3 |
Entity:: |
public | function |
Implements TranslatableInterface::getTranslation(). Overrides TranslatableInterface:: |
1 |
Entity:: |
public | function |
Implements TranslatableInterface::getTranslationLanguages(). Overrides TranslatableInterface:: |
1 |
Entity:: |
public | function |
Implements EntityInterface::id(). Overrides EntityInterface:: |
10 |
Entity:: |
public | function |
Implements Drupal\Core\Entity\EntityInterface::isDefaultRevision(). Overrides EntityInterface:: |
1 |
Entity:: |
public | function |
Implements ComplexDataInterface::isEmpty(). Overrides ComplexDataInterface:: |
1 |
Entity:: |
public | function |
Implements EntityInterface::isNewRevision(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Implements EntityInterface::label(). Overrides EntityInterface:: |
1 |
Entity:: |
public | function |
Implements TranslatableInterface::language(). Overrides TranslatableInterface:: |
1 |
Entity:: |
public | function |
Implements EntityInterface::save(). Overrides EntityInterface:: |
3 |
Entity:: |
public | function |
Implements EntityInterface::setNewRevision(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Implements ComplexDataInterface::setPropertyValues(). Overrides ComplexDataInterface:: |
1 |
Entity:: |
public | function | Returns the languages the entity is translated to. | |
Entity:: |
public | function |
Implements EntityInterface::uri(). Overrides EntityInterface:: |
1 |
Entity:: |
public | function |
Implements EntityInterface::uuid(). Overrides EntityInterface:: |
1 |