public function request($requestName, $type, $chmod = null, $index = null) { $fileInstance = new File($requestName); if ($fileInstance->doesExist()) { return true; } if ($type == self::TYPE_DIRECTORY) { if ($fileInstance->createNewDirectory($chmod)) { $this->logger->i("{$requestName} created (folder)"); } else { $this->logger->e("error, something went wrong {$requestName} (folder)"); } } elseif ($type == self::TYPE_FILE) { if ($fileInstance->createNewFile()) { $this->logger->i("{$requestName} created (file)"); if ($index != null && $fileInstane->isWritable()) { $fileInstance->putIndex($index); } } else { $this->logger->e("error something went wrong {$requestName} (file)"); } } else { $this->logger->e("the type you defined is not known {$type}"); } }
function makeCache($cacheFilename, $content) { $cacheFile = new File($this->cacheDirectory . "/" . $cacheFilename); if ($cacheFile->doesExist()) { return false; } $cacheFile->createNewFile(); if (!$cacheFile->isWritable()) { return false; } return $cacheFile->putIndex($content); }