/** * Write down contents to a temporary file and return its absolute path * * @param string $relativePath * @param string $contents * @return string */ public function createFile($relativePath, $contents) { $filePath = $this->config->getLessMaterializationRelativePath() . '/' . $relativePath; if (!$this->tmpDirectory->isExist($filePath)) { $this->tmpDirectory->writeFile($filePath, $contents); } return $this->tmpDirectory->getAbsolutePath($filePath); }
/** * Check whether generation process has already locked * * @return bool */ protected function isProcessLocked() { $lockFilePath = $this->config->getLessMaterializationRelativePath() . '/' . self::LOCK_FILE; if ($this->tmpDirectory->isExist($lockFilePath)) { $lockTime = time() - (int) $this->tmpDirectory->readFile($lockFilePath); if ($lockTime >= self::MAX_LOCK_TIME) { $this->tmpDirectory->delete($lockFilePath); return false; } return true; } return false; }