Exemplo n.º 1
0
 public function generate(\DateTime $date)
 {
     $filePath = $appMigrationPath = '';
     $date->setTimezone(new \DateTimeZone(SET_TIME_ZONE));
     $appMigrationPath = $this->getAppMigrationDirPath() . DS . 'database' . DS . 'migrations' . DS;
     $this->hasDirectory($appMigrationPath);
     $filePath = $appMigrationPath . strtolower(Inflector::changeToLower($date->format('YmdHis') . '_' . $this->command->input . EXT));
     /*write operation ->*/
     $writeTmp = fopen($filePath, "w") or die("Unable to generate migration on {$filePath}");
     try {
         fwrite($writeTmp, $this->replacedContent);
     } catch (\Exception $ex) {
         echo 'Caught exception: ', $ex->getMessage(), "\n";
     }
     fclose($writeTmp);
     $this->replacedContent = '';
     return $filePath;
 }