/** * Returns the valid creation date of a resource * * @param object $resource * @param array $matter * @param string $format * @return string */ public function getDate(Resource $resource, array $matter = array(), $format = 'Y-m-d') { $date = $resource->getCTime(); if (!empty($matter['date'])) { $date = $matter['date']; } elseif (preg_match('~^((\\d{4})-(\\d{1,2})-(\\d{1,2})(?:[-_]*))~', $resource->getFilename(), $m)) { $date = trim($m['0'], '-_ '); } if (ctype_digit($date)) { $date = date('Y-m-d H:i:s', $date); } $dateTime = new \DateTime($date); return $dateTime->format($format); }
/** * Checks if the resource needs to be recompiled * * @param object $resource * @param string $dst * @return bool */ protected function needToCompile(Resource $resource, $dst) { if (!$this->filesystem->exists($dst)) { return true; } $dstResource = new Resource($dst); return $resource->getCTime() > $dstResource->getCtime(); }