Beispiel #1
0
 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
         //                    ))
         //                );
         //            }
     }
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 /**
  * @return \Fenom
  */
 private function getEngine($index)
 {
     if (!isset($this->instances[$index])) {
         $source = $this->source[$index];
         $build = $this->build . DIRECTORY_SEPARATOR . md5($this->source[$index]);
         $filesystem = new Filesystem();
         $filesystem->mkdir($source);
         $filesystem->mkdir($build);
         $fenom = $this->instances[$index] = \Fenom::factory($source, $build, \Fenom::AUTO_RELOAD);
         $this->initEngine($fenom);
     }
     return $this->instances[$index];
 }
Beispiel #4
0
 public function getCode()
 {
     $code = $this->fenom->render('model', array('model' => $this->model, 'schema' => $this->schema, 'generator' => $this));
     return $code;
 }
Beispiel #5
0
 /**
  * displaying fenom template
  * @param $template
  * @param array $data
  */
 protected function display($template, $data = array())
 {
     $this->fenom->display($template, $data);
 }
Beispiel #6
0
 function addSource(Fenom $fenom, Project $project)
 {
     $fenom->addSource($project->getPath('resources another-fenom'));
 }