How to update a component in the node’s layout builder? I have used the following code.
$node = DrupalnodeEntityNode::load($nid);
$layout = $node->get('layout_builder__layout');
$sections = $layout->getSections();
foreach ($sections as $key => $section) {
$components = $section->getComponents();
foreach ($components as $component) {
if ($component instanceof SectionComponent && $component->getPluginId() === 'myplugin_id') {
$configurations = $component->get('configuration');
$configurations('label_display') = "0";
$component->setConfiguration($configurations);
}
}
}
But now I don’t know how to update the section and layout of the node.
Because $section->setComponent($component)
is a protected method.