Ejemplo n.º 1
0
 /**
  * Perform command.
  *
  * @param Reactor $reactor
  */
 public function perform(Reactor $reactor)
 {
     /**
      * @var ServiceGenerator $generator
      */
     if (empty($generator = $this->getGenerator())) {
         return;
     }
     foreach ($this->option('method') as $method) {
         $generator->addMethod($method);
     }
     if (!empty($model = $this->option('entity'))) {
         if (empty($class = $reactor->findClass('entity', $model))) {
             $this->writeln("<fg=red>Unable to locate model class for '{$model}'.</fg=red>");
             return;
         }
         $generator->associateModel($model, $class);
     }
     if (!$this->option('mortal')) {
         $generator->makeSingleton();
     }
     foreach ($this->option('depends') as $service) {
         if (empty($class = $reactor->findClass('service', $service))) {
             $this->writeln("<fg=red>Unable to locate service class for '{$service}'.</fg=red>");
             return;
         }
         $generator->addDependency($service, $class);
     }
     //Generating
     $generator->render();
     $filename = basename($generator->getFilename());
     $this->writeln("<info>Service was successfully created:</info> {$filename}");
 }
Ejemplo n.º 2
0
 /**
  * Perform command.
  *
  * @param Reactor $reactor
  */
 public function perform(Reactor $reactor)
 {
     /**
      * @var ControllerGenerator $generator
      */
     if (empty($generator = $this->getGenerator())) {
         return;
     }
     foreach ($this->option('method') as $method) {
         $generator->addMethod($method);
     }
     if (!empty($service = $this->option('service'))) {
         if (empty($serviceClass = $reactor->findClass('service', $service))) {
             $this->writeln("<fg=red>Unable to locate service class for '{$service}'.</fg=red>");
             return;
         }
         //Pre-generate methods using data entity service
         if (!empty($request = $this->option('request'))) {
             if (empty($requestClass = $reactor->findClass('request', $request))) {
                 $this->writeln("<fg=red>Unable to locate request class for '{$request}'.</fg=red>");
                 return;
             }
             //Use request instead of POST data to create and update data entity
             $generator->createCRUD($service, $serviceClass, $request, $requestClass);
         } else {
             $generator->createCRUD($service, $serviceClass);
         }
     }
     foreach ($this->option('depends') as $service) {
         if (empty($class = $reactor->findClass('service', $service))) {
             $this->writeln("<fg=red>Unable to locate service class for '{$service}'.</fg=red>");
             return;
         }
         $generator->addDependency($service, $class);
     }
     //Generating
     $generator->render();
     $filename = basename($generator->getFilename());
     $this->writeln("<info>Controller was successfully created:</info> {$filename}");
 }
Ejemplo n.º 3
0
 /**
  * Perform command.
  *
  * @param Reactor $reactor
  */
 public function perform(Reactor $reactor)
 {
     /**
      * @var MiddlewareGenerator $generator
      */
     if (empty($generator = $this->getGenerator())) {
         return;
     }
     foreach ($this->option('depends') as $service) {
         if (empty($class = $reactor->findClass('service', $service))) {
             $this->writeln("<fg=red>Unable to locate service class for '{$service}'.</fg=red>");
             return;
         }
         $generator->addDependency($service, $class);
     }
     //Generating
     $generator->render();
     $filename = basename($generator->getFilename());
     $this->writeln("<info>Http middleware was successfully created:</info> {$filename}");
     $this->writeln("You register your middleware by assigning it to Route or via http config.");
 }
Ejemplo n.º 4
0
 /**
  * Perform command.
  *
  * @param Reactor $reactor
  */
 public function perform(Reactor $reactor)
 {
     /**
      * @var RequestGenerator $generator
      */
     if (empty($generator = $this->getGenerator())) {
         return;
     }
     if (!empty($entity = $this->option('entity'))) {
         if (empty($class = $reactor->findClass('entity', $entity))) {
             $this->writeln("<fg=red>Unable to locate entity class for '{$entity}'.</fg=red>");
             return;
         }
         $generator->followEntity($this->getEntityReflection($class));
     }
     foreach ($this->option('field') as $field) {
         list($field, $type, $source, $origin) = $this->parseField($field);
         $generator->addField($field, $type, $source, $origin);
     }
     //Generating
     $generator->render();
     $filename = basename($generator->getFilename());
     $this->writeln("<info>Request Filter was successfully created:</info> {$filename}");
 }