/** * @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(); }
/** * 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; }
protected function getDeprecatedAtoms() { $id = $this->params['configuration']; $layout = Layout::instance($id); return $layout->atoms(); }
/** * 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; }
/** * @param string $name * @return LayoutObject */ protected function getLayout($name) { return LayoutObject::instance($name); }
/** * @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; }
/** * @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; }