/**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $config = array();
     $this->out()->out('Start generating...')->out();
     // Prepare basic data.
     $command = $this->command;
     $element = $command->getArgument(0, new ElementPrompter('Please enter extension element: '));
     list($extension, $name, $element, $group) = $this->extractElement($element);
     $this->element = $config['element'] = $element;
     $this->type = $config['extension'] = $extension;
     $this->name = $config['name'] = $name;
     $this->group = $config['group'] = $group;
     $this->template = $config['template'] = $this->command->getOption('t');
     $this->client = $config['client'] = $this->command->getOption('c');
     if ($this->client == 'admin') {
         $this->client = $config['client'] = 'administrator';
     }
     // Get Handler
     $task = array_map('ucfirst', explode('.', $this->getTask()));
     $task = implode('\\', $task);
     $class = 'GeneratorBundle\\Controller\\';
     $class .= ucfirst($this->type) . '\\' . $task . 'Controller';
     if (!class_exists($class)) {
         throw new \RuntimeException(sprintf('Action %s of %s not support.', $this->type, $this->getTask()));
     }
     /** @var AbstractTaskController $controller */
     $controller = new $class($this->container, $this->io, new Registry($config));
     $controller->execute();
     $this->out()->out('Template generated.');
 }
예제 #2
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $config = array();
     $this->out()->out('Start generating...')->out();
     // Prepare basic data.
     $command = $this->command;
     $name = $command->getArgument(0);
     list($type, $task) = explode('.', $this->getTask(), 2);
     $this->name = $config['name'] = $name;
     $this->type = $config['type'] = $type;
     $this->template = $config['template'] = $this->command->getOption('t');
     $this->template = $config['table'] = $this->command->getOption('table');
     $config['tagVariables'] = (array) $this->tagVariables;
     $config['migrate'] = $this->command->getOption('migrate');
     $config['seed'] = $this->command->getOption('seed');
     // Get Handler
     $task = StringNormalise::toClassNamespace(str_replace('.', '\\', $task));
     $class = sprintf(__NAMESPACE__ . '\\%s\\%sController', ucfirst($this->type), $task);
     if (!class_exists($class)) {
         throw new \RuntimeException(sprintf('Task %s of type "%s" not support.', $this->getTask(), $this->type));
     }
     /** @var AbstractTaskController $controller */
     $controller = new $class($this->container, $this->io, new Structure($config));
     $controller->execute();
     $this->out()->out('Template generated.');
 }
예제 #3
0
 /**
  * getOption
  *
  * @param string $name
  * @param string $default
  *
  * @return  mixed
  */
 public function getOption($name, $default = null)
 {
     return $this->command->getOption($name, $default);
 }