apply cs-fixer

This commit is contained in:
Manuel Raynaud
2013-08-14 09:29:04 +02:00
parent a3fcb222be
commit 078b1e0d57
125 changed files with 1339 additions and 1491 deletions

View File

@@ -22,15 +22,12 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Action; namespace Thelia\Action;
use Thelia\Form\BaseForm; use Thelia\Form\BaseForm;
use Thelia\Action\Exception\FormValidationException; use Thelia\Action\Exception\FormValidationException;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
class BaseAction class BaseAction
{ {
@@ -39,7 +36,8 @@ class BaseAction
*/ */
protected $container; protected $container;
public function __construct(ContainerInterface $container) { public function __construct(ContainerInterface $container)
{
$this->container = $container; $this->container = $container;
} }
@@ -60,14 +58,11 @@ class BaseAction
$form->bind($aBaseForm->getRequest()); $form->bind($aBaseForm->getRequest());
if ($form->isValid()) { if ($form->isValid()) {
return $form; return $form;
} } else {
else {
throw new FormValidationException("Missing or invalid data"); throw new FormValidationException("Missing or invalid data");
} }
} } else {
else {
throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod)); throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod));
} }
} }
@@ -79,8 +74,8 @@ class BaseAction
* @param string $error_message an error message that may be displayed to the customer * @param string $error_message an error message that may be displayed to the customer
* @param ActionEvent $event the action event * @param ActionEvent $event the action event
*/ */
protected function propagateFormError(BaseForm $aBaseForm, $error_message, ActionEvent $event) { protected function propagateFormError(BaseForm $aBaseForm, $error_message, ActionEvent $event)
{
// The form has an error // The form has an error
$aBaseForm->setError(true); $aBaseForm->setError(true);
$aBaseForm->setErrorMessage($error_message); $aBaseForm->setErrorMessage($error_message);

View File

@@ -25,10 +25,8 @@ namespace Thelia\Action;
use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\CartEvent; use Thelia\Core\Event\CartEvent;
use Thelia\Form\CartAdd; use Thelia\Form\CartAdd;
use Thelia\Model\ProductPrice; use Thelia\Model\ProductPrice;
@@ -99,7 +97,6 @@ class Cart extends BaseAction implements EventSubscriberInterface
} }
/** /**
* *
* Delete specify article present into cart * Delete specify article present into cart
@@ -184,8 +181,6 @@ class Cart extends BaseAction implements EventSubscriberInterface
); );
} }
/** /**
* increase the quantity for an existing cartItem * increase the quantity for an existing cartItem
* *

View File

@@ -40,7 +40,6 @@ use Propel\Runtime\Propel;
use Thelia\Model\Map\CategoryTableMap; use Thelia\Model\Map\CategoryTableMap;
use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Exception\PropelException;
class Category extends BaseAction implements EventSubscriberInterface class Category extends BaseAction implements EventSubscriberInterface
{ {
public function create(ActionEvent $event) public function create(ActionEvent $event)
@@ -237,7 +236,8 @@ class Category extends BaseAction implements EventSubscriberInterface
* *
* @param ActionEvent $event * @param ActionEvent $event
*/ */
public function changePositionUp(ActionEvent $event) { public function changePositionUp(ActionEvent $event)
{
return $this->exchangePosition($event, 'up'); return $this->exchangePosition($event, 'up');
} }
@@ -246,7 +246,8 @@ class Category extends BaseAction implements EventSubscriberInterface
* *
* @param ActionEvent $event * @param ActionEvent $event
*/ */
public function changePositionDown(ActionEvent $event) { public function changePositionDown(ActionEvent $event)
{
return $this->exchangePosition($event, 'down'); return $this->exchangePosition($event, 'down');
} }
@@ -256,8 +257,8 @@ class Category extends BaseAction implements EventSubscriberInterface
* @param ActionEvent $event * @param ActionEvent $event
* @param string $direction up to move up, down to move down * @param string $direction up to move up, down to move down
*/ */
protected function exchangePosition(ActionEvent $event, $direction) { protected function exchangePosition(ActionEvent $event, $direction)
{
$this->checkAuth("ADMIN", "admin.category.edit"); $this->checkAuth("ADMIN", "admin.category.edit");
$request = $event->getRequest(); $request = $event->getRequest();
@@ -277,17 +278,15 @@ class Category extends BaseAction implements EventSubscriberInterface
if ($direction == 'up') { if ($direction == 'up') {
// Find the category immediately before me // Find the category immediately before me
$search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC); $search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC);
} } elseif ($direction == 'down') {
else if ($direction == 'down') {
// Find the category immediately after me // Find the category immediately after me
$search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC); $search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC);
} } else
else
return; return;
$result = $search->findOne(); $result = $search->findOne();
// If we found the proper category, exchange their positions // If we found the proper category, exchange their positions
if ($result) { if ($result) {
@@ -301,8 +300,7 @@ class Category extends BaseAction implements EventSubscriberInterface
$result->setPosition($my_position)->save(); $result->setPosition($my_position)->save();
$cnx->commit(); $cnx->commit();
} } catch (Exception $e) {
catch(Exception $e) {
$cnx->rollback(); $cnx->rollback();
} }
} }
@@ -314,8 +312,8 @@ class Category extends BaseAction implements EventSubscriberInterface
* *
* @param ActionEvent $event * @param ActionEvent $event
*/ */
public function changePosition(ActionEvent $event) { public function changePosition(ActionEvent $event)
{
$this->checkAuth("ADMIN", "admin.category.edit"); $this->checkAuth("ADMIN", "admin.category.edit");
$request = $event->getRequest(); $request = $event->getRequest();
@@ -340,8 +338,7 @@ class Category extends BaseAction implements EventSubscriberInterface
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position)); $search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position));
$delta = -1; $delta = -1;
} } else {
else {
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position // The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
$search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1)); $search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1));
@@ -362,8 +359,7 @@ class Category extends BaseAction implements EventSubscriberInterface
$category->setPosition($new_position)->save($cnx); $category->setPosition($new_position)->save($cnx);
$cnx->commit(); $cnx->commit();
} } catch (Exception $e) {
catch(Exception $e) {
$cnx->rollback(); $cnx->rollback();
} }
} }

View File

@@ -26,7 +26,6 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\BaseForm;
use Thelia\Form\CustomerCreation; use Thelia\Form\CustomerCreation;
use Thelia\Form\CustomerModification; use Thelia\Form\CustomerModification;
use Thelia\Model\Customer as CustomerModel; use Thelia\Model\Customer as CustomerModel;
@@ -34,7 +33,6 @@ use Thelia\Log\Tlog;
use Thelia\Model\CustomerQuery; use Thelia\Model\CustomerQuery;
use Thelia\Form\CustomerLogin; use Thelia\Form\CustomerLogin;
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
use Thelia\Core\Security\SecurityContext;
use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Exception\ValidatorException;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\UsernameNotFoundException; use Thelia\Core\Security\Exception\UsernameNotFoundException;
@@ -122,7 +120,6 @@ class Customer extends BaseAction implements EventSubscriberInterface
$this->processSuccessfullLogin($event, $customer, $customerModification); $this->processSuccessfullLogin($event, $customer, $customerModification);
} catch (PropelException $e) { } catch (PropelException $e) {
Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage())); Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage()));
$message = "Failed to change your account, please try again."; $message = "Failed to change your account, please try again.";
@@ -144,7 +141,6 @@ class Customer extends BaseAction implements EventSubscriberInterface
{ {
$event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGOUT, $event); $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGOUT, $event);
$this->getFrontSecurityContext()->clear(); $this->getFrontSecurityContext()->clear();
} }

View File

@@ -22,10 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Cart; namespace Thelia\Cart;
use Thelia\Model\ProductPrice;
use Thelia\Model\ProductPriceQuery;
use Thelia\Model\CartItem;
use Thelia\Model\CartItemQuery;
use Thelia\Model\CartQuery; use Thelia\Model\CartQuery;
use Thelia\Model\Cart as CartModel; use Thelia\Model\Cart as CartModel;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
@@ -35,7 +31,8 @@ use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Event\Internal\CartEvent; use Thelia\Core\Event\Internal\CartEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
trait CartTrait { trait CartTrait
{
/** /**
* *
* search if cart already exists in session. If not try to create a new one or duplicate an old one. * search if cart already exists in session. If not try to create a new one or duplicate an old one.
@@ -103,7 +100,6 @@ trait CartTrait {
return $cart; return $cart;
} }
/** /**
* try to duplicate existing Cart. Customer is here to determine if this cart belong to him. * try to duplicate existing Cart. Customer is here to determine if this cart belong to him.
* *

View File

@@ -22,12 +22,8 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Command; namespace Thelia\Command;
use Propel\Runtime\Propel; abstract class BaseModuleGenerate extends ContainerAwareCommand
use Symfony\Component\Console\Application; {
abstract class BaseModuleGenerate extends ContainerAwareCommand {
protected $module; protected $module;
protected $moduleDirectory; protected $moduleDirectory;
@@ -53,6 +49,7 @@ abstract class BaseModuleGenerate extends ContainerAwareCommand {
if (in_array(strtolower($name), $this->reservedKeyWords)) { if (in_array(strtolower($name), $this->reservedKeyWords)) {
throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name)); throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name));
} }
return ucfirst($name); return ucfirst($name);
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Command; namespace Thelia\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;

View File

@@ -32,7 +32,8 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class ContainerAwareCommand extends Command implements ContainerAwareInterface { class ContainerAwareCommand extends Command implements ContainerAwareInterface
{
/** /**
* @var ContainerInterface * @var ContainerInterface
*/ */

View File

@@ -29,7 +29,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Thelia\Command\ContainerAwareCommand; use Thelia\Command\ContainerAwareCommand;
class Install extends ContainerAwareCommand class Install extends ContainerAwareCommand
{ {
/** /**
@@ -80,7 +79,6 @@ class Install extends ContainerAwareCommand
$this->checkPermission($output); $this->checkPermission($output);
$connectionInfo = array( $connectionInfo = array(
"host" => $input->getOption("db_host"), "host" => $input->getOption("db_host"),
"dbName" => $input->getOption("db_name"), "dbName" => $input->getOption("db_name"),
@@ -88,8 +86,6 @@ class Install extends ContainerAwareCommand
"password" => $input->getOption("db_password") "password" => $input->getOption("db_password")
); );
while (false === $connection = $this->tryConnection($connectionInfo, $output)) { while (false === $connection = $this->tryConnection($connectionInfo, $output)) {
$connectionInfo = $this->getConnectionInfo($input, $output); $connectionInfo = $this->getConnectionInfo($input, $output);
} }
@@ -164,8 +160,6 @@ class Install extends ContainerAwareCommand
exit; exit;
} }
} }
/** /**
@@ -180,7 +174,6 @@ class Install extends ContainerAwareCommand
$sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample"; $sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample";
$configFile = THELIA_ROOT . "/local/config/database.yml"; $configFile = THELIA_ROOT . "/local/config/database.yml";
$fs->copy($sampleConfigFile, $configFile, true); $fs->copy($sampleConfigFile, $configFile, true);
$configContent = file_get_contents($configFile); $configContent = file_get_contents($configFile);
@@ -200,7 +193,6 @@ class Install extends ContainerAwareCommand
$fs->remove($this->getContainer()->getParameter("kernel.cache_dir")); $fs->remove($this->getContainer()->getParameter("kernel.cache_dir"));
} }
/** /**
@@ -288,11 +280,10 @@ class Install extends ContainerAwareCommand
$output->writeln(array( $output->writeln(array(
"<error>Wrong connection information</error>" "<error>Wrong connection information</error>"
)); ));
return false; return false;
} }
return $connection; return $connection;
} }

View File

@@ -22,16 +22,13 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Command; namespace Thelia\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateCommand extends BaseModuleGenerate { class ModuleGenerateCommand extends BaseModuleGenerate
{
protected function configure() protected function configure()
{ {
$this $this
@@ -99,6 +96,4 @@ class ModuleGenerateCommand extends BaseModuleGenerate {
file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "schema.xml", $schemaContent); file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "schema.xml", $schemaContent);
} }
} }

View File

@@ -23,18 +23,16 @@
namespace Thelia\Command; namespace Thelia\Command;
use Propel\Generator\Command\ModelBuildCommand; use Propel\Generator\Command\ModelBuildCommand;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateModelCommand extends BaseModuleGenerate { class ModuleGenerateModelCommand extends BaseModuleGenerate
{
protected function configure() protected function configure()
{ {
$this $this
@@ -124,7 +122,6 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate {
} }
} }
} }
} }

View File

@@ -23,17 +23,15 @@
namespace Thelia\Command; namespace Thelia\Command;
use Propel\Generator\Command\SqlBuildCommand; use Propel\Generator\Command\SqlBuildCommand;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateSqlCommand extends BaseModuleGenerate { class ModuleGenerateSqlCommand extends BaseModuleGenerate
{
public function configure() public function configure()
{ {
$this $this

View File

@@ -23,11 +23,10 @@
namespace Thelia\Command\Output; namespace Thelia\Command\Output;
use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\ConsoleOutput;
class TheliaConsoleOutput extends ConsoleOutput{ class TheliaConsoleOutput extends ConsoleOutput
{
public function renderBlock(array $messages, $style = "info") public function renderBlock(array $messages, $style = "info")
{ {
$strlen = function ($string) { $strlen = function ($string) {

View File

@@ -21,12 +21,11 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace %%NAMESPACE%%; namespace %%NAMESPACE%%;
use Thelia\Module\BaseModule; use Thelia\Module\BaseModule;
class %%CLASSNAME%% extends BaseModule class Class extends BaseModule
{ {
/** /**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class

View File

@@ -26,9 +26,8 @@ namespace Thelia\Config;
use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
class DefinePropel
class DefinePropel { {
private $processorConfig; private $processorConfig;
public function __construct(ConfigurationInterface $configuration, array $propelConf) public function __construct(ConfigurationInterface $configuration, array $propelConf)
@@ -40,6 +39,7 @@ class DefinePropel {
public function getConfig() public function getConfig()
{ {
$connection = $this->processorConfig["connection"]; $connection = $this->processorConfig["connection"];
return $conf = array( return $conf = array(
"dsn" => $connection["dsn"], "dsn" => $connection["dsn"],
"user" => $connection["user"], "user" => $connection["user"],

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Controller\Front; namespace Thelia\Controller\Front;
use Thelia\Controller\NullControllerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
/** /**

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core; namespace Thelia\Core;
class Context class Context
{ {
const CONTEXT_FRONT_OFFICE = 'front'; const CONTEXT_FRONT_OFFICE = 'front';
@@ -43,8 +42,7 @@ class Context
public function setContext($context) public function setContext($context)
{ {
if($this->isValidContext($context)) if ($this->isValidContext($context)) {
{
$this->currentContext = $context; $this->currentContext = $context;
} }
} }

View File

@@ -22,10 +22,8 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\DependencyInjection\Compiler; namespace Thelia\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
@@ -55,8 +53,6 @@ class RegisterRouterPass implements CompilerPassInterface
$chainRouter->addMethodCall("add", array(new Reference($id), $priority)); $chainRouter->addMethodCall("add", array(new Reference($id), $priority));
} }
} }
} }

View File

@@ -26,7 +26,6 @@ namespace Thelia\Core\Event;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
use Thelia\Form\BaseForm; use Thelia\Form\BaseForm;
use Thelia\Core\Security\SecurityContext;
/** /**
* *
* Class thrown on Thelia.action event * Class thrown on Thelia.action event
@@ -43,7 +42,6 @@ abstract class ActionEvent extends Event
*/ */
protected $request; protected $request;
protected $errorForm = null; protected $errorForm = null;
protected $parameters = array(); protected $parameters = array();
@@ -58,7 +56,6 @@ abstract class ActionEvent extends Event
$this->request = $request; $this->request = $request;
} }
public function __set($name, $value) public function __set($name, $value)
{ {
$this->parameters[$name] = $value; $this->parameters[$name] = $value;
@@ -82,17 +79,20 @@ abstract class ActionEvent extends Event
return $this->request; return $this->request;
} }
public function setErrorForm(BaseForm $form) { public function setErrorForm(BaseForm $form)
{
$this->errorForm = $form; $this->errorForm = $form;
if ($form != null) $this->stopPropagation(); if ($form != null) $this->stopPropagation();
} }
public function getErrorForm() { public function getErrorForm()
{
return $this->errorForm; return $this->errorForm;
} }
public function hasErrorForm() { public function hasErrorForm()
{
return $this->errorForm != null ? true : false; return $this->errorForm != null ? true : false;
} }
} }

View File

@@ -26,8 +26,8 @@ namespace Thelia\Core\Event;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
use Thelia\Model\Cart; use Thelia\Model\Cart;
class CartEvent extends ActionEvent { class CartEvent extends ActionEvent
{
protected $cart; protected $cart;
public function __construct(Request $request, Cart $cart) public function __construct(Request $request, Cart $cart)

View File

@@ -23,11 +23,10 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\CartItem; use Thelia\Model\CartItem;
class CartItemEvent extends InternalEvent { class CartItemEvent extends InternalEvent
{
protected $cartItem; protected $cartItem;
public function __construct(CartItem $cartItem) public function __construct(CartItem $cartItem)

View File

@@ -23,11 +23,10 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Category; use Thelia\Model\Category;
class CategoryEvent extends InternalEvent { class CategoryEvent extends InternalEvent
{
public $category; public $category;
public function __construct(Category $category) public function __construct(Category $category)

View File

@@ -21,14 +21,12 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event\Internal; namespace Thelia\Core\Event\Internal;
use Thelia\Model\Cart; use Thelia\Model\Cart;
class CartEvent extends InternalEvent { class CartEvent extends InternalEvent
{
public $cart; public $cart;
public function __construct(Cart $cart) public function __construct(Cart $cart)
@@ -36,6 +34,4 @@ class CartEvent extends InternalEvent {
$this->cart = $cart; $this->cart = $cart;
} }
} }

View File

@@ -23,11 +23,10 @@
namespace Thelia\Core\Event\Internal; namespace Thelia\Core\Event\Internal;
use Thelia\Model\Customer; use Thelia\Model\Customer;
class CustomerEvent extends InternalEvent { class CustomerEvent extends InternalEvent
{
public $customer; public $customer;
public function __construct(Customer $customer) public function __construct(Customer $customer)

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Internal; namespace Thelia\Core\Event\Internal;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
/** /**
@@ -32,6 +31,6 @@ use Symfony\Component\EventDispatcher\Event;
* Class InternalEvent * Class InternalEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
*/ */
abstract class InternalEvent extends Event { abstract class InternalEvent extends Event
{
} }

View File

@@ -65,8 +65,6 @@ final class TheliaEvents
*/ */
const ADMIN_LOGIN = "action.admin_login"; const ADMIN_LOGIN = "action.admin_login";
/** /**
* Sent once the customer creation form has been successfully validated, and before customer insertion in the database. * Sent once the customer creation form has been successfully validated, and before customer insertion in the database.
*/ */
@@ -86,8 +84,6 @@ final class TheliaEvents
*/ */
const AFTER_CHANGECUSTOMER = "action.after_changecustomer"; const AFTER_CHANGECUSTOMER = "action.after_changecustomer";
/** /**
* Sent once the category creation form has been successfully validated, and before category insertion in the database. * Sent once the category creation form has been successfully validated, and before category insertion in the database.
*/ */
@@ -112,7 +108,6 @@ final class TheliaEvents
*/ */
const AFTER_CHANGECATEGORY = "action.after_changecategory"; const AFTER_CHANGECATEGORY = "action.after_changecategory";
/** /**
* sent when a new existing cat id duplicated. This append when current customer is different from current cart * sent when a new existing cat id duplicated. This append when current customer is different from current cart
*/ */

View File

@@ -44,7 +44,8 @@ class ControllerListener implements EventSubscriberInterface
*/ */
protected $parserContext; protected $parserContext;
public function __construct(ParserContext $parserContext) { public function __construct(ParserContext $parserContext)
{
$this->parserContext = $parserContext; $this->parserContext = $parserContext;
} }

View File

@@ -81,11 +81,9 @@ class ViewListener implements EventSubscriberInterface
} else { } else {
$event->setResponse(new Response($content, $parser->getStatus() ?: 200)); $event->setResponse(new Response($content, $parser->getStatus() ?: 200));
} }
} } catch (ResourceNotFoundException $e) {
catch (ResourceNotFoundException $e) {
$event->setResponse(new Response($e->getMessage(), 404)); $event->setResponse(new Response($e->getMessage(), 404));
} } catch (AuthenticationException $ex) {
catch (AuthenticationException $ex) {
// Redirect to the login template // Redirect to the login template
$event->setResponse(Redirect::exec(URL::viewUrl($ex->getLoginTemplate()))); $event->setResponse(Redirect::exec(URL::viewUrl($ex->getLoginTemplate())));

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\HttpFoundation; namespace Thelia\Core\HttpFoundation;
use Symfony\Component\HttpFoundation\Request as BaseRequest; use Symfony\Component\HttpFoundation\Request as BaseRequest;
use Thelia\Core\Context;
class Request extends BaseRequest class Request extends BaseRequest
{ {
@@ -46,6 +45,7 @@ class Request extends BaseRequest
if ('' == $this->getQueryString()) { if ('' == $this->getQueryString()) {
$additionalQs = '?'. ltrim($additionalQs, '&'); $additionalQs = '?'. ltrim($additionalQs, '&');
} }
return $uri . $additionalQs; return $uri . $additionalQs;
} }
} }

View File

@@ -31,9 +31,10 @@ use Thelia\Core\Security\UserProvider\AdminUserProvider;
use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator;
use Thelia\Form\AdminLogin; use Thelia\Form\AdminLogin;
class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator
{
public function __construct(Request $request, AdminLogin $loginForm) { public function __construct(Request $request, AdminLogin $loginForm)
{
parent::__construct( parent::__construct(
$request, $request,
$loginForm, $loginForm,

View File

@@ -23,8 +23,8 @@
namespace Thelia\Core\Security\Authentication; namespace Thelia\Core\Security\Authentication;
interface AuthenticatorInterface { interface AuthenticatorInterface
{
/** /**
* Returns a UserInterface instance, authentified using the authenticator specific method * Returns a UserInterface instance, authentified using the authenticator specific method
*/ */

View File

@@ -29,9 +29,10 @@ use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator;
use Thelia\Form\CustomerLogin; use Thelia\Form\CustomerLogin;
use Thelia\Core\Security\UserProvider\CustomerUserProvider; use Thelia\Core\Security\UserProvider\CustomerUserProvider;
class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator
{
public function __construct(Request $request, CustomerLogin $loginForm) { public function __construct(Request $request, CustomerLogin $loginForm)
{
parent::__construct( parent::__construct(
$request, $request,
$loginForm, $loginForm,

View File

@@ -32,8 +32,8 @@ use Thelia\Core\Security\Exception\UsernameNotFoundException;
use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Exception\ValidatorException;
use Thelia\Form\BaseForm; use Thelia\Form\BaseForm;
class UsernamePasswordFormAuthenticator implements AuthenticatorInterface { class UsernamePasswordFormAuthenticator implements AuthenticatorInterface
{
protected $request; protected $request;
protected $loginForm; protected $loginForm;
protected $userProvider; protected $userProvider;
@@ -41,7 +41,8 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface {
protected $baseLoginForm; protected $baseLoginForm;
public function __construct(Request $request, BaseForm $loginForm, UserProviderInterface $userProvider, array $options = array()) { public function __construct(Request $request, BaseForm $loginForm, UserProviderInterface $userProvider, array $options = array())
{
$this->request = $request; $this->request = $request;
$this->baseLoginForm = $loginForm; $this->baseLoginForm = $loginForm;
$this->loginForm = $this->baseLoginForm->getForm(); $this->loginForm = $this->baseLoginForm->getForm();
@@ -61,15 +62,16 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface {
/** /**
* @return string the username value * @return string the username value
*/ */
public function getUsername() { public function getUsername()
{
return $this->loginForm->get($this->options['username_field_name'])->getData(); return $this->loginForm->get($this->options['username_field_name'])->getData();
} }
/** /**
* @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser() * @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser()
*/ */
public function getAuthentifiedUser() { public function getAuthentifiedUser()
{
if ($this->request->isMethod($this->options['required_method'])) { if ($this->request->isMethod($this->options['required_method'])) {
if (! $this->loginForm->isValid()) throw new ValidatorException("Form is not valid."); if (! $this->loginForm->isValid()) throw new ValidatorException("Form is not valid.");
@@ -86,7 +88,6 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface {
$authOk = $user->checkPassword($password) === true; $authOk = $user->checkPassword($password) === true;
if ($authOk !== true) throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username)); if ($authOk !== true) throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username));
return $user; return $user;
} }

View File

@@ -33,7 +33,8 @@ class AuthenticationException extends \Exception
/** /**
* @return string the login template name * @return string the login template name
*/ */
public function getLoginTemplate() { public function getLoginTemplate()
{
return $this->loginTemplate; return $this->loginTemplate;
} }
@@ -42,7 +43,8 @@ class AuthenticationException extends \Exception
* *
* @param string $loginPath the login template name * @param string $loginPath the login template name
*/ */
public function setLoginTemplate($loginTemplate) { public function setLoginTemplate($loginTemplate)
{
$this->loginTemplate = $loginTemplate; $this->loginTemplate = $loginTemplate;
} }
} }

View File

@@ -39,7 +39,8 @@ class Role implements RoleInterface
return $this->role; return $this->role;
} }
public function __toString() { public function __toString()
{
return $this->role; return $this->role;
} }
} }

View File

@@ -23,9 +23,6 @@
namespace Thelia\Core\Security; namespace Thelia\Core\Security;
use Thelia\Core\Security\Authentication\AuthenticationProviderInterface;
use Thelia\Core\Security\Exception\AuthenticationTokenNotFoundException;
use Thelia\Core\Security\Token\TokenInterface;
use Thelia\Core\Security\User\UserInterface; use Thelia\Core\Security\User\UserInterface;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
@@ -34,22 +31,23 @@ use Thelia\Core\HttpFoundation\Request;
* *
* @author Franck Allimant <franck@cqfdev.fr> * @author Franck Allimant <franck@cqfdev.fr>
*/ */
class SecurityContext { class SecurityContext
{
const CONTEXT_FRONT_OFFICE = 'front'; const CONTEXT_FRONT_OFFICE = 'front';
const CONTEXT_BACK_OFFICE = 'admin'; const CONTEXT_BACK_OFFICE = 'admin';
private $request; private $request;
private $context; private $context;
public function __construct(Request $request) { public function __construct(Request $request)
{
$this->request = $request; $this->request = $request;
$this->context = null; $this->context = null;
} }
public function setContext($context) { public function setContext($context)
{
if ($context !== self::CONTEXT_FRONT_OFFICE && $context !== self::CONTEXT_BACK_OFFICE) { if ($context !== self::CONTEXT_FRONT_OFFICE && $context !== self::CONTEXT_BACK_OFFICE) {
throw new \InvalidArgumentException(sprintf("Invalid or empty context identifier '%s'", $context)); throw new \InvalidArgumentException(sprintf("Invalid or empty context identifier '%s'", $context));
} }
@@ -59,14 +57,16 @@ class SecurityContext {
return $this; return $this;
} }
public function getContext($exception_if_context_undefined = false) { public function getContext($exception_if_context_undefined = false)
{
if (null === $this->context && $exception_if_context_undefined === true) if (null === $this->context && $exception_if_context_undefined === true)
throw new \LogicException("No context defined. Please use setContext() first."); throw new \LogicException("No context defined. Please use setContext() first.");
return $this->context; return $this->context;
} }
private function getSession() { private function getSession()
{
$session = $this->request->getSession(); $session = $this->request->getSession();
if ($session === null) if ($session === null)
@@ -80,7 +80,8 @@ class SecurityContext {
* *
* @return UserInterface|null A UserInterface instance or null if no user is available * @return UserInterface|null A UserInterface instance or null if no user is available
*/ */
public function getUser() { public function getUser()
{
$context = $this->getContext(true); $context = $this->getContext(true);
if ($context === self::CONTEXT_FRONT_OFFICE) if ($context === self::CONTEXT_FRONT_OFFICE)
@@ -181,7 +182,8 @@ class SecurityContext {
/** /**
* Clear the user from the security context * Clear the user from the security context
*/ */
public function clear() { public function clear()
{
$context = $this->getContext(true); $context = $this->getContext(true);
if ($context === self::CONTEXT_FRONT_OFFICE) if ($context === self::CONTEXT_FRONT_OFFICE)

View File

@@ -8,8 +8,8 @@ namespace Thelia\Core\Security\User;
* @author Franck Allimant <franck@cqfdev.fr> * @author Franck Allimant <franck@cqfdev.fr>
* *
*/ */
interface UserInterface { interface UserInterface
{
/** /**
* Return the user unique name * Return the user unique name
*/ */

View File

@@ -4,10 +4,10 @@ namespace Thelia\Core\Security\UserProvider;
use Thelia\Model\Admin; use Thelia\Model\Admin;
use Thelia\Model\AdminQuery; use Thelia\Model\AdminQuery;
class AdminUserProvider implements UserProviderInterface { class AdminUserProvider implements UserProviderInterface
{
public function getUser($key) { public function getUser($key)
{
$admin = AdminQuery::create() $admin = AdminQuery::create()
->filterByLogin($key) ->filterByLogin($key)
->findOne(); ->findOne();

View File

@@ -1,13 +1,12 @@
<?php <?php
namespace Thelia\Core\Security\UserProvider; namespace Thelia\Core\Security\UserProvider;
use Thelia\Action\Customer; use Thelia\Action\Customer;
use Thelia\Model\CustomerQuery; use Thelia\Model\CustomerQuery;
class CustomerUserProvider implements UserProviderInterface { class CustomerUserProvider implements UserProviderInterface
{
public function getUser($key) { public function getUser($key)
{
$customer = CustomerQuery::create() $customer = CustomerQuery::create()
->filterByEmail($key) ->filterByEmail($key)
->findOne(); ->findOne();

View File

@@ -2,7 +2,8 @@
namespace Thelia\Core\Security\UserProvider; namespace Thelia\Core\Security\UserProvider;
interface UserProviderInterface { interface UserProviderInterface
{
/** /**
* Returns a UserInterface instance * Returns a UserInterface instance
* *
@@ -11,4 +12,3 @@ interface UserProviderInterface {
*/ */
public function getUser($key); public function getUser($key);
} }
?>

View File

@@ -51,7 +51,6 @@ abstract class BaseLoop
*/ */
protected $securityContext; protected $securityContext;
protected $args; protected $args;
/** /**
@@ -93,8 +92,8 @@ abstract class BaseLoop
* @return null * @return null
* @throws \InvalidArgumentException if the parameter is unknown or the method name is not supported. * @throws \InvalidArgumentException if the parameter is unknown or the method name is not supported.
*/ */
public function __call($name, $arguments) { public function __call($name, $arguments)
{
if (substr($name, 0, 3) == 'get') { if (substr($name, 0, 3) == 'get') {
// camelCase to underscore: getNotEmpty -> not_empty // camelCase to underscore: getNotEmpty -> not_empty
@@ -113,8 +112,8 @@ abstract class BaseLoop
* *
* @throws \InvalidArgumentException if somùe argument values are missing, or invalid * @throws \InvalidArgumentException if somùe argument values are missing, or invalid
*/ */
public function initializeArgs(array $nameValuePairs) { public function initializeArgs(array $nameValuePairs)
{
$faultActor = array(); $faultActor = array();
$faultDetails = array(); $faultDetails = array();
@@ -130,18 +129,15 @@ abstract class BaseLoop
if ($value === null && $argument->mandatory) { if ($value === null && $argument->mandatory) {
$faultActor[] = $argument->name; $faultActor[] = $argument->name;
$faultDetails[] = sprintf('"%s" parameter is missing in loop type: %s, name: %s', $argument->name, $loopType, $loopName); $faultDetails[] = sprintf('"%s" parameter is missing in loop type: %s, name: %s', $argument->name, $loopType, $loopName);
} } else if ($value === '' && !$argument->empty) {
else if($value === '' && !$argument->empty) {
/* check if empty */ /* check if empty */
$faultActor[] = $argument->name; $faultActor[] = $argument->name;
$faultDetails[] = sprintf('"%s" parameter cannot be empty in loop type: %s, name: %s', $argument->name, $loopType, $loopName); $faultDetails[] = sprintf('"%s" parameter cannot be empty in loop type: %s, name: %s', $argument->name, $loopType, $loopName);
} } elseif ($value !== null && !$argument->type->isValid($value)) {
else if($value !== null && !$argument->type->isValid($value)) {
/* check type */ /* check type */
$faultActor[] = $argument->name; $faultActor[] = $argument->name;
$faultDetails[] = sprintf('Invalid value for "%s" argument in loop type: %s, name: %s', $argument->name, $loopType, $loopName); $faultDetails[] = sprintf('Invalid value for "%s" argument in loop type: %s, name: %s', $argument->name, $loopType, $loopName);
} } else {
else {
/* set default */ /* set default */
/* did it as last checking for we consider default value is acceptable no matter type or empty restriction */ /* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
if ($value === null) { if ($value === null) {
@@ -167,8 +163,8 @@ abstract class BaseLoop
* @throws \InvalidArgumentException if argument is not found in loop argument list * @throws \InvalidArgumentException if argument is not found in loop argument list
* @return Argument the loop argument. * @return Argument the loop argument.
*/ */
public function getArg($argumentName) { public function getArg($argumentName)
{
$arg = $this->args->get($argumentName); $arg = $this->args->get($argumentName);
if ($arg === null) if ($arg === null)
@@ -185,8 +181,8 @@ abstract class BaseLoop
* @throws \InvalidArgumentException if argument is not found in loop argument list * @throws \InvalidArgumentException if argument is not found in loop argument list
* @return Argument the loop argument. * @return Argument the loop argument.
*/ */
public function getArgValue($argumentName) { public function getArgValue($argumentName)
{
return $this->getArg($argumentName)->getValue(); return $this->getArg($argumentName)->getValue();
} }

View File

@@ -26,19 +26,12 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Loop\Product; use Thelia\Core\Template\Loop\Product;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\AccessoryQuery; use Thelia\Model\AccessoryQuery;
use Thelia\Model\ProductQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
/** /**

View File

@@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\AddressQuery; use Thelia\Model\AddressQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;

View File

@@ -51,11 +51,13 @@ class Argument
$this->setValue($value); $this->setValue($value);
} }
public function getValue() { public function getValue()
{
return $this->type->getFormattedValue($this->value); return $this->type->getFormattedValue($this->value);
} }
public function setValue($value) { public function setValue($value)
{
$this->value = $value === null ? null : (string) $value; $this->value = $value === null ? null : (string) $value;
} }

View File

@@ -37,11 +37,13 @@ class ArgumentCollection implements \Iterator
$this->addArguments(func_get_args(), true); $this->addArguments(func_get_args(), true);
} }
public function hasKey($key) { public function hasKey($key)
{
return isset($this->arguments[$key]); return isset($this->arguments[$key]);
} }
public function get($key) { public function get($key)
{
return $this->hasKey($key) ? $this->arguments[$key] : null; return $this->hasKey($key) ? $this->arguments[$key] : null;
} }

View File

@@ -30,11 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* *
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop
@@ -87,8 +82,7 @@ class Auth extends BaseLoop
// Create an empty row: loop is no longer empty :) // Create an empty row: loop is no longer empty :)
$loopResult->addRow(new LoopResultRow()); $loopResult->addRow(new LoopResultRow());
} }
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Not granted, loop is empty // Not granted, loop is empty
} }

View File

@@ -9,13 +9,13 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
class Cart extends BaseLoop { class Cart extends BaseLoop
{
use \Thelia\Cart\CartTrait; use \Thelia\Cart\CartTrait;
/** /**
* *
@@ -78,7 +78,6 @@ class Cart extends BaseLoop {
return $result; return $result;
} }
$cartItems = $cart->getCartItems(); $cartItems = $cart->getCartItems();
foreach ($cartItems as $cartItem) { foreach ($cartItems as $cartItem) {
@@ -99,5 +98,4 @@ class Cart extends BaseLoop {
return $result; return $result;
} }
} }

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
@@ -107,7 +106,6 @@ class Category extends BaseLoop
$search->filterByParent($parent); $search->filterByParent($parent);
} }
$current = $this->getCurrent(); $current = $this->getCurrent();
if ($current === true) { if ($current === true) {
@@ -116,7 +114,6 @@ class Category extends BaseLoop
$search->filterById($this->request->get("category_id"), Criteria::NOT_IN); $search->filterById($this->request->get("category_id"), Criteria::NOT_IN);
} }
$exclude = $this->getExclude(); $exclude = $this->getExclude();
if (!is_null($exclude)) { if (!is_null($exclude)) {
@@ -171,7 +168,6 @@ class Category extends BaseLoop
if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
$loopResultRow = new LoopResultRow(); $loopResultRow = new LoopResultRow();
$loopResultRow $loopResultRow

View File

@@ -23,18 +23,14 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;
@@ -122,8 +118,7 @@ class CategoryPath extends BaseLoop
if ($visible == true) $search->filterByVisible($visible); if ($visible == true) $search->filterByVisible($visible);
} }
} }
} } while ($category != null && $parent > 0);
while ($category != null && $parent > 0);
// Reverse list and build the final result // Reverse list and build the final result
$results = array_reverse($results); $results = array_reverse($results);

View File

@@ -30,11 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;
@@ -65,8 +62,8 @@ class CategoryTree extends BaseLoop
} }
// changement de rubrique // changement de rubrique
protected function buildCategoryTree($parent, $visible, $level, $max_level, array $exclude, LoopResult &$loopResult) { protected function buildCategoryTree($parent, $visible, $level, $max_level, array $exclude, LoopResult &$loopResult)
{
if ($level > $max_level) return; if ($level > $max_level) return;
$search = CategoryQuery::create(); $search = CategoryQuery::create();

View File

@@ -24,16 +24,13 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\FeatureContentQuery;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Model\Map\ContentTableMap; use Thelia\Model\Map\ContentTableMap;
use Thelia\Model\ContentFolderQuery; use Thelia\Model\ContentFolderQuery;

View File

@@ -30,12 +30,9 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CountryQuery; use Thelia\Model\CountryQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *

View File

@@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CustomerQuery; use Thelia\Model\CustomerQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;

View File

@@ -24,14 +24,12 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\ProductCategoryQuery;

View File

@@ -24,14 +24,12 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\FeatureAvQuery; use Thelia\Model\Base\FeatureAvQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;

View File

@@ -24,14 +24,12 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\Base\FeatureProductQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;

View File

@@ -30,9 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
@@ -89,7 +88,6 @@ class Folder extends BaseLoop
$search->filterByParent($parent); $search->filterByParent($parent);
} }
$current = $this->getCurrent(); $current = $this->getCurrent();
if ($current === true) { if ($current === true) {
@@ -98,7 +96,6 @@ class Folder extends BaseLoop
$search->filterById($this->request->get("folder_id"), Criteria::NOT_IN); $search->filterById($this->request->get("folder_id"), Criteria::NOT_IN);
} }
$exclude = $this->getExclude(); $exclude = $this->getExclude();
if (!is_null($exclude)) { if (!is_null($exclude)) {

View File

@@ -30,8 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Model\LangQuery; use Thelia\Model\LangQuery;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;

View File

@@ -25,14 +25,10 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop

View File

@@ -25,14 +25,10 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop

View File

@@ -24,20 +24,14 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\FeatureProductQuery;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\FeatureAvQuery;
use Thelia\Model\FeatureQuery;
use Thelia\Model\Map\FeatureProductTableMap;
use Thelia\Model\Map\ProductTableMap; use Thelia\Model\Map\ProductTableMap;
use Thelia\Model\ProductCategoryQuery; use Thelia\Model\ProductCategoryQuery;
use Thelia\Model\ProductQuery; use Thelia\Model\ProductQuery;

View File

@@ -30,12 +30,9 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CustomerTitleQuery; use Thelia\Model\CustomerTitleQuery;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *

View File

@@ -37,8 +37,8 @@ class ParserContext implements \IteratorAggregate
{ {
private $store = array(); private $store = array();
public function __construct(Request $request) { public function __construct(Request $request)
{
// Setup basic variables // Setup basic variables
$this $this
->set('BASE_URL' , ConfigQuery::read('base_url', '/')) ->set('BASE_URL' , ConfigQuery::read('base_url', '/'))

View File

@@ -65,7 +65,6 @@ abstract class AbstractSmartyPlugin
$value = $this->getParam($params, $name, $default); $value = $this->getParam($params, $name, $default);
if (is_string($value)) $value = strtolower(trim($value)); if (is_string($value)) $value = strtolower(trim($value));
return $value; return $value;
} }
@@ -85,8 +84,7 @@ abstract class AbstractSmartyPlugin
return $params[$test]; return $params[$test];
} }
} }
} } elseif (isset($params[$name])) {
else if (isset($params[$name])) {
return $params[$name]; return $params[$name];
} }
@@ -96,5 +94,5 @@ abstract class AbstractSmartyPlugin
/** /**
* @return an array of SmartyPluginDescriptor * @return an array of SmartyPluginDescriptor
*/ */
public abstract function getPluginDescriptors(); abstract public function getPluginDescriptors();
} }

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Template\Smarty\Assets; namespace Thelia\Core\Template\Smarty\Assets;
use Thelia\Core\Template\Assets\AsseticHelper; use Thelia\Core\Template\Assets\AsseticHelper;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL; use Thelia\Tools\URL;
class SmartyAssetsManager class SmartyAssetsManager
@@ -50,7 +49,8 @@ class SmartyAssetsManager
$this->assetic_manager = new AsseticHelper(); $this->assetic_manager = new AsseticHelper();
} }
public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template) { public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template)
{
$file = $params['file']; $file = $params['file'];
$filters = isset($params['filters']) ? $params['filters'] : ''; $filters = isset($params['filters']) ? $params['filters'] : '';
$debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false; $debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false;

View File

@@ -67,7 +67,6 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return $this->userDataAccess("Customer User", SecurityContext::CONTEXT_FRONT_OFFICE, $params); return $this->userDataAccess("Customer User", SecurityContext::CONTEXT_FRONT_OFFICE, $params);
} }
/** /**
* Provides access to user attributes using the accessors. * Provides access to user attributes using the accessors.
* *

View File

@@ -28,7 +28,6 @@ use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Log\Tlog;
use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\ParserContext;
/** /**
@@ -111,8 +110,7 @@ class Form extends AbstractSmartyPlugin
$template->assign("form_error", $instance->hasError() ? true : false); $template->assign("form_error", $instance->hasError() ? true : false);
$template->assign("form_error_message", $instance->getErrorMessage()); $template->assign("form_error_message", $instance->getErrorMessage());
} } else {
else {
return $content; return $content;
} }
} }
@@ -145,8 +143,7 @@ class Form extends AbstractSmartyPlugin
$template->assign("attr", implode(" ", $attr)); $template->assign("attr", implode(" ", $attr));
$formFieldView->setRendered(); $formFieldView->setRendered();
} } else {
else {
return $content; return $content;
} }
} }
@@ -193,8 +190,7 @@ class Form extends AbstractSmartyPlugin
if ($repeat) { if ($repeat) {
$this->assignFieldErrorVars($template, $errors); $this->assignFieldErrorVars($template, $errors);
} } else {
else {
return $content; return $content;
} }
} }
@@ -212,7 +208,8 @@ class Form extends AbstractSmartyPlugin
return array_search("hidden", $formView->vars["block_prefixes"]); return array_search("hidden", $formView->vars["block_prefixes"]);
} }
protected function getFormFieldView($params) { protected function getFormFieldView($params)
{
$instance = $this->getInstanceFromParams($params); $instance = $this->getInstanceFromParams($params);
$fieldName = $this->getParam($params, 'field'); $fieldName = $this->getParam($params, 'field');
@@ -227,8 +224,8 @@ class Form extends AbstractSmartyPlugin
return $instance->getView()[$fieldName]; return $instance->getView()[$fieldName];
} }
protected function getInstanceFromParams($params) { protected function getInstanceFromParams($params)
{
$instance = $this->getParam($params, 'form'); $instance = $this->getParam($params, 'form');
if (null == $instance) { if (null == $instance) {

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager;
use Thelia\Core\Security\SecurityContext; use Thelia\Core\Security\SecurityContext;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;

View File

@@ -31,7 +31,8 @@ class Translation extends AbstractSmartyPlugin
{ {
protected $translator; protected $translator;
public function __construct(TranslatorInterface $translator) { public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator; $this->translator = $translator;
} }

View File

@@ -54,7 +54,6 @@ class UrlGenerator extends AbstractSmartyPlugin
$url = URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target'))); $url = URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
if ($target != null) $url .= '#'.$target; if ($target != null) $url .= '#'.$target;
return $url; return $url;
} }
@@ -93,7 +92,6 @@ class UrlGenerator extends AbstractSmartyPlugin
$args = $this->getArgsFromParam($params, array('view', 'action', 'target')); $args = $this->getArgsFromParam($params, array('view', 'action', 'target'));
if (! empty($action)) $args['action'] = $action; if (! empty($action)) $args['action'] = $action;
return $forAdmin ? URL::adminViewUrl($view, $args) : URL::viewUrl($view, $args); return $forAdmin ? URL::adminViewUrl($view, $args) : URL::viewUrl($view, $args);
} }
@@ -103,8 +101,8 @@ class UrlGenerator extends AbstractSmartyPlugin
* @param array $params Smarty function params * @param array $params Smarty function params
* @return array the parameters array (either emply, of valued) * @return array the parameters array (either emply, of valued)
*/ */
private function getArgsFromParam($params, $exclude = array()) { private function getArgsFromParam($params, $exclude = array())
{
$pairs = array(); $pairs = array();
foreach ($params as $name => $value) { foreach ($params as $name => $value) {

View File

@@ -138,8 +138,7 @@ class SmartyParser extends Smarty implements ParserInterface
{ {
try { try {
$templateFile = $this->getTemplateFilePath(); $templateFile = $this->getTemplateFilePath();
} } catch (\RuntimeException $e) {
catch(\RuntimeException $e) {
return new Response($e->getMessage(), "404"); return new Response($e->getMessage(), "404");
} }

View File

@@ -39,7 +39,6 @@ use Symfony\Component\Yaml\Yaml;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Thelia\Core\Bundle; use Thelia\Core\Bundle;
use Thelia\Core\DependencyInjection\Loader\CollectionXmlFileLoader;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
use Thelia\Config\DatabaseConfiguration; use Thelia\Config\DatabaseConfiguration;
use Thelia\Config\DefinePropel; use Thelia\Config\DefinePropel;

View File

@@ -3,8 +3,8 @@ namespace Thelia\Core\Translation;
use Symfony\Component\Translation\Translator as BaseTranslator; use Symfony\Component\Translation\Translator as BaseTranslator;
class Translator extends BaseTranslator { class Translator extends BaseTranslator
{
/** /**
* {@inheritdoc} * {@inheritdoc}
* *

View File

@@ -21,10 +21,8 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Exception; namespace Thelia\Exception;
class InvalidCartException extends \RuntimeException
class InvalidCartException extends \RuntimeException { {
} }

View File

@@ -22,13 +22,11 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form; namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Choice;
class AdminLogin extends BaseForm {
class AdminLogin extends BaseForm
{
protected function buildForm() protected function buildForm()
{ {
$this->formBuilder $this->formBuilder

View File

@@ -24,7 +24,6 @@ namespace Thelia\Form;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension; use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Forms; use Symfony\Component\Form\Forms;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
@@ -33,7 +32,8 @@ use Symfony\Component\Validator\Validation;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL; use Thelia\Tools\URL;
abstract class BaseForm { abstract class BaseForm
{
/** /**
* @var \Symfony\Component\Form\FormFactoryInterface * @var \Symfony\Component\Form\FormFactoryInterface
*/ */
@@ -98,7 +98,8 @@ abstract class BaseForm {
$this->form = $this->formBuilder->getForm(); $this->form = $this->formBuilder->getForm();
} }
public function getRequest() { public function getRequest()
{
return $this->request; return $this->request;
} }
@@ -116,8 +117,8 @@ abstract class BaseForm {
* *
* @return string an absolute URL * @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)) {
@@ -130,13 +131,14 @@ abstract class BaseForm {
return URL::absoluteUrl($successUrl); return URL::absoluteUrl($successUrl);
} }
public function createView() { public function createView()
{
$this->view = $this->form->createView(); $this->view = $this->form->createView();
} }
public function getView() { public function getView()
{
if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first."); if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first.");
return $this->view; return $this->view;
} }
@@ -217,4 +219,3 @@ abstract class BaseForm {
*/ */
abstract public function getName(); abstract public function getName();
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form; namespace Thelia\Form;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface; use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Action\Exception\StockNotFoundException; use Thelia\Action\Exception\StockNotFoundException;

View File

@@ -22,11 +22,10 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form; namespace Thelia\Form;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
class CategoryCreationForm extends BaseForm { class CategoryCreationForm extends BaseForm
{
protected function buildForm() protected function buildForm()
{ {
$this->formBuilder $this->formBuilder

View File

@@ -22,11 +22,10 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form; namespace Thelia\Form;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
class CategoryDeletionForm extends BaseForm { class CategoryDeletionForm extends BaseForm
{
protected function buildForm() protected function buildForm()
{ {
$this->formBuilder $this->formBuilder

View File

@@ -22,15 +22,11 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Form; 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\NotBlank;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Email;
class CustomerLogin extends BaseForm { class CustomerLogin extends BaseForm
{
protected function buildForm() protected function buildForm()
{ {
$this->formBuilder $this->formBuilder

View File

@@ -24,11 +24,9 @@
namespace Thelia\Form; namespace Thelia\Form;
use Symfony\Component\Validator\Constraints; 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. * in this function you add all the fields you need for your Form.

View File

@@ -109,7 +109,8 @@ class Tlog Implements LoggerInterface
* *
* @return \Thelia\Log\Tlog * @return \Thelia\Log\Tlog
*/ */
public static function getInstance() { public static function getInstance()
{
if (self::$instance == false) { if (self::$instance == false) {
self::$instance = new Tlog(); self::$instance = new Tlog();
@@ -479,8 +480,10 @@ class Tlog Implements LoggerInterface
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function log($level, $message, array $context = array()) { public function log($level, $message, array $context = array())
{
if($this->level > $level || array_key_exists($level, $this->levels) === false) if($this->level > $level || array_key_exists($level, $this->levels) === false)
return; return;
$this->out($this->levels[$level], $message, $context); $this->out($this->levels[$level], $message, $context);
@@ -586,7 +589,6 @@ class Tlog Implements LoggerInterface
/* -- Methodes privees ---------------------------------------- */ /* -- Methodes privees ---------------------------------------- */
private function findOrigin() private function findOrigin()
{ {
$origine = array(); $origine = array();

View File

@@ -24,7 +24,6 @@
namespace Thelia\Log; namespace Thelia\Log;
use Thelia\Model\Config; use Thelia\Model\Config;
use Thelia\Model\ConfigDesc;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
class TlogDestinationConfig class TlogDestinationConfig
@@ -51,11 +50,9 @@ class TlogDestinationConfig
$this->load(); $this->load();
} }
public function load() public function load()
{ {
if (null === $config = ConfigQuery::create()->findOneByName($this->name)) if (null === $config = ConfigQuery::create()->findOneByName($this->name)) {
{
$config = new Config(); $config = new Config();
$config->setName($this->name); $config->setName($this->name);
$config->setValue($this->default); $config->setValue($this->default);

View File

@@ -23,13 +23,10 @@
namespace Thelia\Tests\Cart\CartTraitTest; namespace Thelia\Tests\Cart\CartTraitTest;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Thelia\Core\Event\DefaultActionEvent;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Model\Cart; use Thelia\Model\Cart;
use Thelia\Model\Customer; use Thelia\Model\Customer;
use Thelia\Model\ProductQuery;
use Thelia\Model\ProductSaleElementsQuery;
/** /**
* phpunit 3.8 needed for mcking a Trait and there is conflict with php version. * phpunit 3.8 needed for mcking a Trait and there is conflict with php version.
@@ -180,7 +177,6 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
$request = $this->request; $request = $this->request;
//create a fake customer just for test. If not persists test fails ! //create a fake customer just for test. If not persists test fails !
$customer = new Customer(); $customer = new Customer();
$customer->setFirstname("john"); $customer->setFirstname("john");
@@ -219,7 +215,6 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
$request = $this->request; $request = $this->request;
//create a fake customer just for test. If not persists test fails ! //create a fake customer just for test. If not persists test fails !
$customer = new Customer(); $customer = new Customer();
$customer->setFirstname("john"); $customer->setFirstname("john");

View File

@@ -22,8 +22,8 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Tests\Command; namespace Thelia\Tests\Command;
abstract class BaseCommandTest extends \PHPUnit_Framework_TestCase
abstract class BaseCommandTest extends \PHPUnit_Framework_TestCase { {
public function getKernel() public function getKernel()
{ {
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface"); $kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");

View File

@@ -62,7 +62,6 @@ class CacheClearTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($fs->exists($this->cache_dir)); $this->assertFalse($fs->exists($this->cache_dir));
} }
/** /**

View File

@@ -22,14 +22,13 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Tests\Command; namespace Thelia\Tests\Command;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Thelia\Core\Application; use Thelia\Core\Application;
use Thelia\Command\ModuleGenerateCommand; use Thelia\Command\ModuleGenerateCommand;
class ModuleGenerateCommandTest extends BaseCommandTest { class ModuleGenerateCommandTest extends BaseCommandTest
{
protected $command; protected $command;
protected $commandTester; protected $commandTester;

View File

@@ -4,7 +4,6 @@ namespace Thelia\Tests\Core\HttpFoundation;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
class RequestTest extends \PHPUnit_Framework_TestCase class RequestTest extends \PHPUnit_Framework_TestCase
{ {
@@ -37,7 +36,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$this->assertEquals("http://localhost/?test=fu&foo=bar", $result); $this->assertEquals("http://localhost/?test=fu&foo=bar", $result);
} }
} }

View File

@@ -46,10 +46,12 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
abstract public function getTestedInstance(); abstract public function getTestedInstance();
abstract public function getMandatoryArguments(); abstract public function getMandatoryArguments();
protected function getMethod($name) { protected function getMethod($name)
{
$class = new \ReflectionClass($this->getTestedClassName()); $class = new \ReflectionClass($this->getTestedClassName());
$method = $class->getMethod($name); $method = $class->getMethod($name);
$method->setAccessible(true); $method->setAccessible(true);
return $method; return $method;
} }

View File

@@ -99,7 +99,6 @@ class ArgumentTest extends \PHPUnit_Framework_TestCase
) )
); );
$arguments = \PHPUnit_Framework_Assert::readAttribute($collection, 'arguments'); $arguments = \PHPUnit_Framework_Assert::readAttribute($collection, 'arguments');
foreach ($collection as $key => $argument) { foreach ($collection as $key => $argument) {

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Tests\Form; namespace Thelia\Tests\Form;
class CartAddTest extends \PHPUnit_Framework_TestCase class CartAddTest extends \PHPUnit_Framework_TestCase
{ {

View File

@@ -34,7 +34,6 @@ class TlogTest extends \PHPUnit_Framework_TestCase
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
self::$logger = Tlog::getInstance(); self::$logger = Tlog::getInstance();
self::$logger->setDestinations("Thelia\Log\Destination\TlogDestinationText"); self::$logger->setDestinations("Thelia\Log\Destination\TlogDestinationText");

View File

@@ -63,7 +63,6 @@ class TypeTest extends \PHPUnit_Framework_TestCase
new Type\FloatType() new Type\FloatType()
); );
$types = \PHPUnit_Framework_Assert::readAttribute($collection, 'types'); $types = \PHPUnit_Framework_Assert::readAttribute($collection, 'types');
foreach ($collection as $key => $type) { foreach ($collection as $key => $type) {

View File

@@ -11,7 +11,3 @@ require_once __DIR__ . '/../../../bootstrap.php';
use Thelia\Core\Thelia; use Thelia\Core\Thelia;
$thelia = new Thelia("test", true); $thelia = new Thelia("test", true);

View File

@@ -27,7 +27,8 @@ use Thelia\Model\ConfigQuery;
class URL class URL
{ {
public static function getIndexPage() { public static function getIndexPage()
{
return ConfigQuery::read('base_url', '/') . "index_dev.php"; // FIXME ! return ConfigQuery::read('base_url', '/') . "index_dev.php"; // FIXME !
} }
@@ -50,8 +51,7 @@ class URL
$root = $path_only ? ConfigQuery::read('base_url', '/') : self::getIndexPage(); $root = $path_only ? ConfigQuery::read('base_url', '/') : self::getIndexPage();
$base = $root . '/' . ltrim($path, '/'); $base = $root . '/' . ltrim($path, '/');
} } else
else
$base = $path; $base = $path;
$queryString = ''; $queryString = '';
@@ -63,7 +63,6 @@ class URL
$sepChar = strstr($base, '?') === false ? '?' : '&'; $sepChar = strstr($base, '?') === false ? '?' : '&';
if ('' !== $queryString = rtrim($queryString, "&")) $queryString = $sepChar . $queryString; if ('' !== $queryString = rtrim($queryString, "&")) $queryString = $sepChar . $queryString;
return $base . $queryString; return $base . $queryString;
} }
@@ -75,8 +74,8 @@ class URL
* *
* @return string The generated URL * @return string The generated URL
*/ */
public static function adminViewUrl($viewName, array $parameters = array()) { public static function adminViewUrl($viewName, array $parameters = array())
{
$path = sprintf("%s/admin/%s", self::getIndexPage(), $viewName); // FIXME ! view= should not be required, check routing parameters $path = sprintf("%s/admin/%s", self::getIndexPage(), $viewName); // FIXME ! view= should not be required, check routing parameters
return self::absoluteUrl($path, $parameters); return self::absoluteUrl($path, $parameters);
@@ -90,8 +89,8 @@ class URL
* *
* @return string The generated URL * @return string The generated URL
*/ */
public static function viewUrl($viewName, array $parameters = array()) { public static function viewUrl($viewName, array $parameters = array())
{
$path = sprintf("%s?view=%s", self::getIndexPage(), $viewName); $path = sprintf("%s?view=%s", self::getIndexPage(), $viewName);
return self::absoluteUrl($path, $parameters); return self::absoluteUrl($path, $parameters);

View File

@@ -39,6 +39,7 @@ class AlphaNumStringListType implements TypeInterface
{ {
foreach (explode(',', $values) as $value) { foreach (explode(',', $values) as $value) {
if(!preg_match('#^[a-zA-Z0-9\-_]+$#', $value)) if(!preg_match('#^[a-zA-Z0-9\-_]+$#', $value))
return false; return false;
} }

View File

@@ -47,7 +47,6 @@ class BooleanOrBothType implements TypeInterface
public function getFormattedValue($value) public function getFormattedValue($value)
{ {
if ($value === self::ANY) return $value; if ($value === self::ANY) return $value;
return $value === null ? null : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); return $value === null ? null : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
} }
} }

View File

@@ -53,6 +53,7 @@ class EnumListType implements TypeInterface
{ {
foreach (explode(',', $values) as $value) { foreach (explode(',', $values) as $value) {
if(!$this->isSingleValueValid($value)) if(!$this->isSingleValueValid($value))
return false; return false;
} }

View File

@@ -39,6 +39,7 @@ class IntListType implements TypeInterface
{ {
foreach (explode(',', $values) as $value) { foreach (explode(',', $values) as $value) {
if(filter_var($value, FILTER_VALIDATE_INT) === false) if(filter_var($value, FILTER_VALIDATE_INT) === false)
return false; return false;
} }

Some files were not shown because too many files have changed in this diff Show More