public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get Category $this->category = $this->getCategory(); // Set tags $this->tags = $this->getHumanTags(); $this->tag_class = $this->getTagClassNames(); // Set date if ($this->has('date')) { $this->date = new Carbon($this->get('date'), date_default_timezone_get()); } else { $this->date = Carbon::createFromTimestamp($file->getMTime()); } // Set excerpt if ($this->has('excerpt')) { $this->excerpt = $this->get('excerpt'); } else { $this->excerpt = $this->getExcerpt($this->content); } // Set author $this->author = $this->get('author', $this->author); // Set Images if ($this->has('image')) { $fileinfo = pathinfo($this->get('image')); $template = $this->builder->getUrl("{$fileinfo['dirname']}/{$fileinfo['filename']}-%SIZE%.{$fileinfo['extension']}"); $this->image = ['full' => $this->builder->getUrl($this->get('image')), 'medium' => str_replace('%SIZE%', 'medium', $template), 'thumb' => str_replace('%SIZE%', 'thumb', $template)]; } // Remove content HTML comments $this->content = preg_replace('/<!--(.*)-->/Uis', '', $this->content); }
public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get Category $this->category = $this->getCategory(); // Set chapter $this->chapter = $this->get('chapter'); // Set date if ($this->has('date')) { $this->date = strtotime($this->get('date')); } else { $this->date = $file->getMTime(); } }
public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get date file was last modified $this->date = $file->getMTime(); }