Example #1
0
 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}");
     }
 }