Avoo core bundle install

@param InputInterface  $input
@param OutputInterface $output
@param QuestionHelper  $helper
179560
public static function installBackendBundle(InputInterface $input, OutputInterface $output, QuestionHelper $helper)
    {
        $rootDir = getcwd();

        $question = new ConfirmationQuestion('Would you like to install default backend bundle (Recommended)? [y/n] ', true);
        if (!$helper->ask($input, $output, $question)) {
            return;
        }

        $applicationName = self::getApplicationName($input, $output, $helper);

        if (is_dir($rootDir.'/src/' . $applicationName . '/BackendBundle')) {
            return;
        }

        $output->writeln('<info>Installing Backend bundle.</info>');
        $output->writeln('');

        $bundleDir = $rootDir . '/src/' . $applicationName;

        $fileSystem = new Filesystem();
        $fileSystem->setTwigEnvironment(self::getTwigEnvironment());

        self::buildBackendFiles($bundleDir . '/Bundle/BackendBundle/', $applicationName, $fileSystem);

        $routingPath = $rootDir . '/app/config/routing.yml';
        $namePrefix = strtolower($applicationName) . '_backend';
        $bundleName = $applicationName . 'BackendBundle';
        $content = file_get_contents($routingPath);
        $nodeDeclaration = <<<EOF
$namePrefix:
    resource: @$bundleName/Resources/config/routing/main.yml
    prefix: /administration

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_register:
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
    prefix: /register

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

fos_user_change_password:
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
    prefix: /account

EOF;

        if (false === strpos($content, $namePrefix)) {
            $updatedContent = $nodeDeclaration . "\n" . $content;

            $fileSystem->dumpFile($routingPath, $updatedContent);
        }

        $configFile = $rootDir . '/app/config/config.yml';
        $ref = '- { resource: security.yml }';
        $configDeclaration = '- { resource: @' . $applicationName . 'BackendBundle/Resources/config/app/' . strtolower($applicationName) . '.yml }';
        $content = file_get_contents($configFile);

        if (false === strpos($content, $configDeclaration)) {
            $updatedContent = str_replace($ref, $ref . "\n    " . $configDeclaration, $content);
            if ($content === $updatedContent) {
                throw new \RuntimeException('Unable to patch %s.', $configFile);
            }

            $fileSystem->dumpFile($configFile, $updatedContent);
        }

        $kernelFile = $rootDir . '/app/AppKernel.php';

        $fileSystem = new Filesystem();
        $ref = '$bundles = array(';
        $bundleDeclaration = 'new ' . $applicationName . '\\Bundle\\BackendBundle\\' . $applicationName . 'BackendBundle(),';
        $content = file_get_contents($kernelFile);

        if (false === strpos($content, $bundleDeclaration)) {
            $updatedContent = str_replace($ref, $ref . "\n            " . $bundleDeclaration, $content);
            if ($content === $updatedContent) {
                throw new \RuntimeException('Unable to patch %s.', $kernelFile);
            }

            $fileSystem->dumpFile($kernelFile, $updatedContent);
        }
    }
835684
private function doAsk(OutputInterface $output, Question $question)
    {
        $this->writePrompt($output, $question);

        $inputStream = $this->inputStream ?: STDIN;
        $autocomplete = $question->getAutocompleterCallback();

        if (null === $autocomplete || !$this->hasSttyAvailable()) {
            $ret = false;
            if ($question->isHidden()) {
                try {
                    $ret = trim($this->getHiddenResponse($output, $inputStream));
                } catch (RuntimeException $e) {
                    if (!$question->isHiddenFallback()) {
                        throw $e;
                    }
                }
            }

            if (false === $ret) {
                $ret = fgets($inputStream, 4096);
                if (false === $ret) {
                    throw new RuntimeException('Aborted.');
                }
                $ret = trim($ret);
            }
        } else {
            $ret = trim($this->autocomplete($output, $question, $inputStream, $autocomplete));
        }

        if ($output instanceof ConsoleSectionOutput) {
            $output->addContent($ret);
        }

        $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();

        if ($normalizer = $question->getNormalizer()) {
            return $normalizer($ret);
        }

        return $ret;
    }
199622
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $questionHelper = $this->getQuestionHelper();

        GeneratorUtils::ensureOptionsProvided($input, array('entity'));

        $entity = Validators::validateEntityName($input->getOption('entity'));
        list($bundle, $entity) = $this->parseShortcutNotation($entity);

        $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
        $metadata = $this->getEntityMetadata($entityClass);
        /** @var Bundle $bundle */
        $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);

        $questionHelper->writeSection($output, 'AdminList Generation');

        /** @var AdminListGenerator $generator */
        $generator = $this->getGenerator($this->getApplication()->getKernel()->getBundle("KunstmaanGeneratorBundle"));
        $generator->setQuestion($questionHelper);
        $generator->generate($bundle, $entityClass, $metadata[0], $output, $input->getOption('sortfield'));

        $parts = explode('\\', $entity);
        $entityClass = array_pop($parts);

        $generator->generateRouting($bundle, $entityClass);
    }
185737
protected function interact(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getArgument('bundle')) {
            $bundle = $this->getHelper('dialog')->askAndValidate(
                $output,
                'Please give the bundle:',
                function($bundle)
                {
                    if (empty($bundle)) {
                        throw new \Exception('Bundle can not be empty');
                    }

                    return $bundle;
                }
            );
            $input->setArgument('bundle', $bundle);
        }
    }
335862
private function askConfirmation(InputInterface $input, OutputInterface $output, $questionText, $default, $separator)
    {
        $questionHelper = $this->getQuestionHelper();

        // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
        if ($questionHelper instanceof DialogHelper) {
            $question = $questionHelper->getQuestion($questionText, $default, $separator);

            return $questionHelper->askConfirmation($output, $question, ($default === 'no' ? false : true));
        }

        $question = new ConfirmationQuestion($questionHelper->getQuestion(
            $questionText,
            $default,
            $separator
        ), ($default === 'no' ? false : true));

        return $questionHelper->ask($input, $output, $question);
    }
294642
private function askForPropertyClass(InputInterface $input, OutputInterface $output)
    {
        return $this->questionHelper->ask(
            $input,
            $output,
            $this->getQuestion(
                "\n" . 'Property class',
                null,
                [$this, 'validatePropertyClass'],
                array_merge($this->getDocumentClasses(), array_keys($this->getContainer()->get('kernel')->getBundles()))
            )
        );
    }
767657
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->stdOut->writeln("<info>Syncing Platform.sh environment database to local</info>");

        /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
        $process = $this->getHelper('process');

        // If this is a Platform.sh project, get latest dump.
        // @todo: add proper provider integration
        if (Config::get('id')) {
            $process->mustRun($this->stdOut, [
              'platform',
              'sql-dump',
            ]);
        }

        $cd = getcwd();
        chdir(Platform::webDir());
        $process->run($this->stdOut, 'drush sqlc < ' . $input->getArgument('file'));
        chdir($cd);
    }
183925
protected function interact(InputInterface $input, OutputInterface $output)
    {
        $questionHelper = $this->getQuestionHelper();
        $questionHelper->writeSection($output, 'Welcome to the Victoire widget bundle generator');

        ///////////////////////
        //                   //
        //   Create Bundle   //
        //                   //
        ///////////////////////

        // namespace
        $namespace = null;

        try {
            $namespace = $input->getOption('namespace') ? Validators::validateBundleNamespace($input->getOption('namespace')) : null;
        } catch (\Exception $error) {
            $output->writeln($questionHelper->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
        }

        if (null === $namespace) {
            $output->writeln([
                '',
                'Your application code must be written in <comment>widget bundles</comment>. This command helps',
                'you generate them easily.',
                '',
                'Each widget is hosted under a namespace (like <comment>Victoire/Widget/YourAwesomeWidgetNameBundle</comment>).',
                '',
                'If you want for example a BlogWidget, the Widget Name should be Blog',
            ]);

            $question = new Question($questionHelper->getQuestion('Widget name', $input->getOption('bundle-name')));
            $question->setValidator(function ($answer) {
                return self::validateWidgetName($answer, false);
            });

            $name = $questionHelper->ask(
                $input,
                $output,
                $question
            );

            $bundle = 'VictoireWidget'.$name.'Bundle';
            $input->setOption('bundle-name', $bundle);
            $namespace = 'Victoire\\Widget\\'.$name.'Bundle';
            $input->setOption('namespace', $namespace);
        }

        $orgname = $input->getOption('orgname');

        if (null === $orgname) {
            $output->writeln([
                '',
                'A composer.json file will be generated, we need to know under which organisation you will publish the widget',
                '',
                'The default organisation will be friendsofvictoire',
            ]);
            $question = new Question($questionHelper->getQuestion('Under which organisation do you want to publish your widget ?', 'friendsofvictoire'), 'friendsofvictoire');

            $orgname = $questionHelper->ask($input, $output, $question);
        }

        $input->setOption('orgname', $orgname);

        $parent = $input->getOption('parent');

        $question = new ConfirmationQuestion($questionHelper->getQuestion('Does your widget extends another widget ?', 'no', '?'), false);

        if (null === $parent && $questionHelper->ask($input, $output, $question)) {
            $output->writeln([
                '',
                'A widget can extends another to reproduce its behavior',
                '',
                'If you wabt to do so, please give the name of the widget to extend',
                '',
                'If you want to extends the TestWidget, the widget name should be Test',
            ]);

            $question = new Question($questionHelper->getQuestion('Parent widget name', false));
            $question->setValidator(function ($answer) {
                return self::validateWidgetName($answer, false);
            });
            $parent = $questionHelper->ask($input, $output, $question);

            $input->setOption('parent', $parent);

            $packagistParentName = 'friendsofvictoire/'.strtolower($parent).'-widget';
            $question = new Question($questionHelper->getQuestion('Parent widget packagist name', $packagistParentName));

            $parent = $questionHelper->ask($input, $output, $question);

            $input->setOption('packagist-parent-name', $packagistParentName);
        }

        $dir = dirname($this->getContainer()->getParameter('kernel.root_dir')).'/src';

        $output->writeln([
            '',
            'The bundle can be generated anywhere. The suggested default directory uses',
            'the standard conventions.',
            '',
        ]);

        $question = new Question($questionHelper->getQuestion('Target directory', $dir), $dir);
        $question->setValidator(function ($dir) use ($bundle, $namespace) {
            return Validators::validateTargetDir($dir, $bundle, $namespace);
        });
        $dir = $questionHelper->ask($input, $output, $question);
        $input->setOption('dir', $dir);

        // format
        $format = null;

        try {
            $format = $input->getOption('format') ? Validators::validateFormat($input->getOption('format')) : null;
        } catch (\Exception $error) {
            $output->writeln($questionHelper->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
        }

        if (null === $format) {
            $output->writeln([
                '',
                'Determine the format to use for the generated configuration.',
                '',
            ]);

            $question = new Question($questionHelper->getQuestion('Configuration format (yml, xml, php, or annotation)', 'annotation'), 'annotation');
            $question->setValidator(
                ['Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateFormat']
            );
            $format = $questionHelper->ask($input, $output, $question);
            $input->setOption('format', $format);
        }

        $input->setOption('structure', false);

        $contentResolver = $input->getOption('content-resolver');

        $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you want to customize widget rendering logic ?', 'no', '?'), false);
        if (!$contentResolver && $questionHelper->ask($input, $output, $question)) {
            $contentResolver = true;
        }
        $input->setOption('content-resolver', $contentResolver);

        ///////////////////////
        //                   //
        //   Create Entity   //
        //                   //
        ///////////////////////

        $input->setOption('fields', $this->addFields($input, $output, $questionHelper));
        $entity = 'Widget'.$name;
        $input->setOption('entity', $bundle.':'.$entity);

        $cache = $input->getOption('cache');
        $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you want use cache for this widget ?', 'no', '?'), false);
        if (null !== $cache) {
            $cache = $questionHelper->ask($input, $output, $question);
        }
        $input->setOption('cache', $cache);

        // summary
        $output->writeln([
            '',
            $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true),
            '',
            sprintf("You are going to generate a \"<info>%s\\%s</info>\" widget bundle\nin \"<info>%s</info>\" using the \"<info>%s</info>\" format.", $namespace, $bundle, $dir, $format),
            '',
        ]);
    }
684681
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;
            }
        }

        $module = Validators::validateModuleName($input->getOption('module'));
        $entity = Validators::validateEntityName($input->getOption('entity'));
        list($bundle, $module) = $this->parseShortcutNotation($module);
        $module = substr($module, 0, -6);

        $questionHelper->writeSection($output, 'Module generation');

        $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);

        /** @var ModuleGenerator $generator */
        $generator = $this->getGenerator(new ClasticGeneratorBundle());
        $generator->generate($bundle, $module, $entity);

        $output->writeln('Generating the module code: <info>OK</info>');

        $questionHelper->writeGeneratorSummary($output, array());

        return 0;
    }
1168993
private function askAndValidate(InputInterface $input, OutputInterface $output, $questionText, $default, $validator)
    {
        $questionHelper = $this->getQuestionHelper();

        // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
        if ($questionHelper instanceof DialogHelper) {
            return $questionHelper->askAndValidate($output, $questionHelper->getQuestion($questionText, $default), $validator, false, $default);
        }

        $question = new Question($questionHelper->getQuestion($questionText, $default), $default);

        $question->setValidator($validator);

        return $questionHelper->ask($input, $output, $question);
    }
797085
protected function execute( InputInterface $input, OutputInterface $output )
	{
		$code = $input->getArgument( 'email' );
		if( ( $password = $input->getOption( 'password' ) ) === null )
		{
			$helper = $this->getHelper( 'question' );
			$question = new Question( 'Password' );
			$question->setHidden( true );

			$password = $helper->ask( $input, $output, $question );
		}

		$context = $this->getContainer()->get( 'aimeos.context' )->get( false, 'command' );
		$context->setEditor( 'aimeos:account' );

		$localeManager = \Aimeos\MShop::create( $context, 'locale' );
		$localeItem = $localeManager->bootstrap( $input->getArgument( 'site' ), '', '', false );
		$context->setLocale( $localeItem );

		$user = $this->createCustomerItem( $context, $code, $password );

		if( $input->getOption( 'admin' ) ) {
			$this->addGroup( $input, $output, $context, $user, 'admin' );
		}

		if( $input->getOption( 'editor' ) ) {
			$this->addGroup( $input, $output, $context, $user, 'editor' );
		}

		if( $this->getContainer()->has( 'fos_user.user_manager' ) )
		{
			$userManager = $this->getContainer()->get( 'fos_user.user_manager' );

			if( ( $fosUser = $userManager->findUserByUsername( $code ) ) === null ) {
				throw new \RuntimeException( 'No user created' );
			}

			$fosUser->setSuperAdmin( false );

			if( $input->getOption( 'super' ) ) {
				$fosUser->setSuperAdmin( true );
			}

			if( $input->getOption( 'admin' ) || $input->getOption( 'editor' ) ) {
				$fosUser->addRole( 'ROLE_ADMIN' );
			}

			$userManager->updateUser( $fosUser );
		}
	}
622603
protected function shouldProceedWithInstall( InputInterface $input, OutputInterface $output, $config ) {
		$helper = $this->getHelper( 'question' );

		$output->writeln( 'Configuration:' );

		$output->writeln(
			str_pad( 'Clean composer.json: ', 25 )  .
			( $config['remove_composer_author_information'] ? '<info>Yes</info>' : '<comment>No</comment>' )
		);

		$output->writeln(
			str_pad( 'Install Carbon Fields: ', 25 )  .
			( $config['install_carbon_fields'] ? '<info>Yes</info>' : '<comment>No</comment>' )
		);

		$output->writeln(
			str_pad( 'Install CSS Framework: ', 25 ) .
			'<info>' . $config['install_css_framework'] . '</info>'
		);

		$output->writeln(
			str_pad( 'Install Font Awesome: ', 25 ) .
			( $config['install_font_awesome'] ? '<info>Yes</info>' : '<comment>No</comment>' )
		);

		$output->writeln( '' );

		$question = new ConfirmationQuestion(
			'Proceed with installation? <info>[Y/n]</info> ',
			true
		);

		$proceed = $helper->ask( $input, $output, $question );
		$output->writeln( '' );

		return $proceed;
	}
1031126
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $questionHelper = $this->getQuestionHelper();
        $dialog = $this->getHelper('dialog');

        if ($input->isInteractive()) {
            if (!$dialog->askConfirmation($output, $questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
                $output->writeln('<error>Command aborted</error>');

                return 1;
            }
        }

        foreach (array('namespace', 'dir') as $option) {
            if (null === $input->getOption($option)) {
                throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
            }
        }

        $namespace = Validators::validateBundleNamespace($input->getOption('namespace'));
        if (!$bundle = $input->getOption('bundle-name')) {
            $bundle = strtr($namespace, array('\\' => ''));
        }
        $bundle = Validators::validateBundleName($bundle);
        $dir = Validators::validateTargetDir($input->getOption('dir'), $bundle, $namespace);

        if (null === $input->getOption('format')) {
            $input->setOption('format', 'xml');
        }
        $format = Validators::validateFormat($input->getOption('format'));
        $structure = $input->getOption('structure');

        if (null === $input->getOption('db-driver')) {
            $input->setOption('db-driver', 'orm');
        }
        $dbDriver = Validators::validateDbDriver($input->getOption('db-driver'));

        $questionHelper->writeSection($output, 'Bundle generation');

        if (!$this->getContainer()->get('filesystem')->isAbsolutePath($dir)) {
            $dir = getcwd().'/'.$dir;
        }

        $generator = $this->getGenerator();
        $generator->generate($namespace, $bundle, $dir, $format, $structure, $dbDriver);

        $output->writeln('Generating the bundle 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));

        $questionHelper->writeGeneratorSummary($output, $errors);
    }
999730
protected function configureSSH(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper, $deployData)
    {
        $serverOptions = [
            'domain' => [
                'helper' => $deployData['ssh_user'],
                'label'  => 'Domain name',
            ],
        ];
        $sshOptions = [
            'forwardAgent' => [
                'label'  => 'SSH forward agent',
                'helper' => 'false',
            ],
            'authMethods' => [
                'label'  => 'SSH auth method',
                'helper' => 'publickey password',
            ],
            'keys' => [
                'label'  => 'Remote SSH key',
                'helper' => sprintf('/home/%s/.ssh/id_rsa', $deployData['ssh_user']),
            ],
        ];
        $sshProps = [
          'user'         => $deployData['ssh_user'],
          'keys'         => '',
          'forwardAgent' => false,
          'authMethods'  => 'publickey password',
          'deployTo'     => $deployData['deploy_to'],
          'repoUrl'      => $deployData['repo_url'],
        ];

        $question = new Question("<info>{$serverOptions['domain']['label']}</info> [<comment>{$serverOptions['domain']['helper']}</comment>]: ", $serverOptions['domain']['helper']);
        $sshProps['domain'] = $questionHelper->ask($input, $output, $question);

        foreach ($sshOptions as $key => $property) {
            $question = new Question("<info>{$property['label']}</info> [<comment>{$property['helper']}</comment>]: ", $property['helper']);

            if (isset($property['autocomplete'])) {
                $question->setAutocompleterValues($property['autocomplete']);
            }

            $sshProps[$key] = $questionHelper->ask($input, $output, $question);
        }

        return $sshProps;
    }
189224
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$this->apiHelper->restore($this->getHelper('question'), $input, $output)) {
            return;
        }

        $output->writeln(\sprintf('Checking for URL: <info>%s</info>', $this->getUrl()).PHP_EOL);

        /** @var QuestionHelper $asker */
        $asker = $this->getHelper('question');
        $user = $this->apiHelper->currentUser();

        $enabled = $this->getCallbackStatus($user);
        $question = new ConfirmationQuestion(
            sprintf(
                '%s [y/N]: ',
                $enabled
                    ? 'The callback is currently <info>ACTIVE</info>, would you like to disable?'
                    : 'The callback is currently <info>INACTIVE</info>, would you like to enable?'
            ),
            false
        );

        if (!$asker->ask($input, $output, $question)) {
            return;
        }

        try {
            if ($enabled) {
                $this->disableCallback($user);
            } else {
                $this->enableCallback($user);
            }

            $output->writeln('<info>New status successfully applied.</info>');
        } catch (BunqException $exception) {
            $output->writeln('<error>An error occured while applying new status: '.$exception->getMessage().'</error>');
        }
    }
278871
private function init(InputInterface $input, OutputInterface $output)
    {
        $this->helper = $this->getHelper('question');
        $this->input = $input;
        $this->output = $output;

        // Set whether target files should be overwritten or not.
        $this->force = $input->getOption('force');
        $this->root = $input->getOption('root');

        $this->init_wordpress();

        // Setup Snap.
        Snap::create_container();
        Snap::init_config($this->root);

        // Setup WP filesystem helper.
        $this->setup_filesystem();
    }
1223252
protected function initializeExecute(OutputInterface $output, ProcessHelper $helper)
    {
        $this->execute = $this->execute ?: new Execute($output, $helper);
    }