By phenaproxima on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.7.x
Introduced in version:
8.7.0
Issue links:
Description:
As of #2942661: Sections should have third-party settings, it is possible for layout sections to have arbitrary third-party settings attached to them. These settings are treated exactly the same way as third-party settings on config entities, and can be manipulated with the methods defined in Drupal\Core\Config\Entity\ThirdPartySettingsInterface.
For example, assuming Layout Builder is enabled, and the "Full content" node display has layout enabled and at least one layout section, you can do this:
<?php
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
$section = LayoutBuilderEntityViewDisplay::load('node.page.full')->getSection(0);
$setting = $section->getThirdPartySetting('my_module', 'my_setting');
$section->setThirdPartySetting('my_module', 'my_setting', 'some value');
$section->unsetThirdPartySetting('my_module', 'some_dead_setting');
The third party settings will be preserved when the section is converted to an array (for example, when exporting layout configuration).
Impacts:
Module developers
Comments
For within Forms, use: getCurrentSection()
For within Forms, use: getCurrentSection()
e.g. instead of:
use