Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $whitelist = array('name', 'description', 'author', 'require');
     $options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
     if (isset($options['author'])) {
         $options['authors'] = $this->formatAuthors($options['author']);
         unset($options['author']);
     }
     $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass();
     $file = new JsonFile('composer.json');
     $json = $file->encode($options);
     if ($input->isInteractive()) {
         $output->writeln(array('', $json, ''));
         if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $file->write($options);
     if ($input->isInteractive()) {
         $ignoreFile = realpath('.gitignore');
         if (false === $ignoreFile) {
             $ignoreFile = realpath('.') . '/.gitignore';
         }
         if (!$this->hasVendorIgnore($ignoreFile)) {
             $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]?';
             if ($dialog->askConfirmation($output, $question, true)) {
                 $this->addVendorIgnore($ignoreFile);
             }
         }
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isEnabled()) {
         $bundleName = $input->getArgument("bundle");
         $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
         /* @var $bundle BundleInterface */
         $entities = array();
         foreach ($this->getBundleMetadata($bundle) as $m) {
             /* @var $m ClassMetadata */
             $_tmp = explode('\\', $m->getName());
             $entityName = array_pop($_tmp);
             $entities[$bundleName . ':' . $entityName] = $entityName;
         }
         $command = $this->getApplication()->find('itscaro:generate:crud');
         foreach ($entities as $entityShortcut => $entityName) {
             try {
                 $_input = new ArrayInput(['command' => 'itscaro:generate:crud', '--entity' => $entityShortcut, '--route-prefix' => $input->getOption('route-prefix') . strtolower($entityName), '--with-write' => $input->getOption('with-write'), '--format' => $input->getOption('format'), '--overwrite' => $input->getOption('overwrite')]);
                 $_input->setInteractive($input->isInteractive());
                 $output->writeln("<info>Executing:</info> {$_input}");
                 $returnCode = $command->run($_input, $output);
                 $output->writeln("\t<info>Done</info>");
             } catch (\Exception $e) {
                 $output->writeln("\t<error>Error:</error> " . $e->getMessage());
             }
         }
     } else {
         $output->writeln('<error>Cannot find DoctrineBundle</error>');
     }
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $prefix = $this->getRoutePrefix($input, $entity);
     $forceOverwrite = $input->getOption('overwrite');
     $questionHelper->writeSection($output, 'REST api generation');
     $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $resource = $input->getOption('resource');
     $document = $input->getOption('document');
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0], $prefix, $forceOverwrite, $resource, $document);
     $output->writeln('Generating the REST api code: <info>OK</info>');
     $errors = array();
     // form
     $this->generateForm($bundle, $entity, $metadata);
     $output->writeln('Generating the Form code: <info>OK</info>');
     $questionHelper->writeGeneratorSummary($output, $errors);
 }
 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     $fields = $this->parseFields($input->getOption('fields'));
     if (!$input->getOption('no-summary')) {
         $questionHelper->writeSection($output, 'Entity generation');
     }
     /** @var TemplateInterface $generator */
     $generator = $this->getGenerator();
     $generator->setConfiguration('fields', $fields);
     if ($input->getOption('no-interface')) {
         $generator->setConfiguration('with_interface', false);
     }
     $errors = array();
     $runner = $questionHelper->getRunner($output, $errors);
     $runner($generator->generate($entity));
     if (!$input->getOption('no-summary')) {
         $questionHelper->writeGeneratorSummary($output, $generator->getErrors());
     }
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new Question($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     if (null === $input->getOption('controller')) {
         throw new \RuntimeException('The controller option must be provided.');
     }
     list($bundle, $controller) = $this->parseShortcutNotation($input->getOption('controller'));
     if (is_string($bundle)) {
         $bundle = Validators::validateBundleName($bundle);
         try {
             $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
         } catch (\Exception $e) {
             $output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $bundle));
         }
     }
     $questionHelper->writeSection($output, 'Controller generation');
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $controller, $input->getOption('route-format'), $input->getOption('template-format'), $this->parseActions($input->getOption('actions')));
     $output->writeln('Generating the bundle code: <info>OK</info>');
     $questionHelper->writeGeneratorSummary($output, array());
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getEntityManager();
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     $app = $this->getApp();
     $path = $app->getApplicationBase($app->getAppNamespace()) . '/DataFixture';
     $loader = new DataFixturesLoader();
     $loader->loadFromDirectory($path);
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- {$path}"));
     }
     foreach ($fixtures as $fixture) {
         if ($fixture instanceof ContainerAwareInterface) {
             $fixture->setContainer($this->getContainer());
         }
     }
     $purger = new ORMPurger($em);
     if ($input->getOption('truncate-only')) {
         $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
         $purger->purge();
         exit(0);
     }
     $purger->setPurgeMode($input->getOption('truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $confirmationQuestion = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $confirmationQuestion)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     GeneratorUtils::ensureOptionsProvided($input, array('entity', 'fields', 'prefix'));
     $entityInput = Validators::validateEntityName($input->getOption('entity'));
     list($bundleName, $entity) = $this->parseShortcutNotation($entityInput);
     $format = 'annotation';
     $fields = $this->parseFields($input->getOption('fields'));
     $prefix = $input->getOption('prefix');
     $questionHelper->writeSection($output, 'Entity generation');
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
     $generator = $this->getGenerator($this->getApplication()->getKernel()->getBundle("KunstmaanGeneratorBundle"));
     $generator->generate($bundle, $entity, $format, array_values($fields), $input->getOption('with-repository'), $prefix);
     $output->writeln('Generating the entity code: <info>OK</info>');
     $withAdminlist = $input->getOption('with-adminlist');
     if ($withAdminlist) {
         $command = $this->getApplication()->find('kuma:generate:adminlist');
         $arguments = array('command' => 'doctrine:fixtures:load', '--entity' => $entityInput);
         $input = new ArrayInput($arguments);
         $command->run($input, $output);
     }
     $questionHelper->writeGeneratorSummary($output, array());
     $output->writeln(array('Make sure you update your database first before you test the entity/adminlist:', '    Directly update your database:          <comment>app/console doctrine:schema:update --force</comment>', '    Create a Doctrine migration and run it: <comment>app/console doctrine:migrations:diff && app/console doctrine:migrations:migrate</comment>', ''));
 }
Ejemplo n.º 8
0
 private function loopBundle(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output)
 {
     $bundles = ['admin' => ['kernel' => [['bundle' => 'SKCMSAdminBundle', 'namespace' => 'SKCMS\\AdminBundle'], ['bundle' => 'IvoryCKEditorBundle', 'namespace' => 'Ivory\\CKEditorBundle'], ['bundle' => 'FMElfinderBundle', 'namespace' => 'FM\\ElfinderBundle'], ['bundle' => 'StofDoctrineExtensionsBundle', 'namespace' => 'Stof\\DoctrineExtensionsBundle']], 'config' => ['loadSkCMSAdmin', 'loadCKEditor', 'loadDoctrineFunctions'], 'route' => ['routeAdmin']], 'user' => ['kernel' => [['bundle' => 'SKCMSUserBundle', 'namespace' => 'SKCMS\\UserBundle'], ['bundle' => 'FOSUserBundle', 'namespace' => 'FOS\\UserBundle']], 'config' => ['loadFosUser', 'setSecurity'], 'route' => ['routeUser']], 'contact' => ['kernel' => [['bundle' => 'SKCMSContactBundle', 'namespace' => 'SKCMS\\ContactBundle']], 'config' => ['loadSKContact'], 'route' => ['routeContact']], 'tracking' => ['kernel' => [['bundle' => 'SKCMSTrackingBundle', 'namespace' => 'SKCMS\\TrackingBundle']], 'route' => ['routeTracking']], 'shop' => ['kernel' => [['bundle' => 'SKCMSShopBundle', 'namespace' => 'SKCMS\\ShopBundle']], 'route' => ['routeShop']], 'front' => ['kernel' => [['bundle' => 'SKCMSFrontBundle', 'namespace' => 'SKCMS\\FrontBundle']], 'route' => ['routeFront']]];
     foreach ($bundles as $bundleName => $bundle) {
         if ($input->isInteractive()) {
             $question = new ConfirmationQuestion($questionHelper->getQuestion('Install ' . $bundleName . ' (kernel + config)', 'yes', '?'), true);
             $auto = $questionHelper->ask($input, $output, $question);
             $this->module_installed = $auto;
         }
         if ($auto) {
             foreach ($bundle['kernel'] as $bundleKernel) {
                 $kernelUpdate = $this->updateKernel($this->getContainer()->get('kernel'), $bundleKernel['namespace'], $bundleKernel['bundle']);
             }
             if (array_key_exists('config', $bundle) && is_array($bundle['config'])) {
                 foreach ($bundle['config'] as $configMethod) {
                     call_user_func([$this, $configMethod]);
                 }
             }
             if (array_key_exists('route', $bundle) && is_array($bundle['route'])) {
                 foreach ($bundle['route'] as $routeMethod) {
                     call_user_func([$this, $routeMethod]);
                 }
             }
         }
     }
 }
 public function interactWith(FormInterface $form, HelperSet $helperSet, InputInterface $input, OutputInterface $output)
 {
     if (!$form->isRoot()) {
         throw new CanNotInteractWithForm('This interactor only works with root forms');
     }
     if ($input->isInteractive()) {
         throw new CanNotInteractWithForm('This interactor only works with non-interactive input');
     }
     /*
      * We need to adjust the input values for repeated types by copying the provided value to both of the repeated
      * fields. We only loop through the top-level fields, since there are no command options for deeper lying fields
      * anyway.
      *
      * The fix was provided by @craigh
      *
      * P.S. If we need to add another fix like this, we should move this out to dedicated "input fixer" classes.
      */
     foreach ($form->all() as $child) {
         $config = $child->getConfig();
         $name = $child->getName();
         if ($config->getType()->getInnerType() instanceof RepeatedType && $input->hasOption($name)) {
             $input->setOption($name, [$config->getOption('first_name') => $input->getOption($name), $config->getOption('second_name') => $input->getOption($name)]);
         }
     }
     // use the original input as the submitted data
     return $input;
 }
 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     if ($input->isInteractive()) {
         if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     $translationEntity = Validators::validateEntityName(sprintf('%sTranslation', $input->getOption('entity')));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     list($translationBundle, $translationEntity) = $this->parseShortcutNotation($translationEntity);
     $format = Validators::validateFormat($input->getOption('format'));
     $fields = $this->parseFields($input->getOption('fields'));
     $translatableFields = $this->parseFields($input->getOption('translatable-fields'));
     $dialog->writeSection($output, 'Entities generation');
     $kernel = $this->getContainer()->get('kernel');
     $bundle = $kernel->getBundle($bundle);
     $translationBundle = $kernel->getBundle($translationBundle);
     /** @var OrkestroEntityGenerator $generator */
     $generator = $this->getGenerator();
     $generator->generateTranslatable($bundle, $entity, $translationEntity, $format, array_values($fields), array_values($translatableFields), $input->getOption('with-repository'));
     $output->writeln('Generating the entities code: <info>OK</info>');
     $dialog->writeGeneratorSummary($output, array());
 }
Ejemplo n.º 11
0
 /**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
 }
    protected function getBootstrapPathsFromUser()
    {
        $symlinkTarget = $this->input->getArgument('pathTo' . static::$pathName);
        $symlinkName = $this->input->getArgument('pathToMopaBootstrapBundle');
        if (empty($symlinkName)) {
            throw new \Exception("pathToMopaBootstrapBundle not specified");
        }
        if (!is_dir(dirname($symlinkName))) {
            throw new \Exception("pathToMopaBootstrapBundle: " . dirname($symlinkName) . " does not exist");
        }
        if (empty($symlinkTarget)) {
            throw new \Exception(static::$pathName . " not specified");
        }
        if (substr($symlinkTarget, 0, 1) == "/") {
            $this->output->writeln("<comment>Try avoiding absolute paths, for portability!</comment>");
            if (!is_dir($symlinkTarget)) {
                throw new \Exception("Target path " . $symlinkTarget . "is not a directory!");
            }
        } else {
            $symlinkTarget = $symlinkName . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . $symlinkTarget;
        }
        if (!is_dir($symlinkTarget)) {
            throw new \Exception(static::$pathName . " would resolve to: " . $symlinkTarget . "\n and this is not reachable from \npathToMopaBootstrapBundle: " . dirname($symlinkName));
        }
        $dialog = $this->getHelperSet()->get('dialog');
        $text = <<<EOF
Creating the symlink: {$symlinkName}
Pointing to: {$symlinkTarget}
EOF;
        $this->output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock($text, 'bg=blue;fg=white', true), ''));
        if ($this->input->isInteractive() && !$dialog->askConfirmation($this->output, '<question>Should this link be created? (y/n)</question>', false)) {
            throw new \Exception("Aborting due to User not cofirming!");
        }
        return array($symlinkTarget, $symlinkName);
    }
Ejemplo n.º 13
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $origin = $input->getOption('origin');
     $force = $input->getOption('force');
     $interactive = $input->isInteractive();
     $this->logger->pushHandler(new ConsoleHandler($output));
     $dispatcher = $this->sourceCleaner->getEventDispatcher();
     // listen to clean event
     $dispatcher->addListener(IoEvents::PRE_CLEAN_SOURCE, function (SourceEvent $event) use($output) {
         $source = $event->getSource();
         $output->writeln(sprintf('<fg=red>- %s:%s</>', $source->getOrigin()->getName(), $source->getOriginalId()));
     });
     if ($force) {
         $voter = new ThresholdVoter(function () {
             return true;
         }, $dispatcher);
     } else {
         $voter = new ThresholdVoter(function ($count, $total, $max, $message) use($output, $interactive) {
             $output->writeln($message);
             // see if we can ask the user to confirm cleanup
             $question = '<question>> Clean these sources anyway? [y]</question> ';
             return $interactive && $this->getDialogHelper()->askConfirmation($output, $question);
         }, $dispatcher);
     }
     $numCleaned = $this->clean($voter, $origin);
     $output->writeln(sprintf('<info>%s</info> sources cleaned', $numCleaned));
     return 0;
 }
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When namespace doesn't end with Bundle
  * @throws \RuntimeException         When bundle can't be executed
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         if (!$questionHelper->ask($input, $output, new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true))) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     foreach (array('target-bundle', 'fieldtype-name') as $option) {
         if (null === $input->getOption($option)) {
             throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
         }
     }
     $generator = $this->getGenerator();
     $generator->generate($input->getOption('target-bundle'), $input->getOption('target-bundle-dir'), $input->getOption('fieldtype-name'), $input->getOption('fieldtype-name'));
     $output->writeln('Generating the FieldType code: <info>OK</info>');
     //        $errors = array();
     //        $runner = $questionHelper->getRunner($output, $errors);
     //
     //        // check that the namespace is already autoloaded
     //        $runner($this->checkAutoloader($output, $namespace, $bundle, $dir));
     //
     //        // register the bundle in the Kernel class
     //        $runner($this->updateKernel($questionHelper, $input, $output, $this->getContainer()->get('kernel'), $namespace, $bundle));
     //
     //        // routing
     //        $runner($this->updateRouting($questionHelper, $input, $output, $bundle, $format));
     //
     //        $questionHelper->writeGeneratorSummary($output, $errors);
 }
 /**
  * {@inheritDoc}
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var DialogHelper $dialog */
     $dialog = $this->getHelperSet()->get('dialog');
     $wsdl = Validators::validateWsdl($input->getOption('wsdl'));
     $dir = Validators::validateTargetDir($input->getOption('dir'));
     $namespace = Validators::validateNamespace($input->getOption('namespace'));
     $licensePath = Validators::validateLicensePath($input->getOption('license-path'));
     if ($input->isInteractive()) {
         $this->writeSection($output, array(sprintf('Path to the wsdl file: "%s"', $wsdl), sprintf('The directory where to create proxy classes: "%s"', $dir), sprintf('The namespace of proxy classes to create: "%s"', $namespace)));
         if (!$dialog->askConfirmation($output, $this->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $generator = new SimpleTypeAbstractGenerator($wsdl, $dir . 'SimpleType', $namespace . '\\SimpleType', array(), $licensePath);
     $generator->execute();
     $generator = new ComplexTypeAbstractGenerator($wsdl, $dir . 'ComplexType', $namespace . '\\ComplexType', array($namespace . '\\SimpleType'), $licensePath);
     $generator->execute();
     $generator = new SimpleTypeGenerator($wsdl, $dir . 'SimpleType', $namespace . '\\SimpleType', array(), $licensePath);
     $generator->execute();
     $generator = new ComplexTypeGenerator($wsdl, $dir . 'ComplexType', $namespace . '\\ComplexType', array($namespace . '\\SimpleType'), $licensePath);
     $generator->execute();
     $generator = new SoapClientGenerator($wsdl, $dir, $namespace, array('RuntimeException', 'SoapFault', 'SoapClient as BaseSoapClient'), $licensePath);
     $generator->execute();
     $generator = new SoapServiceGenerator($wsdl, $dir, $namespace, array('RuntimeException', 'SoapFault', 'SoapClient as BaseSoapClient', 'InvalidArgumentException'), $licensePath);
     $generator->execute();
     unset($generator);
 }
 function it_does_not_activate_the_pauser_if_input_is_not_interactive(InputInterface $input, OutputInterface $output, Pauser $pauser)
 {
     $input->getOption('step-through')->willReturn(true);
     $input->isInteractive()->willReturn(false);
     $this->execute($input, $output);
     $pauser->activate()->shouldNotHaveBeenCalled();
 }
Ejemplo n.º 17
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $command = $this->getApplication()->find('translations:fetch');
     $arguments = array('command' => 'translations:fetch', '--username' => $input->getOption('username'), '--password' => $input->getOption('password'), '--keep-english' => true);
     $inputObject = new ArrayInput($arguments);
     $inputObject->setInteractive($input->isInteractive());
     $command->run($inputObject, $output);
     $englishFromOTrance = FetchFromOTrance::getDownloadPath() . DIRECTORY_SEPARATOR . 'en.json';
     if (!file_exists($englishFromOTrance)) {
         $output->writeln("English file from oTrance missing. Aborting");
         return;
     }
     $englishFromOTrance = json_decode(file_get_contents($englishFromOTrance), true);
     Translate::reloadLanguage('en');
     $availableTranslations = $GLOBALS['Piwik_translations'];
     $categories = array_unique(array_merge(array_keys($englishFromOTrance), array_keys($availableTranslations)));
     sort($categories);
     $unnecessary = $outdated = $missing = array();
     foreach ($categories as $category) {
         if (!empty($englishFromOTrance[$category])) {
             foreach ($englishFromOTrance[$category] as $key => $value) {
                 if (!array_key_exists($category, $availableTranslations) || !array_key_exists($key, $availableTranslations[$category])) {
                     $unnecessary[] = sprintf('%s_%s', $category, $key);
                     continue;
                 } else {
                     if (html_entity_decode($availableTranslations[$category][$key]) != html_entity_decode($englishFromOTrance[$category][$key])) {
                         $outdated[] = sprintf('%s_%s', $category, $key);
                         continue;
                     }
                 }
             }
         }
         if (!empty($availableTranslations[$category])) {
             foreach ($availableTranslations[$category] as $key => $value) {
                 if (!array_key_exists($category, $englishFromOTrance) || !array_key_exists($key, $englishFromOTrance[$category])) {
                     $missing[] = sprintf('%s_%s', $category, $key);
                     continue;
                 }
             }
         }
     }
     $output->writeln("");
     if (!empty($missing)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are missing on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $missing));
         $output->writeln("");
     }
     if (!empty($unnecessary)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys might be unnecessary on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $unnecessary));
         $output->writeln("");
     }
     if (!empty($outdated)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are outdated on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $outdated));
         $output->writeln("");
     }
     $output->writeln("Finished.");
 }
Ejemplo n.º 18
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $noInitialize = $input->getOption('no-initialize');
     $append = $input->getOption('append');
     if ($input->isInteractive() && !$append) {
         $dialog = $this->getHelperSet()->get('dialog');
         $confirmed = $dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false);
         if (!$confirmed) {
             return 0;
         }
     }
     $paths = $input->getOption('fixtures');
     $candidatePaths = [];
     if (!$paths) {
         $paths = [];
         foreach ($this->kernel->getBundles() as $bundle) {
             $candidatePath = $bundle->getPath() . '/DataFixtures/Document';
             $candidatePaths[] = $candidatePath;
             if (file_exists($candidatePath)) {
                 $paths[] = $candidatePath;
             }
         }
     }
     if (empty($paths)) {
         $output->writeln('<info>Could not find any candidate fixture paths.</info>');
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('Looked for: </comment>%s<comment>"</comment>', implode('"<comment>", "</comment>', $candidatePaths)));
         }
         return 0;
     }
     $fixtures = $this->loader->load($paths);
     $this->executor->execute($fixtures, false === $append, false === $noInitialize, $output);
     $output->writeln('');
     $output->writeln(sprintf('<info>Done. Executed </info>%s</info><info> fixtures.</info>', count($fixtures)));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     # static mvc
     $mvc = MVCStore::retrieve('mvc');
     # get helper set
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         #$question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         $question = new ConfirmationQuestion('Do you confirm generation? (yes or no): yes ', true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $modelName = Validators::validateEntityName($input->getOption('name'));
     list($module, $modelName) = $this->parseShortcutNotation($modelName);
     $format = Validators::validateFormat($input->getOption('format'));
     $fields = $this->parseFields($input->getOption('fields'));
     $output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock('Entity generation', 'bg=blue;fg=white', true), ''));
     $module = $mvc->getModule($module);
     if ('dbal' == strtolower($input->getOption('type'))) {
         $generator = new DBALGenerator();
         $generator->generate($module, $modelName, array($fields));
     } else {
         if ('orm' == strtolower($input->getOption('type'))) {
             $generator = new ORMGenerator();
         } else {
             $generator = new PDOGenerator();
             $generator->generate($module, $modelName, array($fields));
         }
     }
     $output->writeln('Generating the entity code: <info>OK</info>');
     $output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock('You can now start using the generated code!', 'bg=blue;fg=white', true), ''));
 }
Ejemplo n.º 20
0
 /**
  * {@inheritDoc}
  * Add the new bundle to the BundleBundle loader infrastructure instead of main kernel
  *
  * @param QuestionHelper  $questionHelper dialog
  * @param InputInterface  $input          input
  * @param OutputInterface $output         output
  * @param KernelInterface $kernel         kernel
  * @param string          $namespace      namespace
  * @param string          $bundle         bundle
  *
  * @return string[]
  */
 protected function updateKernel(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle)
 {
     // skip if kernel manipulation disabled by options (defaults to true)
     $doUpdate = $input->getOption('doUpdateKernel');
     if ($doUpdate == 'false') {
         return;
     }
     $auto = true;
     if ($input->isInteractive()) {
         $auto = $questionHelper->doAsk($output, $questionHelper->getQuestion('Confirm automatic update of your core bundle', 'yes', '?'));
     }
     $output->write('Enabling the bundle inside the core bundle: ');
     $coreBundle = $kernel->getBundle($input->getOption('loaderBundleName'));
     if (!is_a($coreBundle, '\\Graviton\\BundleBundle\\GravitonBundleInterface')) {
         throw new \LogicException('GravitonCoreBundle does not implement GravitonBundleInterface');
     }
     $manip = new BundleBundleManipulator($coreBundle);
     try {
         $ret = $auto ? $manip->addBundle($namespace . '\\' . $bundle) : false;
         if (!$ret) {
             $reflected = new \ReflectionObject($kernel);
             return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), '  and add the following bundle in the <comment>GravitonCoreBundle::getBundles()</comment> method:', '', sprintf('    <comment>new %s(),</comment>', $namespace . '\\' . $bundle), '');
         }
     } catch (\RuntimeException $e) {
         return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>%s)</comment>.', $namespace . '\\' . $bundle, 'sGravitonCoreBundle::getBundles()'), '');
     }
 }
Ejemplo n.º 21
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rc = 0;
     try {
         if (!$input->getOption('force')) {
             if (!$input->isInteractive()) {
                 throw new Exception("You have to specify the --force option in order to run this command");
             }
             $confirmQuestion = new ConfirmationQuestion('Are you sure you want to update this concrete5 installation?');
             if (!$this->getHelper('question')->ask($input, $output, $confirmQuestion)) {
                 throw new Exception("Operation aborted.");
             }
         }
         $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
         $output = new ConsoleOutput();
         $configuration->setOutputWriter(new OutputWriter(function ($message) use($output) {
             $output->writeln($message);
         }));
         Update::updateToCurrentVersion($configuration);
     } catch (Exception $x) {
         $output->writeln('<error>' . $x->getMessage() . '</error>');
         $rc = 1;
     }
     return $rc;
 }
Ejemplo n.º 22
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm setup', 'yes', '?'));
         if (!$questionHelper->ask($input, $output, $question, true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     foreach (array('username', 'email', 'password') as $option) {
         if (null === $input->getOption($option)) {
             throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
         }
     }
     $output->writeln('Installing <comment>components</comment>.');
     $output->writeln('Setting up default images.');
     $images = $this->getContainer()->get('teapotio.image')->setup();
     $output->writeln('Setting up default groups.');
     $groups = $this->getContainer()->get('teapotio.user.group')->setup();
     $output->writeln('Setting up default user.');
     $username = $input->getOption('username');
     $email = $input->getOption('email');
     $password = $input->getOption('password');
     $users = $this->getContainer()->get('teapotio.user')->setup($username, $email, $password, $groups, $images);
     if ($input->getOption('default-topic-board')) {
         $output->writeln('Setting up default board and topic.');
         $boards = $this->getContainer()->get('teapotio.forum.board')->setup($users[0]);
         $this->getContainer()->get('teapotio.forum.topic')->setup($users[0], $boards[0]);
     }
 }
Ejemplo n.º 23
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $index = $input->getOption('index');
     $type = $input->getOption('type');
     $reset = !$input->getOption('no-reset');
     $options = array('ignore_errors' => $input->getOption('ignore-errors'), 'offset' => $input->getOption('offset'), 'sleep' => $input->getOption('sleep'));
     if ($input->getOption('batch-size')) {
         $options['batch_size'] = (int) $input->getOption('batch-size');
     }
     if ($input->isInteractive() && $reset && $input->getOption('offset')) {
         /** @var DialogHelper $dialog */
         $dialog = $this->getHelperSet()->get('dialog');
         if (!$dialog->askConfirmation($output, '<question>You chose to reset the index and start indexing with an offset. Do you really want to do that?</question>', true)) {
             return;
         }
     }
     if (null === $index && null !== $type) {
         throw new \InvalidArgumentException('Cannot specify type option without an index.');
     }
     if (null !== $index) {
         if (null !== $type) {
             $this->populateIndexType($output, $index, $type, $reset, $options);
         } else {
             $this->populateIndex($output, $index, $reset, $options);
         }
     } else {
         $indexes = array_keys($this->indexManager->getAllIndexes());
         foreach ($indexes as $index) {
             $this->populateIndex($output, $index, $reset, $options);
         }
     }
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive() && !$input->getOption('no-summary')) {
         $question = new Question($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     if (null === $input->getOption('controller')) {
         throw new \RuntimeException('The controller option must be provided.');
     }
     list($bundle) = $this->parseShortcutNotation($input->getOption('controller'));
     if (is_string($bundle)) {
         $bundle = Validators::validateBundleName($bundle);
         try {
             $this->getContainer()->get('kernel')->getBundle($bundle);
         } catch (\Exception $e) {
             $output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $bundle));
         }
     }
     /** @var TemplateInterface $generator */
     $generator = $this->getGenerator();
     $questionHelper->writeSection($output, 'Controller generation');
     $errors = array();
     $runner = $questionHelper->getRunner($output, $errors);
     $runner($generator->generate($input->getOption('controller')));
     if (!$input->getOption('no-summary')) {
         $questionHelper->writeGeneratorSummary($output, $generator->getErrors());
     }
 }
Ejemplo n.º 25
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $grumphpConfigName = $this->input->getOption('config');
     if ($this->filesystem->exists($grumphpConfigName)) {
         if ($input->isInteractive()) {
             $output->writeln('<fg=yellow>GrumPHP is already configured!</fg=yellow>');
         }
         return;
     }
     // Check configuration:
     $configuration = $this->buildConfiguration($input, $output);
     if (!$configuration) {
         $output->writeln('<fg=yellow>Skipped configuring GrumPHP. Using default configuration.</fg=yellow>');
         return;
     }
     // Check write action
     $written = $this->writeConfiguration($configuration);
     if (!$written) {
         $output->writeln('<fg=red>The configuration file could not be saved. Give me some permissions!</fg=red>');
         return;
     }
     if ($input->isInteractive()) {
         $output->writeln('<fg=green>GrumPHP is configured and ready to kick ass!</fg=green>');
     }
 }
Ejemplo n.º 26
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getArgument('user');
     /** @var $user \OC\User\User */
     $user = $this->userManager->get($username);
     if (is_null($user)) {
         $output->writeln("<error>There is no user called " . $username . "</error>");
         return 1;
     }
     if ($input->isInteractive()) {
         /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
         $dialog = $this->getHelperSet()->get('dialog');
         $password = $dialog->askHiddenResponse($output, '<question>Enter a new password: </question>', false);
         $confirm = $dialog->askHiddenResponse($output, '<question>Confirm the new password: </question>', false);
         if ($password === $confirm) {
             $success = $user->setPassword($password);
             if ($success) {
                 $output->writeln("<info>Successfully reset password for " . $username . "</info>");
             } else {
                 $output->writeln("<error>Error while resetting password!</error>");
                 return 1;
             }
         } else {
             $output->writeln("<error>Passwords did not match!</error>");
             return 1;
         }
     } else {
         $output->writeln("<error>Interactive input is needed for entering a new password!</error>");
         return 1;
     }
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Etes vous sûr de vouloir lancer la génération ?', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Commande stopée</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $questionHelper->writeSection($output, 'Génération du CRUD');
     $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $prefix = $this->getRoutePrefix($input, $entity);
     $appDir = $this->getContainer()->get('kernel')->getRootdir();
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0], $prefix, $appDir);
     $output->writeln('Génératon du code CRUD: <info>OK</info>');
     $output->write('Génératon du code FormType: ');
     if ($this->generateForm($bundle, $entity, $metadata)) {
         $output->writeln('<info>OK</info>');
     } else {
         $output->writeln('<comment>FormType déjà existant !</comment>');
     }
     $output->writeln('Vous pouvez maintenant commencer à utiliser le code généré!');
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     if ($input->isInteractive()) {
         if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $format = 'annotation';
     $prefix = $this->getRoutePrefix($input, $entity);
     $withWrite = $input->getOption('with-write');
     $forceOverwrite = $input->getOption('overwrite');
     $dialog->writeSection($output, 'CRUD generation');
     $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0], $format, $prefix, $withWrite, $forceOverwrite);
     $output->writeln('Generating the CRUD code: <info>OK</info>');
     $errors = array();
     $runner = $dialog->getRunner($output, $errors);
     $dialog->writeGeneratorSummary($output, $errors);
 }
Ejemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->inputOptionProvider = new InputOptionProvider($output, $input, $this->getHelperSet()->get('dialog'));
     if (false === $input->isInteractive()) {
         $this->validate($input);
     }
     $forceInstall = $input->getOption('force');
     $commandExecutor = new CommandExecutor($input->hasOption('env') ? $input->getOption('env') : null, $output, $this->getApplication(), $this->getContainer()->get('oro_cache.oro_data_cache_manager'));
     $commandExecutor->setDefaultTimeout($input->getOption('timeout'));
     // if there is application is not installed or no --force option
     $isInstalled = $this->getContainer()->hasParameter('installed') && $this->getContainer()->getParameter('installed');
     if ($isInstalled && !$forceInstall) {
         $output->writeln('<comment>ATTENTION</comment>: Oro Application already installed.');
         $output->writeln('To proceed with install - run command with <info>--force</info> option:');
         $output->writeln(sprintf('    <info>%s --force</info>', $this->getName()));
         $output->writeln('To reinstall over existing database - run command with <info>--force --drop-database</info> options:');
         $output->writeln(sprintf('    <info>%s --force --drop-database</info>', $this->getName()));
         $output->writeln('<comment>ATTENTION</comment>: All data will be lost. ' . 'Database backup is highly recommended before executing this command.');
         $output->writeln('');
         return;
     }
     if ($forceInstall) {
         // if --force option we have to clear cache and set installed to false
         $this->updateInstalledFlag(false);
         $commandExecutor->runCommand('cache:clear', array('--no-optional-warmers' => true, '--process-isolation' => true));
     }
     $output->writeln('<info>Installing Oro Application.</info>');
     $output->writeln('');
     $this->checkStep($output)->prepareStep($commandExecutor, $input->getOption('drop-database'))->loadDataStep($commandExecutor, $output)->finalStep($commandExecutor, $output, $input);
     $output->writeln('');
     $output->writeln(sprintf('<info>Oro Application has been successfully installed in <comment>%s</comment> mode.</info>', $input->getOption('env')));
     if ('prod' != $input->getOption('env')) {
         $output->writeln('<info>To run application in <comment>prod</comment> mode, ' . 'please run <comment>cache:clear</comment> command with <comment>--env prod</comment> parameter</info>');
     }
 }
Ejemplo n.º 30
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $logger = $this->getContainer()->get('erpdataio.logger');
     $logger->log('ERP data import command executed');
     if ($input->isInteractive()) {
         $helper = $this->getHelper('question');
         $question = new ConfirmationQuestion('Careful, database will be purged. Do you want to continue Y/N ? ', false);
         if (!$helper->ask($input, $output, $question)) {
             return;
         }
     }
     $paths = array();
     foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
         $paths[] = $bundle->getPath() . '/DataFixtures/ERP';
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to execute in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $dataImporterManager = $this->getContainer()->get('erpdataio.importer');
     foreach ($fixtures as $fixture) {
         $dataImporterManager->loadData($fixture);
     }
     $output->writeln('OK');
 }