WIP : install wizard : step 1, 2, 3
This commit is contained in:
@@ -22,7 +22,12 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\InstallStep3Form;
|
||||
use Thelia\Install\CheckDatabaseConnection;
|
||||
use Thelia\Install\CheckPermission;
|
||||
use Thelia\Install\Exception\AlreadyInstallException;
|
||||
use Thelia\Install\Exception\InstallException;
|
||||
|
||||
/**
|
||||
* Class InstallController
|
||||
@@ -35,9 +40,14 @@ class InstallController extends BaseInstallController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
//$this->verifyStep(1);
|
||||
$args = array();
|
||||
try {
|
||||
//$this->verifyStep(1); // @todo implement
|
||||
$this->getSession()->set("step", 1);
|
||||
} catch (AlreadyInstallException $e) {
|
||||
$args['isAlreadyInstalled'] = true;
|
||||
}
|
||||
|
||||
$this->getSession()->set("step", 1);
|
||||
|
||||
return $this->render("index.html");
|
||||
}
|
||||
@@ -49,29 +59,22 @@ class InstallController extends BaseInstallController
|
||||
*/
|
||||
public function checkPermissionAction()
|
||||
{
|
||||
try {
|
||||
//$this->verifyStep(2); // @todo implement
|
||||
$checkPermission = new CheckPermission(true, $this->getTranslator());
|
||||
$args['isValid'] = $isValid = $checkPermission->exec();
|
||||
$args['validationMessages'] = $checkPermission->getValidationMessages();
|
||||
|
||||
$this->getSession()->set("step", 2);
|
||||
} catch (AlreadyInstallException $e) {
|
||||
$args['isAlreadyInstalled'] = true;
|
||||
}
|
||||
$args = array();
|
||||
var_dump('step2');
|
||||
//$this->verifyStep(2);
|
||||
|
||||
$checkPermission = new CheckPermission(true, $this->getTranslator());
|
||||
$args['isValid'] = $isValid = $checkPermission->exec();
|
||||
$args['validationMessages'] = $checkPermission->getValidationMessages();
|
||||
|
||||
$this->getSession()->set("step", 2);
|
||||
|
||||
return $this->render("step-2.html", $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Database connexion tests
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function databaseConnection()
|
||||
{
|
||||
var_dump('step 3 bis');
|
||||
}
|
||||
|
||||
/**
|
||||
* Database connexion tests
|
||||
*
|
||||
@@ -79,15 +82,95 @@ class InstallController extends BaseInstallController
|
||||
*/
|
||||
public function databaseConnectionAction()
|
||||
{
|
||||
var_dump('step 3');
|
||||
exit();
|
||||
//$this->verifyStep(2);
|
||||
$args = array();
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
try {
|
||||
//$this->verifyStep(2); // @todo implement
|
||||
|
||||
$this->getSession()->set("step", 3);
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
// Create the form from the request
|
||||
$step3Form = new InstallStep3Form($this->getRequest());
|
||||
|
||||
return $this->render("step-3.html");
|
||||
$message = false;
|
||||
try {
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($step3Form, 'POST');
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
var_dump('data', $data);
|
||||
|
||||
// @todo implement tests
|
||||
try {
|
||||
new CheckDatabaseConnection(
|
||||
$data['host'],
|
||||
$data['user'],
|
||||
$data['password'],
|
||||
$data['port'],
|
||||
true,
|
||||
$this->getTranslator()
|
||||
);
|
||||
|
||||
$this->getSession()->set('install', array(
|
||||
'host' =>$data['host'],
|
||||
'user' => $data['user'],
|
||||
'password' => $data['password'],
|
||||
'port' => $data['port']
|
||||
)
|
||||
);
|
||||
} catch (InstallException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
'Can\'t connect with these credentials to this server',
|
||||
array(),
|
||||
'install-wizard'
|
||||
);
|
||||
}
|
||||
|
||||
// $this->redirect(
|
||||
// str_replace(
|
||||
// '{id}',
|
||||
// $couponEvent->getCoupon()->getId(),
|
||||
// $creationForm->getSuccessUrl()
|
||||
// )
|
||||
// );
|
||||
} catch (FormValidationException $e) {
|
||||
// Invalid data entered
|
||||
$message = $this->getTranslator()->trans(
|
||||
'Please check your input:',
|
||||
array(),
|
||||
'install-wizard'
|
||||
);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Any other error
|
||||
$message = $this->getTranslator()->trans(
|
||||
'Sorry, an error occurred:',
|
||||
array(),
|
||||
'install-wizard'
|
||||
);
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
// Mark the form as with error
|
||||
$step3Form->setErrorMessage($message);
|
||||
|
||||
// Send the form and the error to the parser
|
||||
$this->getParserContext()
|
||||
->addForm($step3Form)
|
||||
->setGeneralError($message);
|
||||
}
|
||||
}
|
||||
|
||||
$this->getSession()->set("step", 3);
|
||||
|
||||
$args['edit_language_locale'] = $this->getSession()->getLang()->getLocale();
|
||||
$args['formAction'] = 'install/step/3';
|
||||
|
||||
} catch (AlreadyInstallException $e) {
|
||||
$args['isAlreadyInstalled'] = true;
|
||||
}
|
||||
|
||||
return $this->render('step-3.html', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +180,14 @@ class InstallController extends BaseInstallController
|
||||
*/
|
||||
public function databaseSelectionAction()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
$args = array();
|
||||
try {
|
||||
|
||||
} catch (AlreadyInstallException $e) {
|
||||
$args['isAlreadyInstalled'] = true;
|
||||
}
|
||||
|
||||
//$this->verifyStep(2); // @todo implement
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
@@ -107,13 +197,19 @@ class InstallController extends BaseInstallController
|
||||
}
|
||||
|
||||
/**
|
||||
* Set general informations
|
||||
* Set general information
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function generalInformationAction()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
$args = array();
|
||||
try {
|
||||
|
||||
} catch (AlreadyInstallException $e) {
|
||||
$args['isAlreadyInstalled'] = true;
|
||||
}
|
||||
//$this->verifyStep(2); // @todo implement
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
@@ -129,7 +225,13 @@ class InstallController extends BaseInstallController
|
||||
*/
|
||||
public function thanksAction()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
$args = array();
|
||||
try {
|
||||
|
||||
} catch (AlreadyInstallException $e) {
|
||||
$args['isAlreadyInstalled'] = true;
|
||||
}
|
||||
//$this->verifyStep(2); // @todo implement
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
@@ -162,5 +264,7 @@ class InstallController extends BaseInstallController
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user