Merge branch 'master' into loops
Conflicts: core/lib/Thelia/Core/Template/Loop/Category.php core/lib/Thelia/Core/Template/Loop/FeatureValue.php core/lib/Thelia/Core/Template/Loop/Folder.php core/lib/Thelia/Core/Template/Loop/Product.php core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php install/faker.php
This commit is contained in:
10
documentation/api/files/Form/AdminLogin.php.txt
Normal file → Executable file
10
documentation/api/files/Form/AdminLogin.php.txt
Normal file → Executable file
@@ -22,13 +22,11 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
|
||||
class AdminLogin extends BaseForm {
|
||||
|
||||
class AdminLogin extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
@@ -40,11 +38,11 @@ class AdminLogin extends BaseForm {
|
||||
))
|
||||
->add("password", "password", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add("remember_me", "checkbox", array(
|
||||
'value' => 'yes'
|
||||
'value' => 'yes'
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
78
documentation/api/files/Form/BaseForm.php.txt
Normal file → Executable file
78
documentation/api/files/Form/BaseForm.php.txt
Normal file → Executable file
@@ -24,7 +24,6 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
||||
use Symfony\Component\Form\Forms;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
|
||||
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
||||
@@ -33,7 +32,8 @@ use Symfony\Component\Validator\Validation;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
abstract class BaseForm {
|
||||
abstract class BaseForm
|
||||
{
|
||||
/**
|
||||
* @var \Symfony\Component\Form\FormFactoryInterface
|
||||
*/
|
||||
@@ -46,33 +46,33 @@ abstract class BaseForm {
|
||||
|
||||
protected $request;
|
||||
|
||||
private $view = null;
|
||||
private $view = null;
|
||||
|
||||
/**
|
||||
* true if the form has an error, false otherwise.
|
||||
* @var boolean
|
||||
*/
|
||||
private $has_error = false;
|
||||
/**
|
||||
* true if the form has an error, false otherwise.
|
||||
* @var boolean
|
||||
*/
|
||||
private $has_error = false;
|
||||
|
||||
/**
|
||||
* The form error message.
|
||||
* @var string
|
||||
*/
|
||||
private $error_message = '';
|
||||
/**
|
||||
* The form error message.
|
||||
* @var string
|
||||
*/
|
||||
private $error_message = '';
|
||||
|
||||
public function __construct(Request $request, $type= "form", $data = array(), $options = array())
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->request = $request;
|
||||
|
||||
$validator = Validation::createValidator();
|
||||
|
||||
if(!isset($options["attr"]["name"])) {
|
||||
if (!isset($options["attr"]["name"])) {
|
||||
$options["attr"]["thelia_name"] = $this->getName();
|
||||
}
|
||||
|
||||
$builder = Forms::createFormFactoryBuilder()
|
||||
->addExtension(new HttpFoundationExtension());
|
||||
if(!isset($options["csrf_protection"]) || $options["csrf_protection"] !== false) {
|
||||
if (!isset($options["csrf_protection"]) || $options["csrf_protection"] !== false) {
|
||||
$builder->addExtension(
|
||||
new CsrfExtension(
|
||||
new SessionCsrfProvider(
|
||||
@@ -92,14 +92,15 @@ abstract class BaseForm {
|
||||
|
||||
// If not already set, define the success_url field
|
||||
if (! $this->formBuilder->has('success_url')) {
|
||||
$this->formBuilder->add("success_url", "text");
|
||||
$this->formBuilder->add("success_url", "text");
|
||||
}
|
||||
|
||||
$this->form = $this->formBuilder->getForm();
|
||||
}
|
||||
|
||||
public function getRequest() {
|
||||
return $this->request;
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
protected function cleanOptions($options)
|
||||
@@ -116,28 +117,29 @@ abstract class BaseForm {
|
||||
*
|
||||
* @return string an absolute URL
|
||||
*/
|
||||
public function getSuccessUrl($default = null) {
|
||||
public function getSuccessUrl($default = null)
|
||||
{
|
||||
$successUrl = $this->form->get('success_url')->getData();
|
||||
|
||||
$successUrl = $this->form->get('success_url')->getData();
|
||||
if (empty($successUrl)) {
|
||||
|
||||
if (empty($successUrl)) {
|
||||
if ($default === null) $default = ConfigQuery::read('base_url', '/');
|
||||
|
||||
if ($default === null) $default = ConfigQuery::read('base_url', '/');
|
||||
$successUrl = $default;
|
||||
}
|
||||
|
||||
$successUrl = $default;
|
||||
}
|
||||
|
||||
return URL::absoluteUrl($successUrl);
|
||||
return URL::absoluteUrl($successUrl);
|
||||
}
|
||||
|
||||
public function createView() {
|
||||
$this->view = $this->form->createView();
|
||||
public function createView()
|
||||
{
|
||||
$this->view = $this->form->createView();
|
||||
}
|
||||
|
||||
public function getView() {
|
||||
if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first.");
|
||||
|
||||
return $this->view;
|
||||
public function getView()
|
||||
{
|
||||
if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first.");
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
// -- Error and errro message ----------------------------------------------
|
||||
@@ -149,7 +151,7 @@ abstract class BaseForm {
|
||||
*/
|
||||
public function setError($has_error = true)
|
||||
{
|
||||
$this->has_error = $has_error;
|
||||
$this->has_error = $has_error;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +161,7 @@ abstract class BaseForm {
|
||||
*/
|
||||
public function hasError()
|
||||
{
|
||||
return $this->has_error;
|
||||
return $this->has_error;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +171,8 @@ abstract class BaseForm {
|
||||
*/
|
||||
public function setErrorMessage($message)
|
||||
{
|
||||
$this->error_message = $message;
|
||||
$this->setError(true);
|
||||
$this->error_message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +182,7 @@ abstract class BaseForm {
|
||||
*/
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return $this->error_message;
|
||||
return $this->error_message;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,4 +221,3 @@ abstract class BaseForm {
|
||||
abstract public function getName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
6
documentation/api/files/Form/CartAdd.php.txt
Normal file → Executable file
6
documentation/api/files/Form/CartAdd.php.txt
Normal file → Executable file
@@ -22,11 +22,10 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Action\Exception\StockNotFoundException;
|
||||
use Thelia\Action\Exception\ProductNotFoundException;
|
||||
use Thelia\Form\Exception\StockNotFoundException;
|
||||
use Thelia\Form\Exception\ProductNotFoundException;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
@@ -136,3 +135,4 @@ class CartAdd extends BaseForm
|
||||
return "thelia_cart_add";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
documentation/api/files/Form/CategoryCreationForm.php.txt
Normal file → Executable file
13
documentation/api/files/Form/CategoryCreationForm.php.txt
Normal file → Executable file
@@ -22,11 +22,10 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class CategoryCreationForm extends BaseForm {
|
||||
|
||||
class CategoryCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
@@ -37,13 +36,13 @@ class CategoryCreationForm extends BaseForm {
|
||||
))
|
||||
->add("parent", "integer", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add("locale", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
10
documentation/api/files/Form/CategoryDeletionForm.php.txt
Normal file → Executable file
10
documentation/api/files/Form/CategoryDeletionForm.php.txt
Normal file → Executable file
@@ -22,17 +22,16 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class CategoryDeletionForm extends BaseForm {
|
||||
|
||||
class CategoryDeletionForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "integer", array(
|
||||
->add("category_id", "integer", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
;
|
||||
@@ -43,3 +42,4 @@ class CategoryDeletionForm extends BaseForm {
|
||||
return "thelia_category_deletion";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
documentation/api/files/Form/CustomerCreation.php.txt
Normal file → Executable file
2
documentation/api/files/Form/CustomerCreation.php.txt
Normal file → Executable file
@@ -33,6 +33,7 @@ class CustomerCreation extends BaseForm
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("auto_login", "integer")
|
||||
->add("firstname", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank()
|
||||
@@ -163,3 +164,4 @@ class CustomerCreation extends BaseForm
|
||||
return "thelia_customer_creation";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
documentation/api/files/Form/CustomerLogin.php.txt
Normal file → Executable file
10
documentation/api/files/Form/CustomerLogin.php.txt
Normal file → Executable file
@@ -22,15 +22,11 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
|
||||
class CustomerLogin extends BaseForm {
|
||||
|
||||
class CustomerLogin extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
@@ -42,7 +38,7 @@ class CustomerLogin extends BaseForm {
|
||||
))
|
||||
->add("password", "password", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add("remember_me", "checkbox")
|
||||
|
||||
8
documentation/api/files/Form/CustomerModification.php.txt
Normal file → Executable file
8
documentation/api/files/Form/CustomerModification.php.txt
Normal file → Executable file
@@ -24,11 +24,9 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
|
||||
class CustomerModification extends BaseForm {
|
||||
|
||||
class CustomerModification extends BaseForm
|
||||
{
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
@@ -53,6 +51,7 @@ class CustomerModification extends BaseForm {
|
||||
{
|
||||
|
||||
$this->formBuilder
|
||||
->add('update_logged_in_user', 'boolean') // In a front office context, update the in-memory logged-in user data
|
||||
->add("firstname", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank()
|
||||
@@ -118,3 +117,4 @@ class CustomerModification extends BaseForm {
|
||||
return "thelia_customer_modification";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
29
documentation/api/files/Form/Exception/FormValidationException.php.txt
Executable file
29
documentation/api/files/Form/Exception/FormValidationException.php.txt
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Exception;
|
||||
|
||||
class FormValidationException extends \RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
29
documentation/api/files/Form/Exception/ProductNotFoundException.php.txt
Executable file
29
documentation/api/files/Form/Exception/ProductNotFoundException.php.txt
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Exception;
|
||||
|
||||
class ProductNotFoundException extends FormValidationException
|
||||
{
|
||||
}
|
||||
|
||||
30
documentation/api/files/Form/Exception/StockNotFoundException.php.txt
Executable file
30
documentation/api/files/Form/Exception/StockNotFoundException.php.txt
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Exception;
|
||||
|
||||
class StockNotFoundException extends FormValidationException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user