コード例 #1
0
 public function handle()
 {
     $this->checkArgs(array('table'));
     $namespace = array_key_exists('namespace', $this->args) ? $this->args['namespace'] : null;
     if (!isset($namespace)) {
         $namespace = array_key_exists('ns', $this->args) ? $this->args['ns'] : null;
     }
     $table = $this->args['table'];
     $class = array_key_exists('class', $this->args) ? $this->args['class'] : Strings::snakeToCamel($table);
     $path = $this->path($class, $namespace);
     $schema = new TableSchema($table);
     if (file_exists($path)) {
         $content = File::readText($path);
         $className = isset($namespace) ? "{$namespace}\\{$class}" : $class;
         $reflection = new \ReflectionClass($className);
         $header = $reflection->getDocComment();
         if (isset($header)) {
             $content = str_replace($header, Template::generateHeader($schema->columns()), $content);
             unlink($path);
             File::writeText($path, $content);
         }
         Console::line("Model [{$class}] updated in path [{$path}].");
     } else {
         File::writeText($path, Template::generateModel($table, $class, $schema->columns(), $namespace));
         Console::line("Model [{$class}] created in path [{$path}].");
     }
 }
コード例 #2
0
ファイル: Settings.php プロジェクト: sanzhumu/xaircraft1.1
 public static function get($path)
 {
     if (isset($path) && is_readable($path)) {
         return File::readText($path);
     }
     return null;
 }
コード例 #3
0
ファイル: TableSchema.php プロジェクト: sanzhumu/xaircraft1.1
 private function loadFromCache()
 {
     $cache = File::readText($this->source);
     if (false !== $cache) {
         $result = unserialize($cache);
         if (isset($result) && $result instanceof TableSchema) {
             $this->table = $result->table;
             $this->columns = $result->columns;
             $this->source = $result->source;
             $this->autoIncrementField = $result->autoIncrementField;
             $this->canSoftDelete = $result->canSoftDelete;
             return true;
         }
     }
     return false;
 }