function FieldLayoutEntityDisplayTrait::setLayoutId
Same name in other branches
- 9 core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php \Drupal\field_layout\Entity\FieldLayoutEntityDisplayTrait::setLayoutId()
- 10 core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php \Drupal\field_layout\Entity\FieldLayoutEntityDisplayTrait::setLayoutId()
- 11.x core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php \Drupal\field_layout\Entity\FieldLayoutEntityDisplayTrait::setLayoutId()
Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayoutId().
2 calls to FieldLayoutEntityDisplayTrait::setLayoutId()
- FieldLayoutEntityDisplayTrait::ensureLayout in core/
modules/ field_layout/ src/ Entity/ FieldLayoutEntityDisplayTrait.php - FieldLayoutEntityDisplayTrait::setLayout in core/
modules/ field_layout/ src/ Entity/ FieldLayoutEntityDisplayTrait.php - Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayout().
File
-
core/
modules/ field_layout/ src/ Entity/ FieldLayoutEntityDisplayTrait.php, line 47
Class
- FieldLayoutEntityDisplayTrait
- Provides shared code for entity displays.
Namespace
Drupal\field_layout\EntityCode
public function setLayoutId($layout_id, array $layout_settings = []) {
if ($this->getLayoutId() !== $layout_id) {
// @todo Devise a mechanism for mapping old regions to new ones in
// https://www.drupal.org/node/2796877.
$layout_definition = $this->getLayoutDefinition($layout_id);
$new_region = $layout_definition->getDefaultRegion();
$layout_regions = $layout_definition->getRegions();
foreach ($this->getComponents() as $name => $component) {
if (isset($component['region']) && !isset($layout_regions[$component['region']])) {
$component['region'] = $new_region;
$this->setComponent($name, $component);
}
}
}
$this->setThirdPartySetting('field_layout', 'id', $layout_id);
// Instantiate the plugin and consult it for the updated plugin
// configuration. Once layouts are no longer stored as third party settings,
// this will be handled by the code in
// \Drupal\Core\Config\Entity\ConfigEntityBase::set() that handles
// \Drupal\Core\Entity\EntityWithPluginCollectionInterface.
$layout_settings = $this->doGetLayout($layout_id, $layout_settings)
->getConfiguration();
$this->setThirdPartySetting('field_layout', 'settings', $layout_settings);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.