RainLab\Pages\Classes\PageList::updateStructure PHP Метод

updateStructure() публичный Метод

Updates the page hierarchy structure in the theme's meta/static-pages.yaml file.
public updateStructure ( array $structure )
$structure array A nested associative array representing the page structure
    public function updateStructure($structure)
    {
        $originalData = $this->getPagesConfig();
        $originalData['static-pages'] = $structure;
        $yamlData = Yaml::render($originalData);
        $filePath = $this->getConfigFilePath();
        $dirPath = dirname($filePath);
        if (!file_exists($dirPath) || !is_dir($dirPath)) {
            if (!File::makeDirectory($dirPath, 0777, true, true)) {
                throw new ApplicationException(Lang::get('cms::lang.cms_object.error_creating_directory', ['name' => $dirPath]));
            }
        }
        if (@File::put($filePath, $yamlData) === false) {
            throw new ApplicationException(Lang::get('cms::lang.cms_object.error_saving', ['name' => $filePath]));
        }
    }

Usage Example

Пример #1
0
 public function onReorder()
 {
     $structure = json_decode(Input::get('structure'), true);
     if (!$structure) {
         throw new SystemException('Invalid structure data posted.');
     }
     $pageList = new StaticPageList($this->theme);
     $pageList->updateStructure($structure);
 }