/** * Generate files. * * @return bool */ protected function generate(FileGenerator $generator) { $fqcn = $this->convertToFullQualifyClassName($this->getNameInput()); $path = $this->getRelativePath($fqcn) . '.php'; if ($generator->exists($path)) { $this->error($this->type . ' already exists!'); return false; } return $this->generateFile($generator, $path, $fqcn); }
/** * Execute the console command. * * @return void */ public function handle() { $generator = FileGenerator::make($this->getRootDirectory(), $this->getStubDirectory()); if ($this->generate($generator) === false) { return false; } $this->info($this->type . ' created successfully.'); }
/** * Generate file. * * @param \Jumilla\Generators\FileGenerator $generator * @param string $path * @param string $fqcn * * @return bool */ protected function generateFile(FileGenerator $generator, $path, $fqcn) { list($namespace, $class) = $this->splitFullQualifyClassName($fqcn); return $generator->file($path)->template($this->getStub(), ['namespace' => $namespace, 'root_namespace' => $this->getAppNamespace(), 'class' => $class]); }
/** * Generate file. * * @param FileGenerator $generator * @param string $path * @param string $fqcn * * @return bool */ protected function generateFile(FileGenerator $generator, $path, $fqcn) { list($namespace, $class) = $this->splitFullQualifyClassName($fqcn); return $generator->file($path)->template($this->getStub(), ['namespace' => $namespace, 'class' => $class, 'table' => $this->option('create') ?: $this->option('update')]); }
protected function generateAddonConfig(FileGenerator $generator, $namespace, array $data, array $defaults = null) { if ($defaults !== null) { $data = array_replace($defaults, $data); } $data = array_merge(['version' => ADDON_VERSION], $data); $generator->phpConfigFile('addon.php', $data, $namespace); }