protected function execute(InputInterface $input, OutputInterface $output) { $module = ucfirst($input->getArgument('module')); $controller = $input->getArgument('controller'); if (!empty($controller)) { $controller = ucfirst($controller); } else { $controller = $module; } $controller .= 'PageController'; $filename = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR; $filename .= 'page_controller.php.twig'; if (file_exists($filename)) { $string = new TString(file_get_contents($filename)); $string->replace('{{ controller }}', $controller)->replace('{{ module }}', $module)->replace('{{ date }}', date('d/m/Y')); } else { throw new FileNotFoundException("{$filename} nao encontrado"); } $fileController = $this->modulesPath . $module . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . $controller . '.php'; if (file_exists($this->modulesPath . $module)) { Filesystem::getInstance()->touch($fileController); Filesystem::getInstance()->chmod($fileController, 0660); $file = new File($fileController); $fileObject = $file->openFile('w'); $fileObject->fwrite($string->getValue()); $output->writeln("<info>OK: {$fileController} criado com sucesso</info>"); } else { $output->writeln("<error>FALHA: O módulo {$module} não existe ou não é gravável</error>"); } }
protected function execute(InputInterface $input, OutputInterface $output) { $this->isConnected(); $entity = $input->getArgument('entity'); $dataSource = new CreateDataSource($entity); $dirBase = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'DataSource'; $filename = realpath($dirBase) . DIRECTORY_SEPARATOR . $dataSource->getClassName() . '.php'; Filesystem::getInstance()->touch($filename); Filesystem::getInstance()->chmod($filename, 0660); $file = new File($filename); $fileObject = $file->openFile('w'); $fileObject->fwrite($dataSource->getOutput()); $output->writeln("<info>{$filename} criado com sucesso!!!</info>"); $output->writeln('<comment>Cria sua classe de modelo de dados e estenda de ' . $dataSource->getClassName() . '</comment>'); }