コード例 #1
0
ファイル: Layout.php プロジェクト: pensesmart/gantry5
 public function save()
 {
     $layout = $this->request->post->getJsonArray('layout');
     if (!isset($layout)) {
         throw new \RuntimeException('Error while saving layout: Structure missing', 400);
     }
     $configuration = $this->params['configuration'];
     $preset = $this->request->post->getJsonArray('preset');
     // Create layout from the data.
     $layout = new LayoutObject($configuration, LayoutReader::data(['preset' => $preset, 'children' => $layout]));
     // Save layout and its index.
     $layout->save()->saveIndex();
     // Fire save event.
     $event = new Event();
     $event->gantry = $this->container;
     $event->theme = $this->container['theme'];
     $event->controller = $this;
     $event->layout = $layout;
     $this->container->fireEvent('admin.layout.save', $event);
 }
コード例 #2
0
ファイル: Layout.php プロジェクト: JozefAB/neoacu
 /**
  * @param  string $name
  * @return static
  */
 public static function load($name)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $layout = null;
     $preset = null;
     $filename = $locator("gantry-config://{$name}/layout.yaml");
     // If layout file doesn't exists, figure out what preset was used.
     if (!$filename) {
         $index = static::loadIndex($name);
         $preset = $index['preset']['name'];
         try {
             $layout = static::preset($preset);
         } catch (\Exception $e) {
             // Layout doesn't exist, do nothing.
         }
     } else {
         $layout = LayoutReader::read($filename);
     }
     return new static($name, $layout);
 }