public function SimpleConfigSectionStorage::save in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php \Drupal\layout_builder_test\Plugin\SectionStorage\SimpleConfigSectionStorage::save()
- 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php \Drupal\layout_builder_test\Plugin\SectionStorage\SimpleConfigSectionStorage::save()
Saves the sections.
Return value
int SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.
Overrides SectionStorageInterface::save
File
- core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Plugin/ SectionStorage/ SimpleConfigSectionStorage.php, line 123
Class
- SimpleConfigSectionStorage
- Provides section storage utilizing simple config.
Namespace
Drupal\layout_builder_test\Plugin\SectionStorageCode
public function save() {
$sections = array_map(function (Section $section) {
return $section
->toArray();
}, $this
->getSections());
$config = $this->configFactory
->getEditable($this
->getConfigName());
$return = $config
->get('sections') ? SAVED_UPDATED : SAVED_NEW;
$config
->set('sections', $sections)
->save();
return $return;
}