apply php-cs-fiwer on Action directory

This commit is contained in:
Manuel Raynaud
2013-08-09 10:38:58 +02:00
parent 7071ffc686
commit 31743fd987
7 changed files with 125 additions and 157 deletions

View File

@@ -23,43 +23,38 @@
namespace Thelia\Action;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Thelia\Form\CategoryDeletionForm;
use Thelia\Form\BaseForm;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Action\Exception\FormValidationException;
use Thelia\Core\Event\ActionEvent;
abstract class BaseAction
{
protected function validateForm(BaseForm $aBaseForm, $expectedMethod = null)
{
$form = $aBaseForm->getForm();
protected function validateForm(BaseForm $aBaseForm, $expectedMethod = null)
{
$form = $aBaseForm->getForm();
if ($aBaseForm->getRequest()->isMethod($expectedMethod)) {
if ($aBaseForm->getRequest()->isMethod($expectedMethod)) {
$form->bind($aBaseForm->getRequest());
$form->bind($aBaseForm->getRequest());
if ($form->isValid()) {
return $form;
}
else {
throw new FormValidationException("Missing or invalid data");
if ($form->isValid()) {
return $form;
} else {
throw new FormValidationException("Missing or invalid data");
}
} else {
throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod));
}
else {
throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod));
}
}
/**
*
* @param BaseForm $aBaseForm
* @param string $error_message
* @param ActionEvent $event
*/
protected function propagateFormError(BaseForm $aBaseForm, $error_message, ActionEvent $event) {
}
/**
*
* @param BaseForm $aBaseForm
* @param string $error_message
* @param ActionEvent $event
*/
protected function propagateFormError(BaseForm $aBaseForm, $error_message, ActionEvent $event)
{
// The form has an error
$aBaseForm->setError(true);
$aBaseForm->setErrorMessage($error_message);
@@ -69,7 +64,7 @@ abstract class BaseAction
// Stop event propagation
$event->stopPropagation();
}
}
protected function redirect($url, $status = 302)
{
@@ -79,4 +74,4 @@ abstract class BaseAction
exit;
}
}
}