Ejemplo n.º 1
0
 protected function write(State $state, InputInterface $input, OutputInterface $output)
 {
     $writeState = new State($this->configWriter);
     $writeState->addModel($state->getEntityModel());
     $writeState->addModel($state->getModel('entity-test'));
     parent::write($writeState, $input, $output);
 }
Ejemplo n.º 2
0
 protected function write(State $state, InputInterface $input, OutputInterface $output)
 {
     $writeState = new State($this->configWriter);
     if (!$input->getOption('no-repository')) {
         $writeState->addModel($state->getRepositoryModel());
     }
     if (!$input->getOption('no-trait')) {
         $writeState->addModel($state->getModel('repository-trait'));
     }
     parent::write($writeState, $input, $output);
 }
Ejemplo n.º 3
0
 public function testWrite()
 {
     $state = new State(new ConfigWriter(new Config()));
     $modelA = new Model();
     $modelB = new Model();
     $state->addModel($modelA);
     $state->addModel($modelB);
     $output = new NullOutput();
     $writer = $this->getWriter(['writeModel', 'mergeConfig']);
     $writer->expects($this->at(0))->method('writeModel')->with($modelA, $output);
     $writer->expects($this->at(1))->method('mergeConfig')->with($state, $modelA, $output);
     $writer->expects($this->at(2))->method('writeModel')->with($modelB, $output);
     $writer->expects($this->at(3))->method('mergeConfig')->with($state, $modelB, $output);
     $writer->write($state, $output);
 }
Ejemplo n.º 4
0
 /**
  * Prepare models
  *
  * @param State|State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart(basename($this->name))->getRawPath('');
     $model->setPath($path);
     $state->addModel($model, $this->name);
 }
Ejemplo n.º 5
0
 public function testGetModel()
 {
     $state = new State($this->getConfigWriter());
     $model = new Model();
     $state->addModel($model, 'test');
     $this->assertSame($model, $state->getModel('test'));
 }
Ejemplo n.º 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = new Config();
     $config->setBasePath(getcwd());
     $config->setFromArray($input->getArguments());
     $config->setFromArray(array('bare' => $input->getOption('bare')));
     $moduleConfig = new ConfigWriter($config);
     $state = new State($moduleConfig);
     $builder = new FullContainer($config);
     $builder->prepare($state);
     $builder->build($state);
     $writeState = new State($moduleConfig);
     $models = array('service' => $state->getServiceModel(), 'factory' => $state->getModel('service-factory'), 'trait' => $state->getModel('service-trait'), 'test' => $state->getModel('service-test'));
     foreach (array_keys($models) as $key) {
         if ($input->getOption('no-' . $key)) {
             $models[$key] = false;
         }
         if ($input->getOption('only-' . $key)) {
             foreach (array_keys($models) as $index) {
                 if ($key != $index) {
                     $models[$index] = false;
                 }
             }
         }
     }
     foreach ($models as $model) {
         if ($model) {
             $writeState->addModel($model);
         }
     }
     $writer = new ModelWriter($config);
     $writer->write($writeState, $output);
     $moduleConfig->save($output);
 }
Ejemplo n.º 7
0
 /**
  * Prepare models
  *
  * @param State|State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule())->addPart('Service')->addPart($this->config->getName() . 'Service')->getNamespace();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart('Service')->addPart($this->config->getName() . 'Service')->getSourcePath();
     $model->setName($name);
     $model->setPath($path);
     $state->addModel($model, 'service');
 }
Ejemplo n.º 8
0
 /**
  * @param State|\Scaffold\State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule() . 'Test')->addPart('Entity')->addPart($this->config->getName() . 'Test')->getNamespace();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart('Entity')->addPart($this->config->getName())->getTestPath();
     $model->setName($name);
     $model->setPath($path);
     $state->addModel($model, 'entity-test');
     $this->model = $model;
 }
 /**
  * Prepare models
  *
  * @param State|\Scaffold\State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule())->addPart('Repository')->addPart($this->config->getName() . 'RepositoryTrait')->getNamespace();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart('Repository')->addPart($this->config->getName() . 'RepositoryTrait')->getSourcePath();
     $model->setName($name);
     $model->setPath($path);
     $state->addModel($model, 'repository-trait');
     $this->model = $model;
 }
Ejemplo n.º 10
0
 /**
  * Prepare models
  *
  * @param State|\Scaffold\State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule())->addPart('Exception')->addPart($this->name)->getNamespace();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart('Exception')->addPart($this->name)->getSourcePath();
     $model->setName($name);
     $model->setPath($path);
     $state->addModel($model, $this->name);
     $this->model = $model;
 }
Ejemplo n.º 11
0
 /**
  * Prepare models
  *
  * @param State|\Scaffold\State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule())->addPart('Form')->addPart($this->config->getName() . 'FormFactory')->getNamespace();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart('Form')->addPart($this->config->getName() . 'FormFactory')->getSourcePath();
     $model->setName($name);
     $model->setPath($path);
     $config = array('service_manager' => array('factories' => array($model->getServiceName() => $name)));
     $model->setServiceConfig($config);
     $state->addModel($model, 'form-factory');
 }
Ejemplo n.º 12
0
 /**
  * Prepare models
  *
  * @param State|State $state
  */
 public function prepare(State $state)
 {
     $filename = $this->config->getName() . 'Controller';
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule())->addPart('Controller')->addPart($filename)->getNamespace();
     $path = $this->buildPath()->setModule($this->config->getModule())->addPart('Controller')->addPart($filename)->getSourcePath();
     $model->setName($name);
     $model->setPath($path);
     $config = array('controllers' => array('invokables' => array($model->getServiceName() => $model->getName())));
     $model->setServiceConfig($config);
     $state->addModel($model, 'controller');
 }
Ejemplo n.º 13
0
 /**
  * Prepare models
  *
  * @param State|State $state
  */
 public function prepare(State $state)
 {
     $model = new Model();
     $name = $this->buildNamespace()->addPart($this->config->getModule())->addPart('Module')->getNamespace();
     $pathBuilder = $this->buildPath();
     if ($this->config->getBare()) {
         $pathBuilder->addPart('src');
         $pathBuilder->addPart($this->config->getModule());
     }
     $path = $pathBuilder->setModule($this->config->getModule())->addPart('Module')->getRawPath();
     $model->setName($name);
     $model->setPath($path);
     $state->addModel($model, 'module');
 }
Ejemplo n.º 14
0
 protected function write(State $state, InputInterface $input, OutputInterface $output)
 {
     $writeState = new State($this->configWriter);
     $writeState->addModel($state->getControllerModel());
     parent::write($writeState, $input, $output);
 }