Creates default payment methods entities.

@param OutputInterface $output
@throws \Exception
163193
private function createPaymentMethods(OutputInterface $output)
    {
        $em = $this->container->get('ekyna_payment.method.manager');
        //$registry = $this->container->get('payum');
        $methodRepository = $this->container->get('ekyna_payment.method.repository');
        $mediaRepository = $this->container->get('ekyna_media.media.repository');

        $folder = $this->createImageFolder();
        $imageDir = realpath(__DIR__.'/../Resources/asset/img');

        $methods = [
            'Chèque'   => [
                'offline',
                'cheque.png',
                '<p>Veuillez adresser votre chèque à l\'ordre de ...</p>',
                true
            ],
            'Virement' => [
                'offline',
                'virement.png',
                '<p>Veuillez adresser votre virement à l\'ordre de ...</p>',
                true
            ],
            'Paypal'   => [
                'paypal_express_checkout_nvp',
                'paypal.png',
                '<p>Réglez avec votre compte paypal, ou votre carte bancaire.</p>',
                false
            ],
        ];

        if (class_exists('Ekyna\Bundle\PayumSipsBundle\EkynaPayumSipsBundle')) {
            $methods['Carte bancaire'] = [
                'atos_sips',
                'credit-card.png',
                '<p>Réglez avec votre carte bancaire.</p>',
                false
            ];
        }

        foreach ($methods as $name => $options) {
            $output->write(sprintf(
                '- <comment>%s</comment> %s ',
                $name,
                str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT)
            ));

            // TODO check that factory method exists

            if (null !== $method = $methodRepository->findOneBy(['gatewayName' => $name])) {
                $output->writeln('already exists.');
                continue;
            }

            $source = $imageDir.'/'.$options[1];
            if (!file_exists($source)) {
                throw new \Exception(sprintf('File "%s" does not exists.', $source));
            }
            $target = sys_get_temp_dir() . '/' . $options[1];
            if (!copy($source, $target)) {
                throw new \Exception(sprintf('Failed to copy "%s" into "%s".', $source, $target));
            }

            /** @var \Ekyna\Bundle\MediaBundle\Model\MediaInterface $image */
            $image = $mediaRepository->createNew();
            $image
                ->setFile(new File($target))
                ->setFolder($folder)
                ->setTitle($name)
                ->setType(MediaTypes::IMAGE)
            ;

            /** @var \Ekyna\Bundle\PaymentBundle\Entity\Method $method */
            $method = $methodRepository->createNew();
            $method
                ->setGatewayName($name)
                ->setFactoryName($options[0])
                ->setMedia($image)
                ->setDescription($options[2])
                ->setEnabled($options[3])
            ;

            $em->persist($method);

            $output->writeln('created.');
        }
        $em->flush();
    }
406816
private function createAclRules(OutputInterface $output)
    {
        $registry = $this->container->get('ekyna_admin.pool_registry');
        $aclOperator = $this->container->get('ekyna_admin.acl_operator');
        $groups = $this->container->get('ekyna_user.group.repository')->findAll();

        // TODO disallow on ekyna_user.group for non super admin.

        /** @var \Ekyna\Bundle\UserBundle\Entity\Group $group */
        foreach ($groups as $group) {
            if (isset($this->defaultGroups[$group->getName()])) {
                $permission = $this->defaultGroups[$group->getName()][1];
            } else {
                continue;
            }
            $datas = [];
            foreach ($registry->getConfigurations() as $id => $config) {
                $datas[$id] = [$permission => true];
            }
            $aclOperator->updateGroup($group, $datas);
        }

        $output->writeln('Acl rules have been successfully generated.');
    }
6138
protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::execute($input, $output);

        $session = $this->mustBeModelManagerSession($this->getSession());

        $this->updateOutput(
            $output,
            (new StructureGenerator(
                $session,
                $this->schema,
                $this->relation,
                $this->getPathFile($input->getArgument('config-name'), $this->relation, null, 'AutoStructure', $input->getOption('psr4')),
                $this->getNamespace($input->getArgument('config-name'), 'AutoStructure')
            ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions())))
        );

        $pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, 'Model', '', $input->getOption('psr4'));
        if (!file_exists($pathFile) || $input->getOption('force')) {
            $this->updateOutput(
                $output,
                (new ModelGenerator(
                    $session,
                    $this->schema,
                    $this->relation,
                    $pathFile,
                    $this->getNamespace($input->getArgument('config-name'))
                ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions())))
            );
        } elseif ($output->isVerbose()) {
            $this->writelnSkipFile($output, $pathFile, 'model');
        }

        $pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, '', '', $input->getOption('psr4'));
        if (!file_exists($pathFile) || $input->getOption('force')) {
            $this->updateOutput(
                $output,
                (new EntityGenerator(
                    $session,
                    $this->schema,
                    $this->relation,
                    $pathFile,
                    $this->getNamespace($input->getArgument('config-name')),
                    $this->flexible_container
                ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions())))
            );
        } elseif ($output->isVerbose()) {
            $this->writelnSkipFile($output, $pathFile, 'entity');
        }
    }
458761
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->setOutput($output);
        $this->setVerbosity($output->getVerbosity());

        if (!$input->getOption('add') && !$input->getOption('delete') && !$input->getOption('skip') && !$input->getOption('info')) {
            throw new \InvalidArgumentException('You must specify whether you want to --add, --delete, --skip or --info the specified migration.');
        }

        $migrationService = $this->getMigrationService();
        $migrationNameOrPath = $input->getArgument('migration');

        if ($input->getOption('info')) {
            $output->writeln('');

            $migration = $migrationService->getMigration($migrationNameOrPath);
            if ($migration == null) {
                throw new \InvalidArgumentException(sprintf('The migration "%s" does not exist in the migrations table.', $migrationNameOrPath));
            }

            switch ($migration->status) {
                case Migration::STATUS_DONE:
                    $status = '<info>executed</info>';
                    break;
                case Migration::STATUS_STARTED:
                    $status = '<comment>execution started</comment>';
                    break;
                case Migration::STATUS_TODO:
                    // bold to-migrate!
                    $status = '<error>not executed</error>';
                    break;
                case Migration::STATUS_SKIPPED:
                    $status = '<comment>skipped</comment>';
                    break;
                case Migration::STATUS_PARTIALLY_DONE:
                    $status = '<comment>partially executed</comment>';
                    break;
                case Migration::STATUS_SUSPENDED:
                    $status = '<comment>suspended</comment>';
                    break;
                case Migration::STATUS_FAILED:
                    $status = '<error>failed</error>';
                    break;
            }

            $output->writeln('<info>Migration: ' . $migration->name . '</info>');
            $output->writeln('Status: ' . $status);
            $output->writeln('Executed on: <info>' . ($migration->executionDate != null ? date("Y-m-d H:i:s", $migration->executionDate) : '--'). '</info>');
            $output->writeln('Execution notes: <info>' . $migration->executionError . '</info>');

            if ($migration->status == Migration::STATUS_SUSPENDED) {
                /// @todo decode the suspension context: date, step, ...
            }

            $output->writeln('Definition path: <info>' . $migration->path . '</info>');
            $output->writeln('Definition md5: <info>' . $migration->md5 . '</info>');

            if ($migration->path != '') {
                // q: what if we have a loader which does not work with is_file? We could probably remove this check...
                if (is_file($migration->path)) {
                    try {
                        $migrationDefinitionCollection = $migrationService->getMigrationsDefinitions(array($migration->path));
                        if (count($migrationDefinitionCollection)) {
                            $migrationDefinition = reset($migrationDefinitionCollection);
                            $migrationDefinition = $migrationService->parseMigrationDefinition($migrationDefinition);

                            if ($migrationDefinition->status != MigrationDefinition::STATUS_PARSED) {
                                $output->writeln('Definition error: <error>' . $migrationDefinition->parsingError . '</error>');
                            }

                            if (md5($migrationDefinition->rawDefinition) != $migration->md5) {
                                $output->writeln('Notes: <comment>The migration definition file has now a different checksum</comment>');
                            }
                        } else {
                            $output->writeln('Definition error: <error>The migration definition file can not be loaded</error>');
                        }
                    } catch (\Exception $e) {
                        /// @todo one day we should be able to limit the kind of exceptions we have to catch here...
                        $output->writeln('Definition parsing error: <error>' . $e->getMessage() . '</error>');
                    }
                } else {
                    $output->writeln('Definition error: <error>The migration definition file can not be found any more</error>');
                }
            }

            $output->writeln('');
            return 0;
        }

        // ask user for confirmation to make changes
        if ($input->isInteractive() && !$input->getOption('no-interaction')) {
            $dialog = $this->getHelperSet()->get('question');
            if (!$dialog->ask(
                $input,
                $output,
                new ConfirmationQuestion('<question>Careful, the database will be modified. Do you want to continue Y/N ?</question>', false)
            )
            ) {
                $output->writeln('<error>Migration change cancelled!</error>');
                return 0;
            }
        }

        if ($input->getOption('add')) {
            // will throw if a file is passed and it is not found, but not if an empty dir is passed
            $migrationDefinitionCollection = $migrationService->getMigrationsDefinitions(array($migrationNameOrPath));

            if (!count($migrationDefinitionCollection))
            {
                throw new \InvalidArgumentException(sprintf('The path "%s" does not correspond to any migration definition.', $migrationNameOrPath));
            }

            foreach ($migrationDefinitionCollection as $migrationDefinition) {
                $migrationName = basename($migrationDefinition->path);

                $migration = $migrationService->getMigration($migrationNameOrPath);
                if ($migration != null) {
                    throw new \InvalidArgumentException(sprintf('The migration "%s" does already exist in the migrations table.', $migrationName));
                }

                $migrationService->addMigration($migrationDefinition);
                $output->writeln('<info>Added migration' . $migrationDefinition->path . '</info>');
            }

            return 0;
        }

        if ($input->getOption('delete')) {
            $migration = $migrationService->getMigration($migrationNameOrPath);
            if ($migration == null) {
                throw new \InvalidArgumentException(sprintf('The migration "%s" does not exist in the migrations table.', $migrationNameOrPath));
            }

            $migrationService->deleteMigration($migration);

            return 0;
        }

        if ($input->getOption('skip')) {
            // will throw if a file is passed and it is not found, but not if an empty dir is passed
            $migrationDefinitionCollection = $migrationService->getMigrationsDefinitions(array($migrationNameOrPath));

            if (!count($migrationDefinitionCollection))
            {
                throw new \InvalidArgumentException(sprintf('The path "%s" does not correspond to any migration definition.', $migrationNameOrPath));
            }

            foreach ($migrationDefinitionCollection as $migrationDefinition) {
                $migrationService->skipMigration($migrationDefinition);
                $output->writeln('<info>Migration' . $migrationDefinition->path . ' marked as skipped</info>');
            }

            return 0;
        }

        throw new \InvalidArgumentException("Please specify one action to be taken on the given migration");
    }
563569
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        parent::initialize($input, $output);

        Context::get('information-collector')->handleCommandInput($input);

        $this->getOutput()->writeBigTitle('Welcome to Release Management Tool');

        $this->executeActionListIfExist('prerequisites');
    }
371944
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $currencyCode = $input->getArgument('currencyCode');
        $ratio = (float) $input->getArgument('ratio');

        /** @var PairManagerInterface $pairManager */
        $pairManager = $this->getContainer()->get('tbbc_money.pair_manager');
        try {
            $pairManager->saveRatio($currencyCode, $ratio);
            $output->writeln('ratio saved');
        } catch (MoneyException $e) {
            $output->writeln('ERROR : ratio no saved du to error : '.$e->getMessage());
        }
    }
382069
public function create(OutputInterface $output) : LoggerInterface
    {
        $logger        = new Logger('browscap');
        $consoleLogger = new ConsoleLogger($output);
        $psrHandler    = new PsrHandler($consoleLogger);

        $logger->pushHandler($psrHandler);
        $logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, Logger::NOTICE));

        ErrorHandler::register($logger);

        return $logger;
    }
619570
protected function initializeLicenser(InputInterface $input, OutputInterface $output)
    {
        $license = $input->getArgument('license');

        try {
            $licenseHeader = $this->licenseHeaderFactory->createFromLicenseName(
                $license,
                ['owners' => $input->getOption('owners')]
            );
        } catch (\InvalidArgumentException $e) {
            $licenseHeader = file_get_contents($license);
        }

        $this->licenser->setLicenseHeader($licenseHeader);
        $this->licenser->setOutputStream($output);
    }
321991
protected function setOutput(OutputInterface $output)
    {
        switch (Config::get('lumos.terminal')) {
            case 'bash':
                $op = new bashOutput($output);
                break;
            case 'cmd':
                $op = new cmdOutput($output);
                break;
            default:
                $op = new bashOutput($output);
                break;
        }
        //
        $this->console = $op;
        $this->output = $op->output;
    }
936606
public function execute(InputInterface $input, OutputInterface $output)
    {
        $description = $input->getArgument('description');
        $time        = date('YmdHis');
        $classname   = $this->generateClassName($time, $description);
        $filepath    = APPDIR.'/src/'.$this->namespaceToPath().$classname.'.php';

        if (! is_dir(dirname($filepath))) {
            mkdir(dirname($filepath), 0775, true);
        }

        $view = $this->newMigrationView;

        $view->description($description);
        $view->classname($classname);
        $view->timestamp($time);

        file_put_contents($filepath, (string) $view);

        $message = '  Created migration file '.$filepath;

        // Output message padded by newlines
        $output->write(['', $message, ''], true);
    }
1049964
public function setOutput($output)
    {
        $psrLogBase = self::PSR_LOG_BASE;
        $consoleBase = self::SYMFONY_CONSOLE_BASE;

        if (($output instanceof $psrLogBase) === false && ($output instanceof $consoleBase) === false) {
            $className = get_class($output);
            $message = 'Output class "%s" not supported. Only "%s" or "%s"';
            throw new \Exception(sprintf($message, $className, $psrLogBase, $consoleBase), 1369595109);
        }

        $this->output = $output;
    }
141113
public function setOutput(\Symfony\Component\Console\Output\OutputInterface $output)
    {
        $this->output = $output;
    }
821227
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = new SymfonyOutput($output);

        $this->input = $input;

        if (method_exists($this, 'handle')) {
            $this->handle();
        }
    }
1324908
protected static function configureFormatter(OutputInterface $output)
    {
        $formatter = $output->getFormatter();
        $formatter->setStyle('system', new OutputFormatterStyle('green'));
        $formatter->setStyle('line', new OutputFormatterStyle('yellow'));
        $formatter->setStyle('fail', new OutputFormatterStyle('red'));
        $formatter->setStyle('info', new OutputFormatterStyle('blue'));
        $formatter->setStyle('body', new OutputFormatterStyle('white'));
        $formatter->setStyle('strong', new OutputFormatterStyle(null, null, ['bold']));
    }
962488
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $styles = [
            // ---------------------------------------
            // Style    => [ Color, BgColor, Options ]
            // ---------------------------------------
            'title'     => [ 'white', null, ['bold'] ],
            'info'      => [ 'cyan' ],
            'warn'      => [ 'yellow', null, ['bold'] ],
            'erro'      => [ 'red', null, ['bold'] ],
            'success'   => [ 'green' ],
            'failure'   => [ 'yellow' ],
            'label'     => [ 'cyan', null, ['underscore'] ],
            'comment'   => [ 'white', null, ['reverse'] ],
            'highlight' => [ 'yellow' ],
        ];

        foreach ($styles as $name => $style) {
            $output->getFormatter()->setStyle(
                $name,
                Reflection::newInstance(
                    OutputFormatterStyle::class,
                    $style
                )
            );
        }

        $this->output = new OutputStyle($input, $output);
    }
638884
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        try {
            $this->checkOptions($input);
            $output->writeln(
                '<comment>Starting generation for ' . $input->getOption(self::OPT_FQN) . '</comment>'
            );
            $idType =
                (true !== $input->getOption(self::OPT_INT_PRIMARY_KEY)) ?
                    IdTrait::UUID_FIELD_TRAIT : IdTrait::INTEGER_ID_FIELD_TRAIT;
            $this->entityGenerator
                ->setPathToProjectRoot($input->getOption(AbstractCommand::OPT_PROJECT_ROOT_PATH))
                ->setProjectRootNamespace($input->getOption(AbstractCommand::OPT_PROJECT_ROOT_NAMESPACE))
                ->setPrimaryKeyType($idType);
            $this->entityGenerator->generateEntity(
                $input->getOption(self::OPT_FQN),
                $input->getOption(self::OPT_ENTITY_SPECIFIC_SAVER)
            );
            $output->writeln('<info>completed</info>');
        } catch (\Exception $e) {
            throw new DoctrineStaticMetaException(
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }
391077
protected function execute(InputInterface $input, OutputInterface $output)
    {
		$this->input = $input;
		$this->output = $output;
		$this->force = $input->getOption('force');
		
		$helper = $this->getHelper('question');
		
        $userQuestion = new Question('User (root): ', 'root');
		
        $passwordQuestion = new Question('Password (): ', '');
		$passwordQuestion->setHidden(true);
		$passwordQuestion->setHiddenFallback(false);

        $hostQuestion = new Question('Host (localhost): ', 'localhost');
        $driverQuestion = new Question('Driver (pdo_mysql): ', 'pdo_mysql');
		
		$user = $helper->ask($input, $output, $userQuestion);
		$password = $helper->ask($input, $output, $passwordQuestion);
		$host = $helper->ask($input, $output, $hostQuestion);
		$driver = $helper->ask($input, $output, $driverQuestion);
		
		$connectionParams = array(
			'user' => $user,
			'password' => $password,
			'host' => $host,
			'driver' => $driver
		);
		
		try {
			$conn = $this->createConnection($connectionParams);
			
			$sm = $conn->getSchemaManager();
			
			$databases = $sm->listDatabases();
			
			$question = new ChoiceQuestion(
				'Database',
				$databases,
				0
			);
			$question->setErrorMessage('Selected database is not valid');

			$dbName = $helper->ask($input, $output, $question);
			$output->writeln('Chosen database: ' . $dbName);
			
			//Add the dbname property
			$connectionParams['dbname'] = $dbName;
			
			$conn = $this->createConnection($connectionParams);
			
			$sm = $conn->getSchemaManager();
		
			$tables = $sm->listTables();
			
			$this->loadConfiguration();
			
			$progress = new ProgressBar($output, count($tables));
			$progress->start();
			
			foreach ($tables as $table) {
				//$output->writeln($table->getName() . " columns:\n\n");
					
				//Columns
				/*
				foreach ($table->getColumns() as $column) {
					//$output->writeln(' - ' . $column->getName() . ': ' . $column->getType() . "\n");
				}
				*/
					
				//Foreign keys
				$name = $table->getName();
				$table = $sm->listTableDetails($name);
				//$foreignKeys = $table->getForeignKeys();
				//$output->writeln("Foreign keys (" . count($foreignKeys) . ")");
				/*
				foreach ($foreignKeys as $foreignKey) {
					//$output->writeln("\n");
					$foreignColumns = $foreignKey->getForeignColumns();
					$localColumns = $foreignKey->getLocalColumns();
					foreach($foreignColumns as $key => $foreignColumn){
						//$output->writeln($foreignKey->getLocalTableName() . "." . $localColumns[$key] . " <=> " . $foreignKey->getForeignTableName() . "." . $foreignColumn . "\n");
					}
				}
				*/
		
				$primaryKeys = $table->getPrimaryKeyColumns();
				//$output->writeln("Primary keys (" . count($primaryKeys) . ")");
				/*
				foreach ($primaryKeys as $primaryKey) {
					//$output->writeln("\n" . $primaryKey);
				}
				*/
				
				//$output->writeln("\n\n");
				$this->generateCode($name, reset($primaryKeys));
				
				$progress->advance();
			}
			
			$progress->finish();
		} catch(\Exception $ex){
			$output->writeln('Generator has found the current exception: ');
			$output->writeln($ex->getMessage());
		}
    }