private function avoidRenderizer($extension, $relativePath) { $strPath = new StringWrapper($relativePath); foreach ($this->params['avoid_renderizer_path'] as $path) { if ($relativePath == $path || $strPath->startWith($path . '/') === true) { return true; } } if (in_array($extension, $this->params['avoid_renderizer_extension']) === true) { return true; } return false; }
public function testStartWith() { $str = new StringWrapper('Welcome to Spress'); $this->assertTrue($str->startWith('Wel')); $this->assertFalse($str->startWith('Well')); }
private function processAttributes(Item $item, SplFileInfo $file) { $attributes = []; $attributesFile = $this->getAttributesFilename($file); 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); } $attributes['mtime'] = $this->getModifiedTime($file); $attributes['filename'] = $file->getFilename(); $attributes['extension'] = $file->getExtension(); if ($data = $this->isDateFilename($file)) { $attributes['title_path'] = implode(' ', explode('-', $data[3])); if (isset($attributes['title']) === false) { $attributes['title'] = $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 ($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); }