Merge branch 'install_wizard'

This commit is contained in:
Manuel Raynaud
2013-09-17 16:02:24 +02:00
38 changed files with 10957 additions and 100 deletions

View File

@@ -31,6 +31,7 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Router;
use Thelia\Core\Security\SecurityContext;
use Thelia\Core\Translation\Translator;
use Thelia\Tools\URL;
use Thelia\Tools\Redirect;
use Thelia\Core\Template\ParserContext;
@@ -97,7 +98,7 @@ class BaseController extends ContainerAware
*
* return the Translator
*
* @return mixed \Thelia\Core\Translation\Translator
* @return Translator
*/
public function getTranslator()
{

View File

@@ -22,74 +22,231 @@
/*************************************************************************************/
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
*
* @package Thelia\Controller\Install
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Guillaume MOREL <gmorel@openstudio.fr>
*/
class InstallController extends BaseInstallController
{
public function index()
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");
}
public function checkPermission()
/**
* Integration tests
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function checkPermissionAction()
{
//$this->verifyStep(2);
try {
//$this->verifyStep(2); // @todo implement
$checkPermission = new CheckPermission(true, $this->getTranslator());
$args['isValid'] = $isValid = $checkPermission->exec();
$args['validationMessages'] = $checkPermission->getValidationMessages();
//$permission = new CheckPermission();
$this->getSession()->set("step", 2);
} catch (AlreadyInstallException $e) {
$args['isAlreadyInstalled'] = true;
}
$args = array();
$this->getSession()->set("step", 2);
return $this->render("step-2.html");
return $this->render("step-2.html", $args);
}
public function databaseConnection()
/**
* Database connexion tests
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function databaseConnectionAction()
{
//$this->verifyStep(2);
$args = array();
//$permission = new CheckPermission();
try {
//$this->verifyStep(2); // @todo implement
$this->getSession()->set("step", 3);
return $this->render("step-3.html");
if ($this->getRequest()->isMethod('POST')) {
// Create the form from the request
$step3Form = new InstallStep3Form($this->getRequest());
$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);
}
public function databaseSelection()
/**
* Database selection
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function databaseSelectionAction()
{
//$this->verifyStep(2);
$args = array();
try {
} catch (AlreadyInstallException $e) {
$args['isAlreadyInstalled'] = true;
}
//$this->verifyStep(2); // @todo implement
//$permission = new CheckPermission();
$this->getSession()->set("step", 4);
return $this->render("step-4.html");
}
public function generalInformation()
/**
* 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();
$this->getSession()->set("step", 5);
return $this->render("step-5.html");
}
public function thanks()
/**
* Display Thanks page
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function thanksAction()
{
//$this->verifyStep(2);
$args = array();
try {
} catch (AlreadyInstallException $e) {
$args['isAlreadyInstalled'] = true;
}
//$this->verifyStep(2); // @todo implement
//$permission = new CheckPermission();
$this->getSession()->set("step", 6);
return $this->render("thanks.html");
}
/**
* Verify each steps and redirect if one step has already been passed
*
* @param int $step Step number
*
* @return bool
*/
protected function verifyStep($step)
{
$session = $this->getSession();
@@ -107,5 +264,7 @@ class InstallController extends BaseInstallController
}
break;
}
return true;
}
}