Ask installing questions

@return $this
@throws \Exception
505426
private function askInstallingQuestions()
    {
        // Database information
        $this->DB_TYPE = $this->ask('Your Database type', config('database.default'));
        $this->DB_HOST = $this->ask('Your DB_HOST', config('database.connections.'.$this->DB_TYPE.'.host'));
        $this->DB_PORT = $this->ask('Your DB PORT', config('database.connections.'.$this->DB_TYPE.'.port'));
        $this->DB_DATABASE = $this->ask('Your Database Name', config('database.connections.'.$this->DB_TYPE.'.database'));
        $this->DB_USERNAME = $this->ask('Your DB Username', config('database.connections.'.$this->DB_TYPE.'.username'));
        $this->DB_PASSWORD = $this->secret('Your DB Password');

        // Validate Database
        $this->validateDatabase();

        $this->APP_NAME = $this->ask('Your Site Name', config('app.name'));
        $this->APP_URL = $this->ask('Your App URL', config('app.url'));

        // Timezone
        $regions = $this->getTimezoneRegions();
        $this->TIMEZONE = $this->choice('Timezone region', array_keys($regions), 0);
        if ($this->TIMEZONE !== 'UTC') {
            $locations = $this->getTimezoneLocations($regions[$this->TIMEZONE]);
            $this->TIMEZONE .= '/' . $this->choice('Timezone location', $locations, 0);
        }

        $this->askAboutDefaultLanguage();

        // User information
        $this->ADMIN_FIRST_NAME = $this->ask('Your First Name');
        $this->ADMIN_LAST_NAME = $this->ask('Your Last Name');
        $this->ADMIN_EMAIL = $this->ask('Your Email');
        $this->ADMIN_PASSWORD = $this->ask('Set Your Admin Password');

        return $this;
    }
1034507
protected function doInteract()
    {
        /**
         * Ask for which bundle we need to create the layout
         */
        $bundleNamespace = $this->assistant->getOptionOrDefault('namespace', null);
        $this->bundle = $this->askForBundleName('article classes', $bundleNamespace);

        /*
         * Entity
         */
        $this->entity = $this->assistant->getOptionOrDefault('entity', null);

        if (is_null($this->entity)) {
            $this->assistant->writeLine(array(
                'You must specify a name for the collection of Article entities.',
                'This name will be prefixed before every new entity.',
                'For example entering <comment>News</comment> will result in:',
                '<comment>News</comment>OverviewPage, <comment>News</comment>Page and <comment>News</comment>Author',
            ));

            $generator = $this->getGenerator();
            $this->entity = $this->assistant->askAndValidate(
                'Article class name',
                function ($name) use ($generator) {
                    // Check reserved words
                    if ($generator->isReservedKeyword($name)) {
                        throw new \InvalidArgumentException(sprintf('"%s" is a reserved word', $name));
                    }
                    if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name)) {
                        throw new \InvalidArgumentException(sprintf('Invalid entity name: %s', $name));
                    }

                    return $name;
                }
            );
        }

        /*
         * Ask if author will be used
         */
        $this->usesAuthor = $this->askForAuthor();

        /*
         * Ask if category will be used
         */
        $this->usesCategories = $this->askForCategories();

        /*
         * Ask if tag will be used
         */
        $this->usesTags = $this->askForTags();

        /**
         * Ask the parent pages
         */
        $bundleWithHomePageNamespace = $this->assistant->getOptionOrDefault('namespacehomepage', null);
        $this->bundleWithHomePage = $this->askForBundleName('', $bundleWithHomePageNamespace, 'In which bundle is the page that you will use as parent for the overview page ?', "%sThe bundle %s will be used for the parent of the overview page.\n");
        $parentPages = $this->getAvailablePages($this->bundleWithHomePage);
        $pagesSelect = array_map(function ($item) {
            return $item['name'];
        }, $parentPages);
        if (count($pagesSelect) > 0) {
            $this->assistant->writeLine('');
            $parentPageNames = $this->assistant->getOptionOrDefault('articleoverviewpageparent', null);
            if (null !== $parentPageNames) {
                $parentPageNames = explode(',', $parentPageNames);
                foreach ($parentPageNames as $parentPageName) {
                    $id = array_search($parentPageName, $pagesSelect);
                    if (false !== $id) {
                        $this->parentPages[] = $parentPages[$id]['path'];
                    }
                }
            }

            if (empty($this->parentPages)) {
                $parentPageIds = $this->assistant->askSelect('Which existing page(s) can have the new overview page as sub-page (multiple possible, separated by comma)', $pagesSelect, null, true);
                foreach ($parentPageIds as $id) {
                    $this->parentPages[] = $parentPages[$id]['path'];
                }
            }
        }

        /*
         * Ask the database table prefix
         */
        $this->prefix = $this->assistant->getOptionOrDefault('prefix', null);
        if (is_null($this->prefix)) {
            $this->prefix = $this->askForPrefix(null, $this->bundle->getNamespace());
        }

        /*
         * Ask for data fixtures
         */
        $this->dummydata = $this->askForDummydata();
    }
49436
public function answers($asks, $answers = null, $attributes = [])
    {
        $this->model->addNode($asks, $answers, $attributes);

        return $this;
    }
259413
public function setupQuestion($question)
    {
        $user = new User($this->db);
        $post = new Post($this->db);

        $question->img = $user->getGravatar($question->user);
        $question->title = $this->getMD($question->title);
        $question->tags = explode(',', $question->tags);

        $question->question = $post->getPost("questionId = ? AND type = ?", [$question->id, "question"]);
        $question->answers = $post->getAllPosts("questionId = ? AND type = ?", [$question->id, "answer"]);
        $question->answerCount = count($question->answers);


        return $question;
    }
930523
public function ask($question, $default = null)
    {
        $question = new Question("<question>$question</question> ", $default);

        return $this->helper('question')->ask($this->input, $this->output, $question);
    }
814149
public function install()
    {
        PackageList::refreshCache();
        $em = $this->app->make(EntityManagerInterface::class);
        $package = new PackageEntity();
        $package->setPackageName($this->getPackageName());
        $package->setPackageDescription($this->getPackageDescription());
        $package->setPackageVersion($this->getPackageVersion());
        $package->setPackageHandle($this->getPackageHandle());
        $em->persist($package);
        $em->flush();

        $this->app->make('cache/overrides')->flush();

        $this->installDatabase();

        Localization::clearCache();

        return $package;
    }
511285
private function setUp(): self
    {
        fn::allowCors();
        fn::allowHeader();
        $this->configApp();
        $this->configRoutes();

        return $this;
    }
754912
public function install()
    {
        $path = $this->command->path.'/config/app.php';

        $contents = file_get_contents($path);

        $contents = str_replace(
            '        App\\Providers\\AppServiceProvider::class,',
            "        Laravel\Spark\Providers\SparkServiceProvider::class,\n        App\Providers\AppServiceProvider::class,",
            $contents
        );

        file_put_contents($path, $contents);
    }
67214
function install()
    {
        if (! $this->brew->hasInstalledPhp()) {
            $this->brew->ensureInstalled('php', [], $this->taps);
        }

        $this->files->ensureDirExists('/usr/local/var/log', user());

        $this->updateConfiguration();

        $this->restart();
    }
493100
public function wizardInstallDrupal() {
    if (!$this->getInspector()->isMySqlAvailable()) {
      return FALSE;
    }
    if (!$this->getInspector()->isDrupalInstalled()) {
      $this->logger->warning('Drupal is not installed.');
      $confirm = $this->confirm("Do you want to install Drupal?");
      if ($confirm) {
        $bin = $this->getConfigValue('composer.bin');
        $this->executor
          ->execute("$bin/blt setup")
          ->interactive($this->input()->isInteractive())
          ->run();
        $this->getInspector()->clearState();
      }
    }
  }
342755
public function ask($question, $default = null)
    {
        $que = new Question($question, $default);
        $helper = new SymfonyQuestionHelper();
        return $helper->ask($this->input, $this->output, $que);
    }
198566
private function initRequest(): App
    {
        try {
            $request = ServerRequestFactory::fromGlobals();
            $this->containers()->set('request', $request);
        } catch (\InvalidArgumentException $e) {
            new Exception($e);
        }
        return $this;
    }
1333265
protected function addWhereConstraints()
    {
        $this->query->where(
            $this->getQualifiedForeignKeyName(), '=', $this->parent->getKey()
        );

        return $this;
    }
702454
protected function setupConsoleCommands()
    {
        // Share dashboard:install command with the application.
        $this->app['dashboard::install'] = $this->app->share(function () {
            return new InstallerCommand();
        });

        // Share dashboard:setup command with the application.
        $this->app['dashboard::setup'] = $this->app->share(function () {
            return new SetupCommand();
        });

        // Share dashboard:fresh command with the application.
        $this->app['dashboard::fresh'] = $this->app->share(function () {
            return new FreshCommand();
        });

        // Share dashboard:uninstall command with the application.
        $this->app['dashboard::uninstall'] = $this->app->share(function () {
            return new UninstallCommand();
        });

        // Adds dashboard:install to the console kernel.
        $this->commands('dashboard::install');

        // Adds dashboard:setup to the console kernel.
        $this->commands('dashboard::setup');

        // Adds dashboard:fresh to the console kernel.
        $this->commands('dashboard::fresh');

        // Adds dashboard:uninstall to the console kernel.
        $this->commands('dashboard::uninstall');
    }
1091460
public function installAction()
    {
        $form = $this->installForm;
        $form->setData($_POST);

        if (!$form->isValid()) {
            return $this->createJsonResponse(
                array(
                    'ok'     => false,
                    'errors' => $form->getMessages(),
                )
            );
        }

        $data = $form->getData();

        try {
            $options = [
                'connection' => $data['db_conn'],
            ];
            $userOk = $this->plugin('Install/UserCreator', $options)->process($data['username'], $data['password'], $data['email']);
            $ok = $this->plugin('Install/ConfigCreator')->process($data['db_conn'], $data['email']);
        } catch (\Exception $exception) {
            /* @TODO: provide a way to handle global error message */
            return $this->createJsonResponse([
                'ok'        => false,
                'errors'    => [
                    'global' => [$exception->getMessage()]
                ]
            ]);
        }

        /*
         * Make sure there's no cached config files
         */
        $this->cacheService->clearCache();

        $model = $this->createViewModel(array('ok' => $ok), true);
        $model->setTemplate('install/index/install.ajax.phtml');

        return $model;
    }
70565
protected function askToSkip() {
        $question = 'This part is optional. Do you like to configure it? [y|N]:';
        $answer = strtolower(IO::in($question));

        switch ($answer) {
            case 'yes':
            case 'y':
            case '1':
            case 'true':
                return false;
            case 'no':
            case 'n':
            case '0':
            case 'false':
            case '':
                return true;
            default:
                $this->log->warning('Excuse me, what do you mean?');

                return $this->askToSkip();
        }
    }
856112
protected function installHttp()
    {
        $result = array(
            'message' => '',
            'severity' => 'success',
            'redirect' => 'install/' . ($this->data['step'] + 1)
        );

        try {

            $this->start();
            $this->process();

        } catch (Exception $ex) {
            $result = array(
                'redirect' => '',
                'severity' => 'warning',
                'message' => $ex->getMessage()
            );
        }

        return $result;
    }