Example #1
0
 public function moveTo($destination)
 {
     Filesystem::checkWritable(dirname($destination));
     if (!move_uploaded_file($this->path, $destination)) {
         throw new FilesystemException("Failed to move file {$this->path} to {$destination}");
     }
 }
Example #2
0
 public function putContents($contents)
 {
     if (file_exists($this->path)) {
         Filesystem::checkWritable($this->path);
     } else {
         Filesystem::checkWritable(dirname($this->path));
     }
     file_put_contents($this->path, $contents);
 }
Example #3
0
 public static function create($path)
 {
     Filesystem::checkWriteSafety(dirname($path));
     if (file_exists($path) && !is_dir($path)) {
         throw new FilesystemException("A file already exists in the location of [{$path}]");
     }
     if (!file_exists($path)) {
         mkdir($path);
     }
     return new Directory($path);
 }
Example #4
0
File: Init.php Project: ntentan/dev
 public function runTask($options)
 {
     ClearIce::output("Setting up app namespace {$options['namespace']} ... ");
     Filesystem::createDirectoryStructure(['src' => ['modules' => ['home'], 'lib'], 'config', 'logs', 'views' => ['default', 'home']], './');
     $data = ['namespace' => $options['namespace'], 'date' => date("Y-m-d H:i:s")];
     $this->writeFile(__DIR__ . "/../../code_templates/misc/htaccess.template", $data, '.htaccess');
     $this->writeFile(__DIR__ . "/../../code_templates/php/index.php.template", $data, 'index.php');
     $this->writeFile(__DIR__ . "/../../code_templates/php/HomeController.php.template", $data, 'src/modules/home/HomeController.php');
     $this->writeFile(__DIR__ . "/../../code_templates/php/home_index.tpl.php.template", $data, 'views/default/home_index.tpl.php');
     $this->writeFile(__DIR__ . "/../../code_templates/php/main.tpl.php.template", $data, 'views/default/main.tpl.php');
     ClearIce::output("OK\n");
 }
Example #5
0
 public static function checkWriteSafety($path)
 {
     Filesystem::checkExists($path);
     Filesystem::checkWritable($path);
 }
Example #6
0
 /**
  * @expectedException \ntentan\utils\exceptions\FilesystemException
  */
 public function testWriteableException()
 {
     $this->assertEquals(true, Filesystem::checkWritable(vfsStream::url('fs/file')));
     $this->file->chmod(00);
     Filesystem::checkWritable(vfsStream::url('fs/file'));
 }
Example #7
0
 public function writeFile($templateFile, $data, $destination)
 {
     $output = \ntentan\honam\TemplateEngine::renderString(Filesystem::get($templateFile)->getContents(), 'mustache', $data);
     Filesystem::get($destination)->putContents($output);
 }