Ejemplo n.º 1
0
 protected function generateScaffoldController($name)
 {
     $filename = '';
     $controller = '';
     //$name = $this->console->argument(1);
     if (strstr($name, '_')) {
         list($this->namespace, $name) = explode('_', $name);
     }
     $pluralized_name = api_helpers_string::plural($name);
     $filename = $pluralized_name . '.php';
     $controller = file_get_contents($this->template_dir . 'controller.php');
     if ($this->namespace != '') {
         $filename = $this->namespace . '/' . $filename;
         $controller = str_replace("namespace", $this->namespace, $controller);
     } else {
         $controller = str_replace("namespace/", "", $controller);
     }
     $controller = str_replace("nameplural", $pluralized_name, $controller);
     $controller = str_replace("name", $name, $controller);
     $this->destination_dir .= 'controllers/';
     if (!is_file($this->destination_dir . $filename)) {
         echo "create: " . $this->destination_dir . $filename . "\n";
         file_put_contents($this->destination_dir . $filename, $controller);
     } else {
         echo "exists: " . $this->destination_dir . $filename . "\n";
     }
 }