private function fillDocs($templateData) { if ($this->commandData->getAddOn('swagger')) { $templateData = $this->generateSwagger($templateData); } else { $docsTemplate = TemplateUtil::getTemplate('docs.model', 'laravel-generator'); $docsTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $docsTemplate); $templateData = str_replace('$DOCS$', $docsTemplate, $templateData); } return $templateData; }
private function generateTable() { if ($this->commandData->getAddOn('datatables')) { $templateData = $this->generateDataTableBody(); $this->generateDataTableActions(); } else { $templateData = $this->generateBladeTableBody(); } FileUtil::createFile($this->path, 'table.blade.php', $templateData); $this->commandData->commandInfo('table.blade.php created'); }
private function fillDocs($templateData) { $methods = ['controller', 'index', 'store', 'store', 'show', 'update', 'destroy']; if ($this->commandData->getAddOn('swagger')) { $templatePrefix = 'controller'; $templateType = 'swagger-generator'; } else { $templatePrefix = 'api.docs.controller'; $templateType = 'laravel-generator'; } foreach ($methods as $method) { $key = '$DOC_' . strtoupper($method) . '$'; $docTemplate = TemplateUtil::getTemplate($templatePrefix . '.' . $method, $templateType); $docTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $docTemplate); $templateData = str_replace($key, $docTemplate, $templateData); } return $templateData; }
public function __construct(CommandData $commandData) { $this->commandData = $commandData; $this->path = config('infyom.laravel_generator.path.views', base_path('resources/views/')) . $commandData->getAddOn('menu.menu_file'); $this->templateType = config('infyom.laravel_generator.templates', 'core-templates'); $this->menuContents = file_get_contents($this->path); $this->menuTemplate = TemplateUtil::getTemplate('scaffold.layouts.menu_template', $this->templateType); $this->menuTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $this->menuTemplate); }
public function generate() { if ($this->commandData->getAddOn('datatables')) { $templateData = TemplateUtil::getTemplate('scaffold.controller.datatable_controller', 'laravel-generator'); $this->generateDataTable(); } else { $templateData = TemplateUtil::getTemplate('scaffold.controller.controller', 'laravel-generator'); $paginate = $this->commandData->getOption('paginate'); if ($paginate) { $templateData = str_replace('$RENDER_TYPE$', 'paginate(' . $paginate . ')', $templateData); } else { $templateData = str_replace('$RENDER_TYPE$', 'all()', $templateData); } } $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData); FileUtil::createFile($this->path, $this->fileName, $templateData); $this->commandData->commandComment("\nController created: "); $this->commandData->commandInfo($this->fileName); }
public function rollback() { $files = ['table.blade.php', 'index.blade.php', 'fields.blade.php', 'create.blade.php', 'edit.blade.php', 'show.blade.php', 'show_fields.blade.php']; if ($this->commandData->getAddOn('datatables')) { $files[] = 'datatables_actions.blade.php'; } foreach ($files as $file) { if ($this->rollbackFile($this->path, $file)) { $this->commandData->commandComment($file . ' file deleted'); } } }
public function generateAPIItems() { if (!$this->isSkip('requests') and !$this->isSkip('api_requests')) { $requestGenerator = new APIRequestGenerator($this->commandData); $requestGenerator->generate(); } if (!$this->isSkip('controllers') and !$this->isSkip('api_controller')) { $controllerGenerator = new APIControllerGenerator($this->commandData); $controllerGenerator->generate(); } if (!$this->isSkip('routes') and !$this->isSkip('api_routes')) { $routesGenerator = new APIRoutesGenerator($this->commandData); $routesGenerator->generate(); } if (!$this->isSkip('tests') and $this->commandData->getAddOn('tests')) { $repositoryTestGenerator = new RepositoryTestGenerator($this->commandData); $repositoryTestGenerator->generate(); $testTraitGenerator = new TestTraitGenerator($this->commandData); $testTraitGenerator->generate(); $apiTestGenerator = new APITestGenerator($this->commandData); $apiTestGenerator->generate(); } }
/** * Execute the command. * * @return void */ public function handle() { if (!in_array($this->argument('type'), [CommandData::$COMMAND_TYPE_API, CommandData::$COMMAND_TYPE_SCAFFOLD, CommandData::$COMMAND_TYPE_API_SCAFFOLD])) { $this->error('invalid rollback type'); } $this->commandData = new CommandData($this, $this->argument('type')); $this->commandData->config->mName = $this->commandData->modelName = $this->argument('model'); $this->commandData->config->prepareOptions($this->commandData, ['tableName', 'prefix']); $this->commandData->config->prepareAddOns(); $this->commandData->config->prepareModelNames(); $this->commandData->config->prepareTableName(); $this->commandData->config->loadPaths(); $this->commandData->config->loadNamespaces($this->commandData); $this->commandData = $this->commandData->config->loadDynamicVariables($this->commandData); $migrationGenerator = new MigrationGenerator($this->commandData); $migrationGenerator->rollback(); $modelGenerator = new ModelGenerator($this->commandData); $modelGenerator->rollback(); $repositoryGenerator = new RepositoryGenerator($this->commandData); $repositoryGenerator->rollback(); $requestGenerator = new APIRequestGenerator($this->commandData); $requestGenerator->rollback(); $controllerGenerator = new APIControllerGenerator($this->commandData); $controllerGenerator->rollback(); $routesGenerator = new APIRoutesGenerator($this->commandData); $routesGenerator->rollback(); $requestGenerator = new RequestGenerator($this->commandData); $requestGenerator->rollback(); $controllerGenerator = new ControllerGenerator($this->commandData); $controllerGenerator->rollback(); $viewGenerator = new ViewGenerator($this->commandData); $viewGenerator->rollback(); $routeGenerator = new RoutesGenerator($this->commandData); $routeGenerator->rollback(); if ($this->commandData->getAddOn('tests')) { $repositoryTestGenerator = new RepositoryTestGenerator($this->commandData); $repositoryTestGenerator->rollback(); $testTraitGenerator = new TestTraitGenerator($this->commandData); $testTraitGenerator->rollback(); $apiTestGenerator = new APITestGenerator($this->commandData); $apiTestGenerator->rollback(); } if ($this->commandData->config->getAddOn('menu.enabled')) { $menuGenerator = new MenuGenerator($this->commandData); $menuGenerator->rollback(); } $this->info('Generating autoload files'); $this->composer->dumpOptimized(); }