/**
  * @param ContainerAwareCommand $command A ContainerAwareCommand instance to test
  * @param ContainerInterface $container The container to be injected in the command to test
  */
 public function __construct(ContainerAwareCommand $command, ContainerInterface $container)
 {
     $application = new Application('Paraunit Command Test: ' . $command->getName());
     $application->add($command);
     $this->container = $container;
     $command->setContainer($container);
     parent::__construct($command);
 }
 /**
  * Executes specified command.
  *
  * @param ContainerAwareCommand $commandInstance
  * @param string                $commandNamespace
  * @param array                 $parameters
  *
  * @return CommandTester
  */
 protected function executeCommand(ContainerAwareCommand $commandInstance, $commandNamespace, array $parameters = [])
 {
     $application = new Application(self::createClient()->getKernel());
     $commandInstance->setContainer($this->getServiceContainer());
     $application->add($commandInstance);
     $command = $application->find($commandNamespace);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array_merge_recursive(['command' => $command->getName()], $parameters));
     return $commandTester;
 }
 /**
  * Check command execute.
  */
 public function testExecute()
 {
     // Parameter was not set, so it has no value.
     $this->commandTester->execute(['command' => $this->command->getName(), 'parameter' => 'test1']);
     $this->assertContains('Parameter `test1`: has no value.', $this->commandTester->getDisplay());
     $this->assertContains('If you want to write new value, use --set="<new value>" option.', $this->commandTester->getDisplay());
     // Set some value, and test if it was set and returned.
     $value = '2014-01-01 01:01:01';
     $this->commandTester->execute(['command' => $this->command->getName(), 'parameter' => 'test1', '--set' => $value]);
     $this->assertContains('New value written:', $this->commandTester->getDisplay());
     /** @var Repository $repo */
     $repo = $this->manager->getRepository('ONGRConnectionsBundle:Pair');
     $parameter = $repo->find('test1');
     $this->assertEquals($value, $parameter->getValue());
 }
 /**
  * Set the service container, and initialize the command.
  *
  * @param ContainerInterface $container
  */
 public function setContainer(ContainerInterface $container = null)
 {
     parent::setContainer($container);
     $this->templating = $container->get('templating');
     $this->logger = $container->get('logger');
     $this->em = $container->get('doctrine')->getManager();
 }
Esempio n. 5
0
 public function configure()
 {
     parent::configure();
     $this->setName('partkeepr:user:protect');
     $this->setDescription("Protects a given user against changes");
     $this->addArgument("username", InputArgument::REQUIRED, "The username to protect against changes");
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->targetPath = $input->getOption('target') ?: sprintf('%s/../web/js/fos_js_routes.js', $this->getContainer()->getParameter('kernel.root_dir'));
     $this->extractor = $this->getContainer()->get('fos_js_routing.extractor');
     $this->serializer = $this->getContainer()->get('fos_js_routing.serializer');
 }
Esempio n. 7
0
 /**
  * Initialize Connections
  * @param InputInterface  $input  input
  * @param OutputInterface $output output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->container = $this->getContainer();
     $this->classification = $this->container->get('consult.classification');
     $this->wordManager = $this->container->get('consult.word_manager');
 }
Esempio n. 8
0
 /**
  * 呼び出し元のコントローラーから呼び出すモデルを判定しrun()を実行します。
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // 実行中チェック
     $name = sprintf('%s.%s', $this->getName(), $input->getArgument('service'));
     $this->getContainer()->get('lib.command.manager')->createExecuting($name);
     $serviceName = $input->getArgument('service');
     $controllerClass = get_class($this);
     // サービスのディレクトリ
     $serviceDir = preg_replace('/Command$/', '', basename(str_replace('\\', '/', $controllerClass)));
     // サービスのクラス名
     $clazz = '';
     foreach (explode('-', $serviceName) as $_word) {
         $clazz .= ucwords($_word);
     }
     if ($clazz === '') {
         throw new IllegalArgumentException('serviceが指定されていません。');
     }
     $tmp = sprintf('Service\\%s\\%s', $serviceDir, $clazz);
     $classPath = preg_replace('/Command.*Command$/', $tmp, $controllerClass);
     $service = new $classPath(parent::getContainer(), $this, $input, $output);
     if (is_null($service)) {
         throw new \ErrorException('Service is not found.');
     }
     $response = $service->run();
     // 実行中チェックを削除
     $this->getContainer()->get('lib.command.manager')->removeExecuting($name);
     return $response;
 }
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (!class_exists('Symfony\\Component\\Translation\\Translator')) {
         return false;
     }
     return parent::isEnabled();
 }
Esempio n. 10
0
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (version_compare(phpversion(), '5.4.0', '<')) {
         return false;
     }
     return parent::isEnabled();
 }
    /**
     * {@inheritdoc}
     */
    public function getHelp()
    {
        $help = parent::getHelp();
        if (null !== $help) {
            return $help;
        }
        /** @var $generators \PhpCollection\Map */
        $generators = $this->getContainer()->get('sp_fixture_dumper.generators_map');
        $help = <<<EOT
The <info>%1\$s</info> command dumps fixtures to a directory from your existing entities/documents:

  <info>./app/console %1\$s /path/to/fixtures</info>

The path argument can include parameters (like <info>%%kernel.root_dir%%</info>) and you can use
the bundle annotation (<info>@AcmeDemoBundle/DataFixtures/Fixtures</info>)

If you want to put all fixtures in one file you can use the <info>--single-file</info> option:

  <info>./app/console %1\$s --path=/path/to/fixtures --single-file</info>

You can also use different formats for the dumped fixtures (Available formats: <comment>%2\$s</comment>)

  <info>./app/console %1\$s --format=yml --single-file /path/to/fixtures</info>

Some formats require you to enter extra options, like the <comment>class</comment> format where
you have to specify the namespace.
EOT;
        return sprintf($help, $this->getName(), implode(', ', $generators->keys()));
    }
Esempio n. 12
0
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (!$this->getContainer()->has('security.acl.dbal.connection')) {
         return false;
     }
     return parent::isEnabled();
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (defined('HHVM_VERSION')) {
         return false;
     }
     return parent::isEnabled();
 }
 protected function configure()
 {
     parent::configure();
     $this->setName('debug:rpc_router');
     $this->setDescription('Display essential info about RPC routing');
     $this->addOption('endpoint', 'p', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Filter endpoint', null);
 }
Esempio n. 15
0
 public function __construct(SessionManagerInterface $sessionManager, SessionInterface $defaultSession, SessionInterface $liveSession)
 {
     $this->sessionManager = $sessionManager;
     $this->defaultSession = $defaultSession;
     $this->liveSession = $liveSession;
     parent::__construct();
 }
 /**
  * Set the service container, and initialize the command.
  *
  * @param ContainerInterface $container
  */
 public function setContainer(ContainerInterface $container = null)
 {
     parent::setContainer($container);
     $this->templating = $container->get('templating');
     $this->logger = $container->get('monolog.logger.processing');
     $this->ping = $container->get('ping');
 }
 public function __construct($name, $description = null)
 {
     parent::__construct($name);
     if ($description) {
         $this->setDescription($description);
     }
 }
Esempio n. 18
0
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) {
         return false;
     }
     return parent::isEnabled();
 }
Esempio n. 19
0
 /**
  * 
  * @param InputInterface $input
  * @param OutputInterface $output
  * 
  * @return void
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     declare (ticks=1);
     pcntl_signal(SIGTERM, [$this, 'stopCommand']);
     pcntl_signal(SIGINT, [$this, 'stopCommand']);
 }
Esempio n. 20
0
 /**
  * {@inheritdoc}
  */
 public function setContainer(ContainerInterface $container = null)
 {
     parent::setContainer($container);
     $this->logger = $container->get('logger');
     $this->em = $container->get('doctrine')->getManager();
     $this->filePaths = $container->get('filepaths');
 }
 /**
  * Initializes the command just after the input has been validated.
  *
  * This is mainly useful when a lot of commands extends one main command
  * where some things need to be initialized based on the input arguments and options.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->helper = $this->getHelperSet()->get('formatter');
     //        $this->rootDir = $this->getContainer()->get('kernel')->getRootDir();
     //        $this->env = $this->getContainer()->get('kernel')->getEnvironment();
 }
 /**
  * @param EventRepository      $eventRepository
  * @param EventProcessor       $eventProcessor
  * @param LockHandlerInterface $lockHandler
  * @param null|string          $name
  */
 public function __construct(EventRepository $eventRepository, EventProcessor $eventProcessor, LockHandlerInterface $lockHandler, $name = null)
 {
     $this->eventRepository = $eventRepository;
     $this->eventProcessor = $eventProcessor;
     $this->lockHandler = $lockHandler;
     parent::__construct($name);
 }
Esempio n. 23
0
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
         return false;
     }
     return parent::isEnabled();
 }
    /**
     * Configures the current command.
     */
    protected function configure()
    {
        parent::configure();
        $this->setName('kuma:user:create')->setDescription('Create a user.')->setDefinition(array(new InputArgument('username', InputArgument::REQUIRED, 'The username'), new InputArgument('email', InputArgument::REQUIRED, 'The email'), new InputArgument('password', InputArgument::REQUIRED, 'The password'), new InputArgument('locale', InputArgument::OPTIONAL, 'The locale (language)'), new InputOption('group', null, InputOption::VALUE_REQUIRED, 'The group(s) the user should belong to'), new InputOption('super-admin', null, InputOption::VALUE_NONE, 'Set the user as super admin'), new InputOption('inactive', null, InputOption::VALUE_NONE, 'Set the user as inactive')))->setHelp(<<<EOT
The <info>kuma:user:create</info> command creates a user:

  <info>php app/console kuma:user:create matthieu --group=Users</info>

This interactive shell will ask you for an email and then a password.

You can alternatively specify the email, password and locale and group as extra arguments:

  <info>php app/console kuma:user:create matthieu matthieu@example.com mypassword en --group=Users</info>

You can create a super admin via the super-admin flag:

  <info>php app/console kuma:user:create admin --super-admin --group=Administrators</info>

You can create an inactive user (will not be able to log in):

  <info>php app/console kuma:user:create thibault --inactive --group=Users</info>

<comment>Note:</comment> You have to specify at least one group.

EOT
);
    }
 public function __construct(ResourceWatcher $watcher, $watchPath, PhotoService $photoService)
 {
     $this->watcher = $watcher;
     $this->watchPath = $watchPath;
     $this->photoService = $photoService;
     parent::__construct();
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     if (trim($input->getOption('name')) == '') {
         $question = new Question\Question('Please enter the client name: ');
         $question->setValidator(function ($value) {
             if (trim($value) == '') {
                 throw new \Exception('The client name can not be empty');
             }
             $doctrine = $this->getContainer()->get('doctrine');
             $client = $doctrine->getRepository('AppBundle:Client')->findOneBy(['name' => $value]);
             if ($client instanceof \AppBundle\Entity\Client) {
                 throw new \Exception('The client name must be unique');
             }
             return $value;
         });
         $question->setMaxAttempts(5);
         $input->setOption('name', $helper->ask($input, $output, $question));
     }
     $grants = $input->getOption('grant-type');
     if (!(is_array($grants) && count($grants))) {
         $question = new Question\ChoiceQuestion('Please select the grant types (defaults to password and facebook_access_token): ', [\OAuth2\OAuth2::GRANT_TYPE_AUTH_CODE, \OAuth2\OAuth2::GRANT_TYPE_CLIENT_CREDENTIALS, \OAuth2\OAuth2::GRANT_TYPE_EXTENSIONS, \OAuth2\OAuth2::GRANT_TYPE_IMPLICIT, \OAuth2\OAuth2::GRANT_TYPE_REFRESH_TOKEN, \OAuth2\OAuth2::GRANT_TYPE_USER_CREDENTIALS, 'http://grants.api.schoolmanager.ledo.eu.org/facebook_access_token'], '5,6');
         $question->setMultiselect(true);
         $question->setMaxAttempts(5);
         $input->setOption('grant-type', $helper->ask($input, $output, $question));
     }
     parent::interact($input, $output);
 }
Esempio n. 27
0
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->basePath = $input->getArgument('write_to') ?: $this->getContainer()->getParameter('assetic.write_to');
     $this->verbose = $input->getOption('verbose');
     $this->am = $this->getContainer()->get('assetic.asset_manager');
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->communicationService = $this->getContainer()->get(CommunicationService::ID);
     $this->documentManager = $this->getContainer()->get('doctrine_mongodb')->getManager();
     $this->eventDispatcher = $this->getContainer()->get('event_dispatcher');
 }
 /**
  * @param DocumentRepository $documentRepository
  * @param ResourceGenerator  $generator
  */
 public function __construct(DocumentRepository $documentRepository, ResourceGenerator $generator)
 {
     parent::__construct(self::NAME);
     $this->setDescription('Generate DTO-like classes using the resource schema definitions in a swagger document')->setHelp('This is a development tool and will only work with require-dev dependencies included')->addArgument('file', InputArgument::REQUIRED, 'File path to the Swagger document')->addArgument('bundle', InputArgument::REQUIRED, 'Name of the bundle you want the classes in')->addOption('namespace', null, InputOption::VALUE_REQUIRED, 'Namespace of the classes to generate (relative to the bundle namespace)', 'Model\\Resources');
     $this->documentRepository = $documentRepository;
     $this->generator = $generator;
 }
 /**
  * @see Symfony\Component\Console\Command\Command::isEnabled()
  */
 public function isEnabled()
 {
     if (!$this->getContainer()->has('doctrine.odm.mongodb')) {
         return false;
     }
     return parent::isEnabled();
 }