protected function execute(InputInterface $input, OutputInterface $output) { /** * @var $schema Schema */ $schema = $this->application->getStorage()->getSchema(); $debug = $input->getArgument('debug') == true; $fs = new Filesystem(); $fs->dumpFile($this->application->getProject()->getPath('build php Storage Master.php'), $this->fenom->render("master", array('schema' => $schema))); if ($debug) { echo '- master' . PHP_EOL; } foreach ($schema->getModels() as $model) { $modelGenerator = $this->application->getManager()->create('Cti\\Storage\\Generator\\Model', array('model' => $model)); $modelSource = $modelGenerator->getCode(); $path = $this->application->getProject()->getPath('build php Storage Model ' . $model->getClassName() . 'Base.php'); $fs->dumpFile($path, $modelSource); $repositoryGenerator = $this->application->getManager()->create('Cti\\Storage\\Generator\\Repository', array('model' => $model)); $repositorySource = $repositoryGenerator->getCode(); $path = $this->application->getProject()->getPath('build php Storage Repository ' . $model->getClassName() . 'Repository.php'); $fs->dumpFile($path, $repositorySource); if ($debug) { echo '- generate ' . $model->getClassName() . PHP_EOL; } // if($model->hasOwnQuery()) { // $fs->dumpFile( // $this->application->getPath('build php Storage Query ' . $model->class_name . 'Select.php'), // $this->application->getManager()->create('Cti\Storage\Generator\Select', array( // 'model' => $model // )) // ); // } } }
public function getCode() { $fields = array(); foreach ($this->model->getProperties() as $property) { $fields[] = $property->getName(); } $code = $this->fenom->render('repository', array('model' => $this->model, 'fields' => $fields, 'schema' => $this->schema)); return $code; }
public function getCode() { $code = $this->fenom->render('model', array('model' => $this->model, 'schema' => $this->schema, 'generator' => $this)); return $code; }