private function generateModel() { $tableName = $this->input->getArgument('table'); $className = $this->input->getOption('class'); $fileName = $this->input->getOption('file'); $nameSpace = $this->input->getOption('namespace'); $tablePrefixToRemove = $this->input->getOption('remove-prefix') ?: 't'; $shortArrays = $this->input->getOption('short-arrays'); if (empty($tableName)) { $this->fail("Specify table name e.g. users"); } try { $modelGenerator = new Generator($tableName, $className, $nameSpace, $tablePrefixToRemove, $shortArrays); $this->output->writeln('---------------------------------'); $this->writeInfo('Database name: <info>%s</info>', Config::getValue('db', 'dbname')); $this->writeInfo('Class name: <info>%s</info>', $modelGenerator->getTemplateClassName()); $this->writeInfo('Class namespace: <info>%s</info>', $modelGenerator->getClassNamespace()); $this->output->writeln('---------------------------------'); $this->output->writeln($modelGenerator->templateContents()); $this->output->writeln('---------------------------------'); if ($fileName) { $this->saveClassToFile($modelGenerator, $fileName); } else { $classFileName = ClassPathResolver::forClassAndNamespace($modelGenerator->getTemplateClassName(), $modelGenerator->getClassNamespace())->getClassFileName(); $this->saveClassToFile($modelGenerator, $classFileName); } } catch (GeneratorException $e) { $this->fail($e->getMessage()); } }
/** * @test */ public function shouldResolveDirectoryPath() { //given $resolver = ClassPathResolver::forClassAndNamespace('UserAcl', '\\Application\\View'); //when $directoryPath = $resolver->getClassDirectory(); //then Assert::thatString($directoryPath)->endsWith(Path::join('Application', 'View', 'UserAcl')); }
public function getViewPath() { return $this->viewPath ?: ClassPathResolver::forClassAndNamespace($this->getViewName(), $this->getViewNamespace())->getClassDirectory(); }
public function getControllerPath() { return $this->controllerPath ?: ClassPathResolver::forClassAndNamespace($this->getClassName(), $this->getClassNamespace())->getClassFileName(); }