protected function execute(InputInterface $input, OutputInterface $output) { $this->execInput = $input; $this->execOutput = $output; $this->initDoctrine($input, $output); $project = $this->getProject(); $package = $this->getPackage(); $name = $input->getArgument('name'); $contexts = (array) $input->getArgument('contexts'); if (empty($contexts)) { $contexts = array('page-content'); } $section = $this->validateOptionalString($input->getOption('section')); $label = $this->validateOptionalString($input->getOption('label')); $this->widgetsDir = $project->dir('resources')->sub('widgets/'); $this->info('Creating Widget ' . $name . ' in ' . $this->widgetsDir); $this->jsonc = new JSONConverter(); $specification = $this->getSpecification($name, $contexts, $section, $label); $template = $this->getTemplate($specification); $dashName = Code::camelCaseToDash($name); $tableName = 'cs_' . str_replace('-', '_', $dashName) . 's'; $tableName = $this->askDefault('TableName for Entity', $tableName); $entityExists = FALSE; try { $this->callCommand('cms:create-entity', array('name' => 'ContentStream\\' . $name, 'tableName' => $tableName), $output); } catch (\Psc\Code\Generate\ClassWritingException $e) { $entityExists = TRUE; $this->warn('Your entity was already created before. I will not recreate it.'); } $this->comment('put this to the discrimination map from ContentStream\\Entry' . ($entityExists ? ' (if not already)' : '') . ': '); $this->comment(' "' . $dashName . '" = "' . $name . '",'); $this->br(); if ($this->confirm('Should I compile the entities, now?')) { $this->callCommand('project:compile', array('--con' => 'tests'), $output); $this->br(); } if ($this->confirm('Should I compile js templates, now?')) { system('grunt hogan'); $this->br(); } $this->info('finished.'); return 0; }
/** * Der EntityName ist eine KurzForm der Klasse * * Dies ist für \tiptoi\Entities\Sound z. b. "sound" */ public function getEntityName() { return Code::camelCaseToDash($this->getGClass()->getClassName()); }