Todaymade\Daux\Tree\Builder::createContent PHP Метод

createContent() публичный статический Метод

public static createContent ( Directory $parent, SplFileInfo $file ) : Todaymade\Daux\Tree\Content | Raw
$parent Directory
$file SplFileInfo
Результат Todaymade\Daux\Tree\Content | Raw
    public static function createContent(Directory $parent, SplFileInfo $file)
    {
        $name = static::getName($file->getPathname());
        $config = $parent->getConfig();
        if (!in_array($file->getExtension(), $config['valid_content_extensions'])) {
            $uri = static::removeSortingInformations($file->getFilename());
            $entry = new Raw($parent, $uri, $file);
            $entry->setTitle(str_replace('_', ' ', static::removeSortingInformations($name)));
            $entry->setName($name);
            return $entry;
        }
        $uri = static::removeSortingInformations($name);
        if ($config->isStatic()) {
            $uri .= '.html';
        }
        $entry = new Content($parent, $uri, $file);
        if ($entry->getUri() == $config['index_key']) {
            if ($parent instanceof Root) {
                $entry->setTitle($config['title']);
            } else {
                $entry->setTitle($parent->getTitle());
            }
        } else {
            $entry->setTitle(str_replace('_', ' ', static::removeSortingInformations($name)));
        }
        $entry->setName($name);
        return $entry;
    }