Ejemplo n.º 1
0
 public function handle(InputInterface $input, OutputInterface $output)
 {
     $this->file = Filesystem::getInstance();
     $this->manager = new MigrationManager();
     $command = $this->argument('function') ? $this->argument('function') : 'create';
     $param = $this->argument('name') ? $this->argument('name') : '';
     if (is_callable([$this, $command])) {
         $this->{$command}($param);
     } else {
         $this->error(sprintf('%s adında bir komut bulunamadı', $command));
     }
 }
Ejemplo n.º 2
0
 /**
  * Dosyayı oluşturur ve içeriği dosyaya aktarır
  *
  * @param string $src
  * @param string $fileName
  * @param string $content
  * @throws \Exception
  */
 private function create($src = '', $fileName = '', $content = '')
 {
     $file = Filesystem::getInstance();
     $path = $src . $fileName . '.php';
     // kaynak dosya yoksa oluşturuyoruz
     if (!$file->exists($src)) {
         $file->mkdir($src);
     }
     $file->chmod($src, 0777);
     // eğer dosya yoksa oluşturuyoruz
     if (!$file->exists($path)) {
         $file->touch($path);
         $file->chmod($path, 0777);
         if ($file->isWriteable($path)) {
             $file->write($path, $content);
             $this->info(sprintf('%s isimli dosya %s yolunda başarıyla oluşturuldu.', $fileName, $src));
         } else {
             $this->error(sprintf('%s isimli dosyaya veri işlenemedi, sebep: dosya yazılabilir değil', $path));
         }
     } else {
         $this->error(sprintf('%s isimli dosya %s yolunda oluşturulamadı, sebep: dosya zaten var', $fileName, $src));
     }
 }