function NavigationSectionStorage::save

Same name in other branches
  1. 11.x core/modules/navigation/src/Plugin/SectionStorage/NavigationSectionStorage.php \Drupal\navigation\Plugin\SectionStorage\NavigationSectionStorage::save()

Overrides SectionStorageInterface::save

File

core/modules/navigation/src/Plugin/SectionStorage/NavigationSectionStorage.php, line 133

Class

NavigationSectionStorage
Provides navigation section storage.

Namespace

Drupal\navigation\Plugin\SectionStorage

Code

public function save() : int {
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.