Todaymade\Daux\Tree\Directory::getConfig PHP Method

getConfig() public method

public getConfig ( ) : Config
return Todaymade\Daux\Config
    public function getConfig()
    {
        if (!$this->parent) {
            throw new \RuntimeException('Could not retrieve configuration. Are you sure that your tree has a Root ?');
        }
        return $this->parent->getConfig();
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param Directory $parent
  * @param string $path
  * @return ContentAbstract
  */
 public static function getOrCreatePage(Directory $parent, $path)
 {
     $extension = pathinfo($path, PATHINFO_EXTENSION);
     // If the file doesn't have an extension, set .md as a default
     if ($extension == '') {
         $extension = 'md';
         $path .= '.md';
     }
     $raw = !in_array($extension, $parent->getConfig()['valid_content_extensions']);
     $title = $uri = $path;
     if (!$raw) {
         $title = static::getName($path);
         $uri = DauxHelper::slug($title);
         if ($parent->getConfig()->isStatic()) {
             $uri .= '.html';
         }
     }
     if (array_key_exists($uri, $parent->getEntries())) {
         return $parent->getEntries()[$uri];
     }
     $page = $raw ? new ComputedRaw($parent, $uri) : new Content($parent, $uri);
     $page->setContent('-');
     //set an almost empty content to avoid problems
     $page->setName($path);
     $page->setTitle($title);
     if ($title == 'index' || $title == '_index') {
         $page->setTitle($parent->getTitle());
     }
     return $page;
 }
All Usage Examples Of Todaymade\Daux\Tree\Directory::getConfig