Yosymfony\Spress\Core\DataSource\Filesystem\FilesystemDataSource::processAttributes PHP Method

processAttributes() private method

private processAttributes ( Item $item, Symfony\Component\Finder\SplFileInfo $file )
$item Yosymfony\Spress\Core\DataSource\Item
$file Symfony\Component\Finder\SplFileInfo
    private function processAttributes(Item $item, SplFileInfo $file)
    {
        $attributes = [];
        $attributesFile = $this->getAttributesFilename($file);
        $isItemType = $item->getType() === Item::TYPE_ITEM;
        if ($attributesFile && file_exists($attributesFile)) {
            $contentFile = file_get_contents($attributesFile);
            $attributes = $this->attributeParser->getAttributesFromString($contentFile);
        } elseif (false === $item->isBinary()) {
            $attributes = $this->attributeParser->getAttributesFromFrontmatter($item->getContent());
            $content = $this->attributeParser->getContentFromFrontmatter($item->getContent());
            $item->setContent($content, Item::SNAPSHOT_RAW);
        }
        $fileInfo = new FileInfo($file->getPathname(), $this->params['text_extensions']);
        $avoidRender = $this->avoidRenderizer($fileInfo->getExtension(), $file->getRelativePath());
        if ($isItemType && $avoidRender === true && isset($attributes['avoid_renderizer']) === false) {
            $attributes['avoid_renderizer'] = true;
        }
        $attributes['mtime'] = $this->getModifiedTime($file);
        $attributes['filename'] = $fileInfo->getFilename();
        $attributes['extension'] = $fileInfo->getExtension();
        if ($data = $this->isDateFilename($attributes['filename'])) {
            $attributes['title_path'] = $data[3];
            if (isset($attributes['title']) === false) {
                $attributes['title'] = implode(' ', explode('-', $attributes['title_path']));
            }
            if (isset($attributes['date']) === false) {
                $attributes['date'] = implode('-', [$data[0], $data[1], $data[2]]);
            }
        }
        $str = new StringWrapper($this->normalizeDirSeparator($file->getRelativePath()));
        if ($isItemType && $str->startWith('posts/') === true && array_key_exists('categories', $attributes) === false) {
            $categories = explode('/', $str->deletePrefix('posts/'));
            if ($categories[0] === '') {
                unset($categories[0]);
            }
            $attributes['categories'] = $categories;
        }
        $item->setAttributes($attributes);
    }