Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
 }