src/Controller/Index.php
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;
    }
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;
    }
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 ; }
Main working action. Creates the configuration.

@return ResponseInterface|ViewModel
Main working action . Creates the configuration .