/** * Saves the object to the disk. */ public function save() { if ($this->itemData !== false) { $this->items = MenuItem::initFromArray($this->itemData); } $contentData = ['name' => $this->name, 'items' => $this->itemData ? $this->itemData : []]; $dumper = new YamlDumper(); $this->content = $dumper->dump($contentData, 20, 0, false, true); return parent::save(); }
/** * Saves the object to the disk. */ public function save() { $this->code = trim($this->code); $this->markup = trim($this->markup); $trim = function (&$values) use(&$trim) { foreach ($values as &$value) { if (!is_array($value)) { $value = trim($value); } else { $trim($value); } } }; $trim($this->settings); if (array_key_exists('components', $this->settings) && count($this->settings['components']) == 0) { unset($this->settings['components']); } $this->validate(); $content = []; if ($this->settings) { $content[] = FileHelper::formatIniString($this->settings); } if ($this->code) { if ($this->wrapCodeToPhpTags() && array_get($this->originalData, 'code') != $this->code) { $code = preg_replace('/^\\<\\?php/', '', $this->code); $code = preg_replace('/^\\<\\?/', '', $code); $code = preg_replace('/\\?>$/', '', $code); $content[] = '<?php' . PHP_EOL . $this->code . PHP_EOL . '?>'; } else { $content[] = $this->code; } } $content[] = $this->markup; $this->content = trim(implode(PHP_EOL . '==' . PHP_EOL, $content)); parent::save(); }
/** * Saves the object to the disk. */ public function save() { $this->code = trim($this->code); $this->markup = trim($this->markup); $trim = function (&$values) use(&$trim) { foreach ($values as &$value) { if (!is_array($value)) { $value = trim($value); } else { $trim($value); } } }; $trim($this->settings); $this->validate(); $content = []; if ($this->settings) { $content[] = FileHelper::formatIniString($this->settings); } if ($this->code) { $code = preg_replace('/^\\<\\?php/', '', $this->code); $code = preg_replace('/^\\<\\?/', '', $code); $code = preg_replace('/\\?>$/', '', $code); $content[] = '<?php' . PHP_EOL . $this->code . PHP_EOL . '?>'; } $content[] = $this->markup; $this->content = trim(implode(PHP_EOL . '==' . PHP_EOL, $content)); parent::save(); }