Exemplo n.º 1
0
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $ioClass = 'Phoenix\\IO\\IO';
     $container->alias('io', $ioClass)->alias('Muse\\IO\\IO', $ioClass)->alias('Muse\\IO\\IOInterface', $ioClass)->share($ioClass, new IO($this->controller->getCommand()));
     $container->alias('operator.copy', 'Phoenix\\Generaotr\\FileOperator\\CopyOperator')->createObject('Phoenix\\Generaotr\\FileOperator\\CopyOperator');
     $closure = function (Container $container) {
         return new OperatorFactory($container->get('io'), $this->controller->getTagVariables());
     };
     $container->share('operator.factory', $closure);
 }
Exemplo n.º 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.');
 }
 /**
  * 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.');
 }
Exemplo n.º 4
0
 /**
  * Test prompter ask.
  *
  * @return  void
  *
  * @since  2.0
  */
 public function testAsk()
 {
     $this->setStream("y");
     $this->instance->ask();
     $this->assertEquals(trim($this->io->getTestOutput()), trim('Tell me something: '));
     // Ask by invoke
     $this->setStream("n");
     /** @var $prompter AbstractPrompter */
     $prompter = $this->instance;
     $in = $prompter();
     $this->assertEquals($in, 'n');
     // Set as default in command getArgument
     $command = new Command('test', $prompter->getIO());
     $this->setStream("fly");
     $this->io->setTestOutput('');
     $in = $command->getArgument(9, $this->instance);
     $this->assertEquals(trim($this->io->getTestOutput()), trim('Tell me something: '));
     $this->assertEquals($in, 'fly');
 }
 /**
  * execute
  *
  * @return  mixed
  */
 public function execute()
 {
     define('SQLSYNC_COMMAND', __DIR__);
     define('SQLSYNC_RESOURCE', JPATH_ROOT . '/resources/sqlsync');
     define('SQLSYNC_PROFILE', SQLSYNC_RESOURCE);
     define('SQLSYNC_LIB', DEVELOPMENT_BUNDLE_ROOT . '/Sqlsync');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     return parent::execute();
 }
Exemplo n.º 6
0
    /**
     * Configure command information.
     *
     * @return void
     */
    public function initialise()
    {
        $this->help(<<<HELP
Example:

generator test Helper PathHelper
    Generate to: test/Helper/PathHelper.php

generator test Helper PathHelper Foo/Bar/PathHelper
    Generate to: test/Foo/Bar/PathHelper.php

HELP
);
        parent::initialise();
    }
 /**
  * clear
  *
  * @param AbstractSeeder|string $seeder
  *
  * @return  static
  */
 public function clear($seeder = null)
 {
     if ($seeder === null) {
         return $this;
     }
     if (is_string($seeder)) {
         $ref = new \ReflectionClass($this);
         include_once dirname($ref->getFileName()) . '/' . $seeder . '.php';
         $seeder = new $seeder();
     }
     $seeder->setDb($this->db);
     $seeder->setCommand($this->command);
     $this->command->out('Clear seeder ' . get_class($seeder));
     $seeder->doClear();
     return $this;
 }
Exemplo n.º 8
0
 /**
  * Initialise command information.
  *
  * @return void
  */
 public function initialise()
 {
     parent::initialise();
     $this->addOption('no-backup')->description('Do not backup database.');
 }
Exemplo n.º 9
0
 /**
  * Get argument or close this appliction.
  *
  * @param   integer $arg Argument offset.
  * @param   string  $msg Close message.
  *
  * @return  string Return argument value.
  */
 public function getOrClose($arg, $msg = '')
 {
     return $this->command->getOrClose($arg, $msg);
 }
 /**
  * Get a value from standard input.
  *
  * @param   string  $question  The question you want to ask user.
  *
  * @return  string  The input string from standard input.
  */
 public function in($question = '')
 {
     return $this->command->in($question);
 }
Exemplo n.º 11
0
 /**
  * configure
  *
  * @return  void
  */
 public function configure()
 {
     parent::configure();
 }
Exemplo n.º 12
0
 /**
  * Configure command information.
  *
  * @return void
  */
 public function initialise()
 {
     // $this->addArgument();
     parent::initialise();
 }
Exemplo n.º 13
0
 /**
  * Execute this command.
  *
  * @return int|void
  */
 protected function doExecute()
 {
     return parent::doExecute();
 }
Exemplo n.º 14
0
 /**
  * Initialise command information.
  *
  * @return void
  */
 public function initialise()
 {
     parent::initialise();
 }
Exemplo n.º 15
0
 /**
  * Configure command information.
  *
  * @return void
  */
 public function initialise()
 {
     $this->addOption(array('d', 'description'), null, 'Command description');
     parent::initialise();
 }
Exemplo n.º 16
0
 /**
  * getOption
  *
  * @param string $name
  * @param string $default
  *
  * @return  mixed
  */
 public function getOption($name, $default = null)
 {
     return $this->command->getOption($name, $default);
 }
Exemplo n.º 17
0
 /**
  * Test the err method.
  *
  * @return void
  *
  * @since  2.0
  *
  * @covers Windwalker\Console\Command\AbstractCommand::err
  */
 public function testErr()
 {
     $this->instance->getIO()->outputStream = '';
     $this->instance->err('errrr', false);
     $this->assertEquals('errrr', $this->instance->getIO()->getTestOutput());
 }
Exemplo n.º 18
0
 /**
  * Configure command information.
  *
  * @return void
  */
 public function configure()
 {
     $this->addOption(array('d', 'description'), null, 'Command description');
     parent::configure();
 }
Exemplo n.º 19
0
 /**
  * Configure command information.
  *
  * @return void
  */
 public function initialise()
 {
     $this->addOption('a')->alias('admin')->description('Use admin client.');
     $this->addOption('w')->alias('windwalker')->description('Use Windwalker sum style.');
     parent::initialise();
 }
Exemplo n.º 20
0
 /**
  * testError
  *
  * @return  void
  *
  * @expectedException  \Exception
  */
 public function testError()
 {
     $this->instance->error('test');
 }
Exemplo n.º 21
0
 /**
  * Configure command information.
  *
  * @return void
  */
 public function initialise()
 {
     $this->addGlobalOption('g')->alias('group')->description('The group id, default will use SuperUser group.');
     parent::initialise();
 }
Exemplo n.º 22
0
 /**
  * Configure command information.
  *
  * @return void
  */
 public function configure()
 {
     // $this->addArgument();
     parent::configure();
 }
Exemplo n.º 23
0
 /**
  * initialise
  *
  * @return  void
  */
 public function initialise()
 {
     parent::initialise();
     $this->addCommand(new GenerateCommand());
 }