/**
  * @param int|string $id
  * @return Layout
  */
 public function layoutPreset($id)
 {
     $layout = Layout::load($id);
     $preset = $layout->preset;
     unset($layout);
     return $preset;
 }
 public function onLayoutSave(Event $event)
 {
     $gantry = Gantry::instance();
     /** @var Configurations $configurations */
     $configurations = $gantry['configurations'];
     $list = [];
     foreach ($configurations as $name => $title) {
         $list += Layout::instance($name)->positions();
     }
     $manifest = new Manifest($gantry['theme.name']);
     $manifest->setPositions(array_keys($list));
     $manifest->save();
 }
Exemple #3
0
 /**
  * Load current layout and its configuration.
  *
  * @param string $name
  * @return Layout
  * @throws \LogicException
  */
 public function loadLayout($name = null)
 {
     if (!$name) {
         try {
             $name = static::gantry()['configuration'];
         } catch (\Exception $e) {
             throw new \LogicException('Gantry: Configuration has not been defined yet', 500);
         }
     }
     $layout = Layout::instance($name);
     if (!$layout->exists()) {
         $layout = Layout::instance('default');
     }
     return $layout;
 }
Exemple #4
0
 protected function getDeprecatedAtoms()
 {
     $id = $this->params['configuration'];
     $layout = Layout::instance($id);
     return $layout->atoms();
 }
Exemple #5
0
 /**
  * Load current layout and its configuration.
  *
  * @param string $name
  * @return Layout
  * @throws \LogicException
  */
 public function loadLayout($name = null)
 {
     if (!$name) {
         try {
             $name = static::gantry()['configuration'];
         } catch (\Exception $e) {
             throw new \LogicException('Gantry: Outline has not been defined yet', 500);
         }
     }
     if (!isset($this->layoutObject) || $this->layoutObject->name != $name) {
         $layout = Layout::instance($name);
         if (!$layout->exists()) {
             $layout = Layout::instance('default');
         }
         $this->layoutObject = $layout;
     }
     return $this->layoutObject;
 }
Exemple #6
0
 /**
  * @param string $name
  * @return LayoutObject
  */
 protected function getLayout($name)
 {
     return LayoutObject::instance($name);
 }
Exemple #7
0
 /**
  * @param string $title
  * @param string $preset
  * @return string
  * @throws \RuntimeException
  */
 public function create($title = 'Untitled', $preset = 'default')
 {
     $gantry = $this->container;
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $name = strtolower(preg_replace('|[^a-z\\d_-]|ui', '_', $title));
     if (!$name) {
         throw new \RuntimeException("Outline needs a name", 400);
     }
     if ($name === 'default' || $name[0] === '_') {
         throw new \RuntimeException("Outline cannot use reserved name '{$name}'", 400);
     }
     $name = $this->findFreeName($name);
     // Create index file for the new layout.
     $layout = new Layout($name, Layout::preset($preset));
     $layout->saveIndex();
     return $name;
 }
Exemple #8
0
 /**
  * @param string $title
  * @param string $preset
  * @return string
  * @throws \RuntimeException
  */
 public function create($title = 'Untitled', $preset = 'default')
 {
     $name = strtolower(preg_replace('|[^a-z\\d_-]|ui', '_', $title));
     if (!$name) {
         throw new \RuntimeException("Outline needs a name", 400);
     }
     if ($name === 'default' || $name[0] === '_') {
         throw new \RuntimeException("Outline cannot use reserved name '{$name}'", 400);
     }
     $name = $this->findFreeName($name);
     // Load preset.
     $preset = Layout::preset($preset);
     // Create index file for the new layout.
     $layout = new Layout($name, $preset);
     $layout->saveIndex();
     return $name;
 }