diff --git a/core/lib/Thelia/Action/Address.php b/core/lib/Thelia/Action/Address.php index 32ec24c05..278f71a5b 100644 --- a/core/lib/Thelia/Action/Address.php +++ b/core/lib/Thelia/Action/Address.php @@ -27,7 +27,6 @@ use Thelia\Core\Event\AddressCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Address as AddressModel; - /** * Class Address * @package Thelia\Action @@ -50,7 +49,6 @@ class Address extends BaseAction implements EventSubscriberInterface $this->createOrUpdate($addressModel, $event); } - protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event) { $addressModel->setDispatcher($this->getDispatcher()); @@ -105,4 +103,4 @@ class Address extends BaseAction implements EventSubscriberInterface TheliaEvents::ADDRESS_UPDATE => array("update", 128) ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index 2984ddbd6..56565ddc6 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -22,10 +22,6 @@ /*************************************************************************************/ namespace Thelia\Action; -use Thelia\Form\BaseForm; -use Thelia\Action\Exception\FormValidationException; -use Thelia\Core\Event\ActionEvent; -use Symfony\Component\Form\Form; use Symfony\Component\DependencyInjection\ContainerInterface; class BaseAction @@ -49,4 +45,4 @@ class BaseAction { return $this->container->get('event_dispatcher'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 9203dc00d..5549f3eb3 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -23,12 +23,9 @@ namespace Thelia\Action; -use Propel\Runtime\Exception\PropelException; -use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\CartEvent; -use Thelia\Form\CartAdd; use Thelia\Model\ProductPrice; use Thelia\Model\ProductPriceQuery; use Thelia\Model\CartItem; diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 7b7608dc9..297cd64da 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -31,7 +31,6 @@ use Thelia\Model\CategoryQuery; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Propel; use Thelia\Model\Map\CategoryTableMap; -use Propel\Runtime\Exception\PropelException; use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Core\Event\CategoryDeleteEvent; diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index e0a62f69d..83df28524 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -23,7 +23,6 @@ namespace Thelia\Action; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\ConfigQuery; diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index fee349585..8676eb16c 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -27,9 +27,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Coupon as CouponModel; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Propel; -use Thelia\Model\Map\CategoryTableMap; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 7f9c3281f..619374902 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -23,7 +23,6 @@ namespace Thelia\Action; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\CurrencyQuery; @@ -60,7 +59,6 @@ class Currency extends BaseAction implements EventSubscriberInterface ->save() ; - $event->setCurrency($currency); } @@ -136,16 +134,15 @@ class Currency extends BaseAction implements EventSubscriberInterface } } - public function updateRates() { - + public function updateRates() + { $rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'); $rate_data = @file_get_contents($rates_url); if ($rate_data && $sxe = new \SimpleXMLElement($rate_data)) { - foreach ($sxe->Cube[0]->Cube[0]->Cube as $last) - { + foreach ($sxe->Cube[0]->Cube[0]->Cube as $last) { $code = strtoupper($last["currency"]); $rate = floatval($last['rate']); @@ -157,8 +154,7 @@ class Currency extends BaseAction implements EventSubscriberInterface ; } } - } - else { + } else { throw new \RuntimeException(sprintf("Failed to get currency rates data from URL %s", $rates_url)); } } diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 962e2e2cf..1b3ac6909 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -27,17 +27,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Form\CustomerCreation; -use Thelia\Form\CustomerModification; use Thelia\Model\Customer as CustomerModel; -use Thelia\Log\Tlog; -use Thelia\Model\CustomerQuery; -use Thelia\Form\CustomerLogin; -use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; -use Symfony\Component\Validator\Exception\ValidatorException; -use Thelia\Core\Security\Exception\AuthenticationException; -use Thelia\Core\Security\Exception\UsernameNotFoundException; -use Propel\Runtime\Exception\PropelException; use Thelia\Core\Event\CustomerLoginEvent; /** @@ -96,7 +86,6 @@ class Customer extends BaseAction implements EventSubscriberInterface $event->setCustomer($customer); } - public function login(CustomerLoginEvent $event) { $this->getSecurityContext()->setCustomerUser($event->getCustomer()); diff --git a/core/lib/Thelia/Action/Image.php b/core/lib/Thelia/Action/Image.php index 103633165..66baffdbb 100755 --- a/core/lib/Thelia/Action/Image.php +++ b/core/lib/Thelia/Action/Image.php @@ -25,7 +25,6 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ImageEvent; use Thelia\Model\ConfigQuery; use Thelia\Tools\URL; @@ -86,8 +85,8 @@ class Image extends BaseAction implements EventSubscriberInterface * * @param ImageEvent $event */ - public function clearCache(ImageEvent $event) { - + public function clearCache(ImageEvent $event) + { $path = $this->getCachePath($event->getCacheSubdirectory(), false); $this->clearDirectory($path); @@ -98,8 +97,8 @@ class Image extends BaseAction implements EventSubscriberInterface * * @param string $path the directory path */ - protected function clearDirectory($path) { - + protected function clearDirectory($path) + { $iterator = new \DirectoryIterator($path); foreach ($iterator as $fileinfo) { @@ -108,8 +107,7 @@ class Image extends BaseAction implements EventSubscriberInterface if ($fileinfo->isFile() || $fileinfo->isLink()) { @unlink($fileinfo->getPathname()); - } - else if ($fileinfo->isDir()) { + } elseif ($fileinfo->isDir()) { $this->clearDirectory($fileinfo->getPathname()); } } @@ -124,7 +122,7 @@ class Image extends BaseAction implements EventSubscriberInterface * * This method updates the cache_file_path and file_url attributes of the event * - * @param ImageEvent $event + * @param ImageEvent $event * @throws \InvalidArgumentException, ImageException */ public function processImage(ImageEvent $event) @@ -160,8 +158,7 @@ class Image extends BaseAction implements EventSubscriberInterface if (false == symlink($source_file, $originalImagePathInCache)) { throw new ImageException(sprintf("Failed to create symbolic link for %s in %s image cache directory", basename($source_file), $subdir)); } - } - else {// mode = 'copy' + } else {// mode = 'copy' if (false == @copy($source_file, $originalImagePathInCache)) { throw new ImageException(sprintf("Failed to copy %s in %s image cache directory", basename($source_file), $subdir)); } @@ -182,8 +179,7 @@ class Image extends BaseAction implements EventSubscriberInterface if ($background_color != null) { $bg_color = new Color($background_color); - } - else + } else $bg_color = null; // Apply resize @@ -252,8 +248,7 @@ class Image extends BaseAction implements EventSubscriberInterface $cacheFilePath, array('quality' => $quality) ); - } - else { + } else { throw new ImageException(sprintf("Source file %s cannot be opened.", basename($source_file))); } } @@ -277,13 +272,13 @@ class Image extends BaseAction implements EventSubscriberInterface * Process image resizing, with borders or cropping. If $dest_width and $dest_height * are both null, no resize is performed. * - * @param ImagineInterface $imagine the Imagine instance - * @param ImageInterface $image the image to process - * @param int $dest_width the required width - * @param int $dest_height the required height - * @param int $resize_mode the resize mode (crop / bands / keep image ratio)p - * @param string $bg_color the bg_color used for bands - * @return ImageInterface the resized image. + * @param ImagineInterface $imagine the Imagine instance + * @param ImageInterface $image the image to process + * @param int $dest_width the required width + * @param int $dest_height the required height + * @param int $resize_mode the resize mode (crop / bands / keep image ratio)p + * @param string $bg_color the bg_color used for bands + * @return ImageInterface the resized image. */ protected function applyResize(ImagineInterface $imagine, ImageInterface $image, $dest_width, $dest_height, $resize_mode, $bg_color) { @@ -313,8 +308,7 @@ class Image extends BaseAction implements EventSubscriberInterface $dest_width = ($resize_mode == self::EXACT_RATIO_WITH_BORDERS ? $dest_width : $next_width); $dest_height = ($resize_mode == self::EXACT_RATIO_WITH_BORDERS ? $dest_height : $next_height); - } - else if ($width_diff > $height_diff) { + } elseif ($width_diff > $height_diff) { // Image height > image width $next_height = $dest_height; @@ -324,12 +318,10 @@ class Image extends BaseAction implements EventSubscriberInterface $next_width = $dest_width; $next_height = intval($height_orig * $dest_width / $width_orig); $delta_y = ($next_height - $dest_height) / 2; - } - else if ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) { + } elseif ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) { $dest_width = $next_width; } - } - else { + } else { // Image width > image height $next_width = $dest_width; $next_height = intval($height_orig * $dest_width / $width_orig); @@ -338,8 +330,7 @@ class Image extends BaseAction implements EventSubscriberInterface $next_height = $dest_height; $next_width = intval(($width_orig * $next_height) / $height_orig); $delta_x = ($next_width - $dest_width) / 2; - } - else if ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) { + } elseif ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) { $dest_height = $next_height; } } @@ -357,9 +348,7 @@ class Image extends BaseAction implements EventSubscriberInterface return $imagine->create($canvas, $bg_color) ->paste($image, new Point($border_width, $border_height)); - } - - else if ($resize_mode == self::EXACT_RATIO_WITH_CROP) { + } elseif ($resize_mode == self::EXACT_RATIO_WITH_CROP) { $image->crop( new Point($delta_x, $delta_y), new Box($dest_width, $dest_height) @@ -370,12 +359,11 @@ class Image extends BaseAction implements EventSubscriberInterface return $image; } - /** * Return the absolute URL to the cached image * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the safe filename, as returned by getCacheFilePath() + * @param string $subdir the subdirectory related to cache base + * @param string $filename the safe filename, as returned by getCacheFilePath() * @return string the absolute URL to the cached image */ protected function getCacheFileURL($subdir, $safe_filename) @@ -388,10 +376,10 @@ class Image extends BaseAction implements EventSubscriberInterface /** * Return the full path of the cached file * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the filename - * @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned. - * @return string the cache directory path relative to Web Root + * @param string $subdir the subdirectory related to cache base + * @param string $filename the filename + * @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned. + * @return string the cache directory path relative to Web Root */ protected function getCacheFilePath($subdir, $filename, ImageEvent $event, $forceOriginalImage = false) { @@ -409,7 +397,7 @@ class Image extends BaseAction implements EventSubscriberInterface /** * Return the cache directory path relative to Web Root * - * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. + * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. * @return string the cache directory path relative to Web Root */ protected function getCachePathFromWebRoot($subdir = null) @@ -420,21 +408,19 @@ class Image extends BaseAction implements EventSubscriberInterface $safe_subdir = basename($subdir); $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir); - } - else + } else $path = $cache_dir_from_web_root; // Check if path is valid, e.g. in the cache dir - return $path; } /** * Return the absolute cache directory path * - * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. + * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. * @throws \RuntimeException if cache directory cannot be created - * @return string the absolute cache directory path + * @return string the absolute cache directory path */ protected function getCachePath($subdir = null, $create_if_not_exists = true) { @@ -494,4 +480,4 @@ class Image extends BaseAction implements EventSubscriberInterface TheliaEvents::IMAGE_CLEAR_CACHE => array("clearCache", 128), ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Message.php b/core/lib/Thelia/Action/Message.php index 5299efc99..faac35bf2 100644 --- a/core/lib/Thelia/Action/Message.php +++ b/core/lib/Thelia/Action/Message.php @@ -23,7 +23,6 @@ namespace Thelia\Action; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\MessageQuery; diff --git a/core/lib/Thelia/Action/PageNotFound.php b/core/lib/Thelia/Action/PageNotFound.php index a4d715fbb..c6593ff7c 100755 --- a/core/lib/Thelia/Action/PageNotFound.php +++ b/core/lib/Thelia/Action/PageNotFound.php @@ -23,7 +23,6 @@ namespace Thelia\Action; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; @@ -41,7 +40,7 @@ class PageNotFound extends BaseAction implements EventSubscriberInterface { public function display404(GetResponseForExceptionEvent $event) { - if($event->getException() instanceof NotFoundHttpException) { + if ($event->getException() instanceof NotFoundHttpException) { $parser = $this->container->get("thelia.parser"); diff --git a/core/lib/Thelia/Action/PositionManagementTrait.php b/core/lib/Thelia/Action/PositionManagementTrait.php index 70f91d995..5da085594 100644 --- a/core/lib/Thelia/Action/PositionManagementTrait.php +++ b/core/lib/Thelia/Action/PositionManagementTrait.php @@ -25,8 +25,8 @@ namespace Thelia\Action; use Thelia\Core\Event\BaseChangePositionEvent; -trait PositionManagementTrait { - +trait PositionManagementTrait +{ const POSITION_UP /** * Changes object position, selecting absolute ou relative change. @@ -154,4 +154,4 @@ trait PositionManagementTrait { } } } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index 527867d5d..8589f25b5 100755 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -139,4 +139,4 @@ trait CartTrait return $id; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index 37e853f05..72b7571d2 100755 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -61,7 +61,7 @@ class CacheClear extends ContainerAwareCommand $cacheDir = $this->getContainer()->getParameter("kernel.cache_dir"); $this->clearCache($cacheDir, $output); - if(!$input->getOption("without-assets")) { + if (!$input->getOption("without-assets")) { $this->clearCache(THELIA_WEB_DIR . "/assets", $output); } diff --git a/core/lib/Thelia/Command/ClearImageCache.php b/core/lib/Thelia/Command/ClearImageCache.php index babbdd619..d2010ead1 100755 --- a/core/lib/Thelia/Command/ClearImageCache.php +++ b/core/lib/Thelia/Command/ClearImageCache.php @@ -32,7 +32,6 @@ use Thelia\Core\HttpFoundation\Request; use Symfony\Component\Console\Input\InputArgument; use Thelia\Core\Event\TheliaEvents; - class ClearImageCache extends ContainerAwareCommand { protected function configure() @@ -60,9 +59,8 @@ class ClearImageCache extends ContainerAwareCommand $dispatcher->dispatch(TheliaEvents::IMAGE_CLEAR_CACHE, $event); $output->writeln(sprintf('%s image cache successfully cleared.', is_null($subdir) ? 'Entire' : ucfirst($subdir))); - } - catch(\Exception $ex) { + } catch (\Exception $ex) { $output->writeln(sprintf("Failed to clear image cache: %s", $ex->getMessage())); } } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Command/CreateAdminUser.php b/core/lib/Thelia/Command/CreateAdminUser.php index 868ca1496..4fd8b886e 100644 --- a/core/lib/Thelia/Command/CreateAdminUser.php +++ b/core/lib/Thelia/Command/CreateAdminUser.php @@ -133,8 +133,7 @@ class CreateAdminUser extends ContainerAwareCommand } $output->writeln("Passwords are different, please try again."); - } - while (true); + } while (true); return $admin; } @@ -144,4 +143,4 @@ class CreateAdminUser extends ContainerAwareCommand return sprintf("%s", $text); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Command/ReloadDatabaseCommand.php b/core/lib/Thelia/Command/ReloadDatabaseCommand.php index d25add644..70fab56d9 100644 --- a/core/lib/Thelia/Command/ReloadDatabaseCommand.php +++ b/core/lib/Thelia/Command/ReloadDatabaseCommand.php @@ -28,7 +28,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Thelia\Install\Database; - /** * Class ReloadDatabasesCommand * @package Thelia\Command @@ -67,4 +66,4 @@ class ReloadDatabaseCommand extends BaseModuleGenerate '' )); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Command/Skeleton/Module/Class.php b/core/lib/Thelia/Command/Skeleton/Module/Class.php index c4c90aa60..c9c7109ac 100755 --- a/core/lib/Thelia/Command/Skeleton/Module/Class.php +++ b/core/lib/Thelia/Command/Skeleton/Module/Class.php @@ -25,7 +25,7 @@ namespace %%NAMESPACE%%; use Thelia\Module\BaseModule; -class %%CLASSNAME%% extends BaseModule +class Class extends BaseModule { /** * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index a6dd05c89..50e32955d 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -23,18 +23,6 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\MessageDeleteEvent; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Tools\URL; -use Thelia\Core\Event\MessageUpdateEvent; -use Thelia\Core\Event\MessageCreateEvent; -use Thelia\Log\Tlog; -use Thelia\Form\Exception\FormValidationException; -use Thelia\Core\Security\Exception\AuthorizationException; -use Thelia\Model\MessageQuery; -use Thelia\Form\MessageModificationForm; -use Thelia\Form\MessageCreationForm; - /** * Manages messages sent by mail * @@ -47,17 +35,15 @@ class AttributeController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function defaultAction() { - + public function defaultAction() + { if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response; - return $this->render('product-attributes'); } - public function updateAction() { - + public function updateAction() + { if (null !== $response = $this->checkAuth("admin.configuration.attributes.update")) return $response; - return $this->render('product-attributes-edit'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 5461b8d3f..21fffd3d9 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -33,7 +33,6 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Tools\URL; use Thelia\Tools\Redirect; -use Thelia\Core\Security\SecurityContext; use Thelia\Model\AdminLog; use Thelia\Model\Lang; use Thelia\Model\LangQuery; @@ -50,14 +49,15 @@ class BaseAdminController extends BaseController * * @param unknown $message */ - public function adminLogAppend($message) { + public function adminLogAppend($message) + { AdminLog::append($message, $this->getRequest(), $this->getSecurityContext()->getAdminUser()); } /** * This method process the rendering of view called from an admin page * - * @param unknown $template + * @param unknown $template * @return Response the reponse which contains the rendered view */ public function processTemplateAction($template) @@ -66,12 +66,10 @@ class BaseAdminController extends BaseController if (! empty($template)) { // If we have a view in the URL, render this view return $this->render($template); - } - elseif (null != $view = $this->getRequest()->get('view')) { + } elseif (null != $view = $this->getRequest()->get('view')) { return $this->render($view); } - } - catch (\Exception $ex) { + } catch (\Exception $ex) { return $this->errorPage($ex->getMessage()); } @@ -135,7 +133,8 @@ class BaseAdminController extends BaseController /* * Create the standard message displayed to the user when the form cannot be validated. */ - protected function createStandardFormValidationErrorMessage(FormValidationException $exception) { + protected function createStandardFormValidationErrorMessage(FormValidationException $exception) + { return $this->getTranslator()->trans( "Please check your input: %error", array( @@ -147,13 +146,13 @@ class BaseAdminController extends BaseController /** * Setup the error context when an error occurs in a action method. * - * @param string $action the action that caused the error (category modification, variable creation, currency update, etc.) - * @param BaseForm $form the form where the error occured, or null if no form was involved - * @param string $error_message the error message - * @param Exception $exception the exception or null if no exception + * @param string $action the action that caused the error (category modification, variable creation, currency update, etc.) + * @param BaseForm $form the form where the error occured, or null if no form was involved + * @param string $error_message the error message + * @param Exception $exception the exception or null if no exception */ - protected function setupFormErrorContext($action, $error_message, BaseForm $form = null, \Exception $exception = null) { - + protected function setupFormErrorContext($action, $error_message, BaseForm $form = null, \Exception $exception = null) + { if ($error_message !== false) { // Log the error message @@ -214,7 +213,7 @@ class BaseAdminController extends BaseController /** * Return the route path defined for the givent route ID * - * @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml + * @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml * @param mixed $parameters An array of parameters * @param Boolean|string $referenceType The type of reference to be generated (one of the constants) * @@ -222,12 +221,13 @@ class BaseAdminController extends BaseController * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement - * @throws \InvalidArgumentException When the router doesn't exist - * @return string The generated URL + * @throws \InvalidArgumentException When the router doesn't exist + * @return string The generated URL * * @see \Thelia\Controller\BaseController::getRouteFromRouter() */ - protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { + protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) + { return $this->getRouteFromRouter( 'router.admin', $routeId, @@ -239,18 +239,19 @@ class BaseAdminController extends BaseController /** * Redirect to à route ID related URL * - * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml + * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml * @param unknown $urlParameters the URL parametrs, as a var/value pair array */ - public function redirectToRoute($routeId, $urlParameters = array()) { + public function redirectToRoute($routeId, $urlParameters = array()) + { $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters)); } /** * Get the current edition lang ID, checking if a change was requested in the current request. */ - protected function getCurrentEditionLang() { - + protected function getCurrentEditionLang() + { // Return the new language if a change is required. if (null !== $edit_language_id = $this->getRequest()->get('edit_language_id', null)) { @@ -266,7 +267,8 @@ class BaseAdminController extends BaseController /** * A simple helper to get the current edition locale. */ - protected function getCurrentEditionLocale() { + protected function getCurrentEditionLocale() + { return $this->getCurrentEditionLang()->getLocale(); } @@ -322,13 +324,11 @@ class BaseAdminController extends BaseController $data = $this->getParser()->render($templateName, $args); return $data; - } - catch (AuthenticationException $ex) { + } catch (AuthenticationException $ex) { // User is not authenticated, and templates requires authentication -> redirect to login page // We user login_tpl as a path, not a template. Redirect::exec(URL::getInstance()->absoluteUrl($ex->getLoginTemplate())); - } - catch (AuthorizationException $ex) { + } catch (AuthorizationException $ex) { // User is not allowed to perform the required action. Return the error page instead of the requested page. return $this->errorPage($this->getTranslator()->trans("Sorry, you are not allowed to perform this action.")); } diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 5eca91cf9..fba832ec8 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -23,18 +23,10 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Security\Exception\AuthenticationException; -use Thelia\Core\Security\Exception\AuthorizationException; -use Thelia\Log\Tlog; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\CategoryDeleteEvent; -use Thelia\Core\Event\CategoryToggleVisibilityEvent; -use Thelia\Core\Event\CategoryChangePositionEvent; -use Thelia\Form\CategoryDeletionForm; -use Thelia\Model\Lang; -use Thelia\Core\Translation\Translator; use Thelia\Core\Event\CategoryUpdatePositionEvent; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; @@ -46,12 +38,13 @@ class CategoryController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - protected function renderList() { + protected function renderList() + { return $this->render('categories', $this->getTemplateArgs()); } - protected function getTemplateArgs() { - + protected function getTemplateArgs() + { // Get the category ID $category_id = $this->getRequest()->get('category_id', 0); @@ -77,10 +70,9 @@ class CategoryController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function defaultAction() { - + public function defaultAction() + { if (null !== $response = $this->checkAuth("admin.categories.view")) return $response; - return $this->renderList(); } @@ -89,8 +81,8 @@ class CategoryController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function createAction() { - + public function createAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.create")) return $response; @@ -126,12 +118,10 @@ class CategoryController extends BaseAdminController // Redirect to the success URL $this->redirect($successUrl); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } @@ -147,8 +137,8 @@ class CategoryController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function changeAction() { - + public function changeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; @@ -189,8 +179,8 @@ class CategoryController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function saveChangeAction() { - + public function saveChangeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; @@ -241,12 +231,10 @@ class CategoryController extends BaseAdminController // Redirect to the success URL $this->redirect($changeForm->getSuccessUrl()); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } @@ -260,7 +248,8 @@ class CategoryController extends BaseAdminController /** * Online status toggle category */ - public function setToggleVisibilityAction() { + public function setToggleVisibilityAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; @@ -271,8 +260,7 @@ class CategoryController extends BaseAdminController try { $this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -283,7 +271,8 @@ class CategoryController extends BaseAdminController /** * Update categoryposition */ - public function updatePositionAction() { + public function updatePositionAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; @@ -306,8 +295,7 @@ class CategoryController extends BaseAdminController ); $this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -320,8 +308,8 @@ class CategoryController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function deleteAction() { - + public function deleteAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response; @@ -335,4 +323,4 @@ class CategoryController extends BaseAdminController $this->redirectToRoute('admin.categories.default'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index 6d1a04b05..397266677 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -28,9 +28,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Tools\URL; use Thelia\Core\Event\ConfigUpdateEvent; use Thelia\Core\Event\ConfigCreateEvent; -use Thelia\Log\Tlog; use Thelia\Form\Exception\FormValidationException; -use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Model\ConfigQuery; use Thelia\Form\ConfigModificationForm; use Thelia\Form\ConfigCreationForm; @@ -47,8 +45,8 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - protected function renderList() { - + protected function renderList() + { // Find the current order $order = $this->getRequest()->get( 'order', @@ -66,10 +64,9 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function defaultAction() { - + public function defaultAction() + { if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response; - return $this->renderList(); } @@ -78,8 +75,8 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function createAction() { - + public function createAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.variables.create")) return $response; @@ -120,12 +117,10 @@ class ConfigController extends BaseAdminController // Redirect to the success URL $this->redirect($successUrl); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $message = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $message = $ex->getMessage(); } @@ -141,8 +136,8 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function changeAction() { - + public function changeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response; @@ -183,8 +178,8 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function saveChangeAction() { - + public function saveChangeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response; @@ -240,12 +235,10 @@ class ConfigController extends BaseAdminController // Redirect to the success URL $this->redirect($changeForm->getSuccessUrl()); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $message = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $message = $ex->getMessage(); } @@ -261,15 +254,15 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function changeValuesAction() { - + public function changeValuesAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response; $variables = $this->getRequest()->get('variable', array()); // Process all changed variables - foreach($variables as $id => $value) { + foreach ($variables as $id => $value) { $event = new ConfigUpdateEvent($id); $event->setValue($value); @@ -284,8 +277,8 @@ class ConfigController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function deleteAction() { - + public function deleteAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.variables.delete")) return $response; @@ -299,4 +292,4 @@ class ConfigController extends BaseAdminController $this->redirectToRoute('admin.configuration.variables.default'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index e11fcf09e..a440b9ba6 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -26,17 +26,12 @@ namespace Thelia\Controller\Admin; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Router; use Thelia\Constraint\ConstraintFactory; -use Thelia\Constraint\ConstraintFactoryTest; use Thelia\Constraint\Rule\AvailableForTotalAmount; use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Constraint\Validator\PriceParam; -use Thelia\Core\Event\Coupon\CouponCreateEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\HttpFoundation\Session\Session; -use Thelia\Core\Security\Exception\AuthenticationException; -use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Core\Translation\Translator; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\CouponManager; @@ -222,7 +217,6 @@ class CouponController extends BaseAdminController ); } - /** * Manage Coupons Rule creation display * @@ -311,8 +305,6 @@ class CouponController extends BaseAdminController ); } - - /** * Manage Coupons read display * @@ -375,7 +367,6 @@ class CouponController extends BaseAdminController ); } - /** * Manage Coupons read display * @@ -697,6 +688,4 @@ class CouponController extends BaseAdminController // } // } - - } diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index c6f5afdc3..ff2db0ab2 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -28,9 +28,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Tools\URL; use Thelia\Core\Event\CurrencyUpdateEvent; use Thelia\Core\Event\CurrencyCreateEvent; -use Thelia\Log\Tlog; use Thelia\Form\Exception\FormValidationException; -use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Model\CurrencyQuery; use Thelia\Form\CurrencyModificationForm; use Thelia\Form\CurrencyCreationForm; @@ -48,8 +46,8 @@ class CurrencyController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - protected function renderList() { - + protected function renderList() + { // Find the current order $order = $this->getRequest()->get( 'order', @@ -67,10 +65,9 @@ class CurrencyController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function defaultAction() { - + public function defaultAction() + { if (null !== $response = $this->checkAuth("admin.configuration.currencies.view")) return $response; - return $this->renderList(); } @@ -79,8 +76,8 @@ class CurrencyController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function createAction() { - + public function createAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response; @@ -120,12 +117,10 @@ class CurrencyController extends BaseAdminController // Redirect to the success URL $this->redirect($successUrl); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } @@ -141,8 +136,8 @@ class CurrencyController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function changeAction() { - + public function changeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; @@ -179,8 +174,8 @@ class CurrencyController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function saveChangeAction() { - + public function saveChangeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; @@ -231,12 +226,10 @@ class CurrencyController extends BaseAdminController // Redirect to the success URL $this->redirect($changeForm->getSuccessUrl()); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } @@ -250,7 +243,8 @@ class CurrencyController extends BaseAdminController /** * Sets the default currency */ - public function setDefaultAction() { + public function setDefaultAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; @@ -261,8 +255,7 @@ class CurrencyController extends BaseAdminController try { $this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -273,14 +266,14 @@ class CurrencyController extends BaseAdminController /** * Update currencies rates */ - public function updateRatesAction() { + public function updateRatesAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; try { $this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -291,7 +284,8 @@ class CurrencyController extends BaseAdminController /** * Update currencyposition */ - public function updatePositionAction() { + public function updatePositionAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; @@ -314,8 +308,7 @@ class CurrencyController extends BaseAdminController ); $this->dispatch(TheliaEvents::CURRENCY_UPDATE_POSITION, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -323,14 +316,13 @@ class CurrencyController extends BaseAdminController $this->redirectToRoute('admin.configuration.currencies.default'); } - /** * Delete a currency object * * @return Symfony\Component\HttpFoundation\Response the response */ - public function deleteAction() { - + public function deleteAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.currencies.delete")) return $response; @@ -344,4 +336,4 @@ class CurrencyController extends BaseAdminController $this->redirectToRoute('admin.configuration.currencies.default'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index 04c8842cd..c53c2b3d3 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -23,7 +23,6 @@ namespace Thelia\Controller\Admin; - /** * Class CustomerController * @package Thelia\Controller\Admin @@ -34,7 +33,6 @@ class CustomerController extends BaseAdminController public function indexAction() { if (null !== $response = $this->checkAuth("admin.customers.view")) return $response; - return $this->render("customers", array("display_customer" => 20)); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php index 00fcb17bd..b5316efdd 100644 --- a/core/lib/Thelia/Controller/Admin/MessageController.php +++ b/core/lib/Thelia/Controller/Admin/MessageController.php @@ -28,9 +28,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Tools\URL; use Thelia\Core\Event\MessageUpdateEvent; use Thelia\Core\Event\MessageCreateEvent; -use Thelia\Log\Tlog; use Thelia\Form\Exception\FormValidationException; -use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Model\MessageQuery; use Thelia\Form\MessageModificationForm; use Thelia\Form\MessageCreationForm; @@ -47,7 +45,8 @@ class MessageController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - protected function renderList() { + protected function renderList() + { return $this->render('messages'); } @@ -56,10 +55,9 @@ class MessageController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function defaultAction() { - + public function defaultAction() + { if (null !== $response = $this->checkAuth("admin.configuration.messages.view")) return $response; - return $this->renderList(); } @@ -68,8 +66,8 @@ class MessageController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function createAction() { - + public function createAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.messages.create")) return $response; @@ -107,12 +105,10 @@ class MessageController extends BaseAdminController // Redirect to the success URL $this->redirect($successUrl); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $message = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $message = $ex->getMessage(); } @@ -128,8 +124,8 @@ class MessageController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function changeAction() { - + public function changeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response; @@ -168,8 +164,8 @@ class MessageController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function saveChangeAction() { - + public function saveChangeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response; @@ -221,12 +217,10 @@ class MessageController extends BaseAdminController // Redirect to the success URL $this->redirect($changeForm->getSuccessUrl()); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $message = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $message = $ex->getMessage(); } @@ -242,8 +236,8 @@ class MessageController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function deleteAction() { - + public function deleteAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.messages.delete")) return $response; @@ -257,4 +251,4 @@ class MessageController extends BaseAdminController $this->redirectToRoute('admin.configuration.messages.default'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index d7385ad1b..81f366ddf 100755 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -27,7 +27,6 @@ use Thelia\Form\AdminLogin; use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator; use Thelia\Model\AdminLog; use Thelia\Core\Security\Exception\AuthenticationException; -use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Core\Event\TheliaEvents; @@ -74,20 +73,17 @@ class SessionController extends BaseAdminController // Redirect to the success URL return Redirect::exec($adminLoginForm->getSuccessUrl()); - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Validation problem $message = $this->createStandardFormValidationErrorMessage($ex); - } - catch (AuthenticationException $ex) { + } catch (AuthenticationException $ex) { // Log authentication failure AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request); $message = $this->getTranslator()->trans("Login failed. Please check your username and password."); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Log authentication failure AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request); @@ -103,4 +99,4 @@ class SessionController extends BaseAdminController // Display the login form again return $this->render("login"); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 95ba9a524..36a03529b 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -39,7 +39,6 @@ use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; use Symfony\Component\EventDispatcher\Event; use Thelia\Core\Event\DefaultActionEvent; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -65,8 +64,8 @@ class BaseController extends ContainerAware /** * Dispatch a Thelia event * - * @param string $eventName a TheliaEvent name, as defined in TheliaEvents class - * @param Event $event the action event, or null (a DefaultActionEvent will be dispatched) + * @param string $eventName a TheliaEvent name, as defined in TheliaEvents class + * @param Event $event the action event, or null (a DefaultActionEvent will be dispatched) */ protected function dispatch($eventName, ActionEvent $event = null) { @@ -139,11 +138,11 @@ class BaseController extends ContainerAware /** * Get all errors that occured in a form * - * @param \Symfony\Component\Form\Form $form - * @return string the error string + * @param \Symfony\Component\Form\Form $form + * @return string the error string */ - private function getErrorMessages(\Symfony\Component\Form\Form $form) { - + private function getErrorMessages(\Symfony\Component\Form\Form $form) + { $errors = ''; foreach ($form->getErrors() as $key => $error) { @@ -177,8 +176,7 @@ class BaseController extends ContainerAware if ($form->isValid()) { return $form; - } - else { + } else { $errorMessage = null; if ($form->get("error_message")->getData() != null) { $errorMessage = $form->get("error_message")->getData(); @@ -188,8 +186,7 @@ class BaseController extends ContainerAware throw new FormValidationException($errorMessage); } - } - else { + } else { throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod)); } } @@ -214,8 +211,7 @@ class BaseController extends ContainerAware { if ($form != null) { $url = $form->getSuccessUrl(); - } - else { + } else { $url = $this->getRequest()->get("success_url"); } @@ -236,10 +232,11 @@ class BaseController extends ContainerAware * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement - * @throws \InvalidArgumentException When the router doesn't exist - * @return string The generated URL + * @throws \InvalidArgumentException When the router doesn't exist + * @return string The generated URL */ - protected function getRouteFromRouter($routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { + protected function getRouteFromRouter($routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) + { /** @var Router $router */ $router = $this->container->get($routerName); @@ -268,4 +265,4 @@ class BaseController extends ContainerAware { return $this->container->getParameter('kernel.debug'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Front/AddressController.php b/core/lib/Thelia/Controller/Front/AddressController.php index 08e803556..92d54695c 100644 --- a/core/lib/Thelia/Controller/Front/AddressController.php +++ b/core/lib/Thelia/Controller/Front/AddressController.php @@ -31,7 +31,6 @@ use Thelia\Model\Base\AddressQuery; use Thelia\Model\Customer; use Thelia\Tools\URL; - /** * Class AddressController * @package Thelia\Controller\Front @@ -64,10 +63,9 @@ class AddressController extends BaseFrontController $this->dispatch(TheliaEvents::ADDRESS_CREATE, $event); $this->redirectSuccess($addressCreate); - }catch (FormValidationException $e) { + } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); - } - catch (\Exception $e) { + } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); } @@ -91,7 +89,7 @@ class AddressController extends BaseFrontController $this->redirectToRoute("home"); } - if(null === $address_id = $request->get("address_id")) { + if (null === $address_id = $request->get("address_id")) { $this->redirectToRoute("home"); } @@ -108,7 +106,7 @@ class AddressController extends BaseFrontController $this->redirectToRoute("home"); } - if($address->getCustomer()->getId() != $customer->getId()) { + if ($address->getCustomer()->getId() != $customer->getId()) { $this->redirectToRoute("home"); } @@ -118,10 +116,9 @@ class AddressController extends BaseFrontController $this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event); $this->redirectSuccess($addressUpdate); - }catch (FormValidationException $e) { + } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); - } - catch (\Exception $e) { + } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); } @@ -155,4 +152,4 @@ class AddressController extends BaseFrontController $form->get("company")->getData() ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index ed6774c8b..cf83e865d 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -35,17 +35,19 @@ class BaseFrontController extends BaseController * * @see \Thelia\Controller\BaseController::getRouteFromRouter() */ - protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { + protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) + { return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType); } /** * Redirect to à route ID related URL * - * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml + * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml * @param unknown $urlParameters the URL parametrs, as a var/value pair array */ - public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) { + public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) + { $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters)); } } diff --git a/core/lib/Thelia/Controller/Front/CartController.php b/core/lib/Thelia/Controller/Front/CartController.php index c3d928a15..e13ecd61b 100755 --- a/core/lib/Thelia/Controller/Front/CartController.php +++ b/core/lib/Thelia/Controller/Front/CartController.php @@ -77,7 +77,7 @@ class CartController extends BaseFrontController $this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent); $this->redirectSuccess(); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->getParserContext()->setGeneralError($e->getMessage()); } @@ -97,7 +97,6 @@ class CartController extends BaseFrontController $this->getParserContext()->setGeneralError($e->getMessage()); } - } /** diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 58d578955..85db69472 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -27,19 +27,15 @@ use Thelia\Core\Event\CustomerLoginEvent; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\UsernameNotFoundException; -use Thelia\Core\Security\SecurityContext; use Thelia\Form\CustomerCreation; use Thelia\Form\CustomerLogin; use Thelia\Form\CustomerModification; use Thelia\Form\Exception\FormValidationException; use Thelia\Model\Customer; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CustomerEvent; -use Thelia\Core\Factory\ActionEventFactory; use Thelia\Tools\URL; use Thelia\Log\Tlog; use Thelia\Core\Security\Exception\WrongPasswordException; -use Symfony\Component\Routing\Router; /** * Class CustomerController @@ -70,11 +66,9 @@ class CustomerController extends BaseFrontController $this->processLogin($customerCreateEvent->getCustomer()); $this->redirectSuccess($customerCreation); - } - catch (FormValidationException $e) { + } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); - } - catch (\Exception $e) { + } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); } @@ -118,11 +112,9 @@ class CustomerController extends BaseFrontController $this->redirectSuccess($customerModification); - } - catch (FormValidationException $e) { + } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); - } - catch (\Exception $e) { + } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); } @@ -166,29 +158,24 @@ class CustomerController extends BaseFrontController $this->redirectSuccess($customerLoginForm); - } - catch (FormValidationException $e) { + } catch (FormValidationException $e) { if ($request->request->has("account")) { $account = $request->request->get("account"); $form = $customerLoginForm->getForm(); - if($account == 0 && $form->get("email")->getData() !== null) { + if ($account == 0 && $form->get("email")->getData() !== null) { $this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData())); } } $message = sprintf("Please check your input: %s", $e->getMessage()); - } - catch(UsernameNotFoundException $e) { + } catch (UsernameNotFoundException $e) { $message = "Wrong email or password. Please try again"; - } - catch (WrongPasswordException $e) { + } catch (WrongPasswordException $e) { $message = "Wrong email or password. Please try again"; - } - catch(AuthenticationException $e) { + } catch (AuthenticationException $e) { $message = "Wrong email or password. Please try again"; - } - catch (\Exception $e) { + } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); } diff --git a/core/lib/Thelia/Controller/Front/DefaultController.php b/core/lib/Thelia/Controller/Front/DefaultController.php index fe7e1aede..0466e4dd4 100755 --- a/core/lib/Thelia/Controller/Front/DefaultController.php +++ b/core/lib/Thelia/Controller/Front/DefaultController.php @@ -53,7 +53,7 @@ class DefaultController extends BaseFrontController $view = $request->request->get('view'); } } - if(null !== $view) { + if (null !== $view) { $request->attributes->set('_view', $view); } @@ -61,11 +61,11 @@ class DefaultController extends BaseFrontController $request->attributes->set("_view", "index"); } - if(ConfigQuery::isRewritingEnable()) { - if($request->attributes->get('_rewritten', false) === false) { + if (ConfigQuery::isRewritingEnable()) { + if ($request->attributes->get('_rewritten', false) === false) { /* Does the query GET parameters match a rewritten URL ? */ $rewrittenUrl = URL::getInstance()->retrieveCurrent($request); - if($rewrittenUrl->rewrittenUrl !== null) { + if ($rewrittenUrl->rewrittenUrl !== null) { /* 301 redirection to rewritten URL */ $this->redirect($rewrittenUrl->rewrittenUrl, 301); } diff --git a/core/lib/Thelia/Controller/Front/DeliveryController.php b/core/lib/Thelia/Controller/Front/DeliveryController.php index ef84be6ab..ef5913bc9 100644 --- a/core/lib/Thelia/Controller/Front/DeliveryController.php +++ b/core/lib/Thelia/Controller/Front/DeliveryController.php @@ -25,7 +25,6 @@ namespace Thelia\Controller\Front; use Thelia\Model\ModuleQuery; use Thelia\Tools\URL; - /** * Class DeliveryController * @package Thelia\Controller\Front @@ -53,4 +52,4 @@ class DeliveryController extends BaseFrontController $this->pageNotFound(); } } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Install/BaseInstallController.php b/core/lib/Thelia/Controller/Install/BaseInstallController.php index a5cbbd506..35293904e 100644 --- a/core/lib/Thelia/Controller/Install/BaseInstallController.php +++ b/core/lib/Thelia/Controller/Install/BaseInstallController.php @@ -25,7 +25,6 @@ namespace Thelia\Controller\Install; use Symfony\Component\HttpFoundation\Response; use Thelia\Controller\BaseController; - /** * Class BaseInstallController * @package Thelia\Controller\Install @@ -57,4 +56,4 @@ class BaseInstallController extends BaseController return $data; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Install/InstallController.php b/core/lib/Thelia/Controller/Install/InstallController.php index 209eea82b..0514ba0ff 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Controller/Install/InstallController.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Controller\Install; -use Thelia\Install\BaseInstall; use Thelia\Install\CheckPermission; /** @@ -30,8 +29,8 @@ use Thelia\Install\CheckPermission; * @package Thelia\Controller\Install * @author Manuel Raynaud */ -class InstallController extends BaseInstallController { - +class InstallController extends BaseInstallController +{ public function index() { $this->verifyStep(1); @@ -58,7 +57,7 @@ class InstallController extends BaseInstallController { return true; } - switch($step) { + switch ($step) { case "1" : if ($sessionStep > 1) { $this->redirect("/install/step/2"); @@ -66,4 +65,4 @@ class InstallController extends BaseInstallController { break; } } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/ActionEvent.php b/core/lib/Thelia/Core/Event/ActionEvent.php index 5040be7f5..41886fd82 100755 --- a/core/lib/Thelia/Core/Event/ActionEvent.php +++ b/core/lib/Thelia/Core/Event/ActionEvent.php @@ -24,8 +24,6 @@ namespace Thelia\Core\Event; use Symfony\Component\EventDispatcher\Event; -use Thelia\Core\HttpFoundation\Request; -use Thelia\Form\BaseForm; /** * * Class thrown on Thelia.action event @@ -50,4 +48,4 @@ abstract class ActionEvent extends Event return null; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php index d6dd6e3ed..af69ae0b4 100644 --- a/core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php @@ -26,7 +26,6 @@ use Symfony\Component\EventDispatcher\Event; use Thelia\Model\Address; use Thelia\Model\Customer; - /** * Class AddressCreateOrUpdateEvent * @package Thelia\Core\Event @@ -109,7 +108,7 @@ class AddressCreateOrUpdateEvent extends ActionEvent */ protected $address; - function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company) + public function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company) { $this->address1 = $address1; $this->address2 = $address2; @@ -263,5 +262,4 @@ class AddressCreateOrUpdateEvent extends ActionEvent return $this->address; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/AddressEvent.php b/core/lib/Thelia/Core/Event/AddressEvent.php index 5167108fd..366801075 100644 --- a/core/lib/Thelia/Core/Event/AddressEvent.php +++ b/core/lib/Thelia/Core/Event/AddressEvent.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Event; use Symfony\Component\EventDispatcher\Event; use Thelia\Model\Address; - /** * Class AddressEvent * @package Thelia\Core\Event @@ -38,12 +37,11 @@ class AddressEvent extends ActionEvent */ protected $address; - function __construct(Address $address) + public function __construct(Address $address) { $this->address = $address; } - /** * @return \Thelia\Model\Address */ @@ -51,4 +49,4 @@ class AddressEvent extends ActionEvent { return $this->address; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php index 2dbd54374..65be75292 100644 --- a/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event; - class BaseToggleVisibilityEvent extends ActionEvent { protected $object_id; @@ -43,6 +42,7 @@ class BaseToggleVisibilityEvent extends ActionEvent public function setObjectId($object_id) { $this->object_id = $object_id; + return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/BaseUpdatePositionEvent.php b/core/lib/Thelia/Core/Event/BaseUpdatePositionEvent.php index 41907c29c..9b58ecfeb 100644 --- a/core/lib/Thelia/Core/Event/BaseUpdatePositionEvent.php +++ b/core/lib/Thelia/Core/Event/BaseUpdatePositionEvent.php @@ -50,6 +50,7 @@ class BaseUpdatePositionEvent extends ActionEvent public function setMode($mode) { $this->mode = $mode; + return $this; } @@ -61,6 +62,7 @@ class BaseUpdatePositionEvent extends ActionEvent public function setPosition($position) { $this->position = $position; + return $this; } @@ -72,6 +74,7 @@ class BaseUpdatePositionEvent extends ActionEvent public function setObjectId($object_id) { $this->object_id = $object_id; + return $this; } } diff --git a/core/lib/Thelia/Core/Event/CartEvent.php b/core/lib/Thelia/Core/Event/CartEvent.php index 61d58e9d2..b24a5c403 100755 --- a/core/lib/Thelia/Core/Event/CartEvent.php +++ b/core/lib/Thelia/Core/Event/CartEvent.php @@ -145,5 +145,4 @@ class CartEvent extends ActionEvent return $this->cart; } - } diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 0a6b79269..5a687217c 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Category; - class CategoryCreateEvent extends CategoryEvent { protected $title; @@ -46,6 +44,7 @@ class CategoryCreateEvent extends CategoryEvent public function setTitle($title) { $this->title = $title; + return $this; } @@ -57,6 +56,7 @@ class CategoryCreateEvent extends CategoryEvent public function setParent($parent) { $this->parent = $parent; + return $this; } @@ -68,6 +68,7 @@ class CategoryCreateEvent extends CategoryEvent public function setLocale($locale) { $this->locale = $locale; + return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php index ad686563d..9d77a7e87 100644 --- a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Category; - class CategoryDeleteEvent extends CategoryEvent { public function __construct($category_id) @@ -40,6 +38,7 @@ class CategoryDeleteEvent extends CategoryEvent public function setCategoryId($category_id) { $this->category_id = $category_id; + return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CategoryEvent.php b/core/lib/Thelia/Core/Event/CategoryEvent.php index ac04f15c9..ab5b101e5 100644 --- a/core/lib/Thelia/Core/Event/CategoryEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryEvent.php @@ -35,7 +35,8 @@ class CategoryEvent extends ActionEvent $this->category = $category; } - public function hasCategory() { + public function hasCategory() + { return ! is_null($this->category); } diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php index 103c5207e..506904ec8 100644 --- a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -25,4 +25,4 @@ namespace Thelia\Core\Event; class CategoryToggleVisibilityEvent extends BaseToggleVisibilityEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php index 305cf9369..44e760549 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Core\Event; -use Thelia\Model\Category; class CategoryUpdateEvent extends CategoryCreateEvent { @@ -49,6 +48,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setCategoryId($category_id) { $this->category_id = $category_id; + return $this; } @@ -60,6 +60,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setChapo($chapo) { $this->chapo = $chapo; + return $this; } @@ -71,6 +72,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setDescription($description) { $this->description = $description; + return $this; } @@ -82,6 +84,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setPostscriptum($postscriptum) { $this->postscriptum = $postscriptum; + return $this; } @@ -93,6 +96,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setUrl($url) { $this->url = $url; + return $this; } @@ -104,6 +108,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setVisibility($visibility) { $this->visibility = $visibility; + return $this; } @@ -115,6 +120,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent public function setParent($parent) { $this->parent = $parent; + return $this; } } diff --git a/core/lib/Thelia/Core/Event/CategoryUpdatePositionEvent.php b/core/lib/Thelia/Core/Event/CategoryUpdatePositionEvent.php index 44af9b946..701fd4c8a 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdatePositionEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryUpdatePositionEvent.php @@ -25,4 +25,4 @@ namespace Thelia\Core\Event; class CategoryUpdatePositionEvent extends BaseUpdatePositionEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/ConfigCreateEvent.php b/core/lib/Thelia/Core/Event/ConfigCreateEvent.php index 79440c491..986eb31b7 100644 --- a/core/lib/Thelia/Core/Event/ConfigCreateEvent.php +++ b/core/lib/Thelia/Core/Event/ConfigCreateEvent.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Core\Event; -use Thelia\Model\Config; class ConfigCreateEvent extends ConfigEvent { diff --git a/core/lib/Thelia/Core/Event/ConfigDeleteEvent.php b/core/lib/Thelia/Core/Event/ConfigDeleteEvent.php index 6cc39438c..87ae50c38 100644 --- a/core/lib/Thelia/Core/Event/ConfigDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/ConfigDeleteEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Config; - class ConfigDeleteEvent extends ConfigEvent { protected $config_id; diff --git a/core/lib/Thelia/Core/Event/ConfigEvent.php b/core/lib/Thelia/Core/Event/ConfigEvent.php index 5e1c673cf..646b43856 100644 --- a/core/lib/Thelia/Core/Event/ConfigEvent.php +++ b/core/lib/Thelia/Core/Event/ConfigEvent.php @@ -33,7 +33,8 @@ class ConfigEvent extends ActionEvent $this->config = $config; } - public function hasConfig() { + public function hasConfig() + { return ! is_null($this->config); } diff --git a/core/lib/Thelia/Core/Event/ConfigUpdateEvent.php b/core/lib/Thelia/Core/Event/ConfigUpdateEvent.php index a73613699..b3d5955c4 100644 --- a/core/lib/Thelia/Core/Event/ConfigUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/ConfigUpdateEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Config; - class ConfigUpdateEvent extends ConfigCreateEvent { protected $config_id; @@ -85,4 +83,4 @@ class ConfigUpdateEvent extends ConfigCreateEvent return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php index 796baed08..2e004b818 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php @@ -102,7 +102,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent * @param CouponRuleCollection $rules CouponRuleInterface to add * @param string $locale Coupon Language code ISO (ex: fr_FR) */ - function __construct( + public function __construct( $code, $title, $amount, @@ -307,6 +307,4 @@ class CouponCreateOrUpdateEvent extends ActionEvent return $this->coupon; } - - } diff --git a/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php b/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php index d9d345ddd..fe2cf078c 100644 --- a/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Core\Event; -use Thelia\Model\Currency; class CurrencyCreateEvent extends CurrencyEvent { @@ -92,4 +91,4 @@ class CurrencyCreateEvent extends CurrencyEvent return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php b/core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php index 5b9714b47..706b77f9d 100644 --- a/core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Currency; - class CurrencyDeleteEvent extends CurrencyEvent { protected $currency_id; @@ -45,4 +43,4 @@ class CurrencyDeleteEvent extends CurrencyEvent return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CurrencyEvent.php b/core/lib/Thelia/Core/Event/CurrencyEvent.php index 65ac60513..cdc0b854c 100644 --- a/core/lib/Thelia/Core/Event/CurrencyEvent.php +++ b/core/lib/Thelia/Core/Event/CurrencyEvent.php @@ -33,7 +33,8 @@ class CurrencyEvent extends ActionEvent $this->currency = $currency; } - public function hasCurrency() { + public function hasCurrency() + { return ! is_null($this->currency); } diff --git a/core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php b/core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php index 044a93baa..58f8b0af4 100644 --- a/core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Core\Event; -use Thelia\Model\Currency; class CurrencyUpdateEvent extends CurrencyCreateEvent { diff --git a/core/lib/Thelia/Core/Event/CurrencyUpdatePositionEvent.php b/core/lib/Thelia/Core/Event/CurrencyUpdatePositionEvent.php index 3a3dbb18f..fad51f2c7 100644 --- a/core/lib/Thelia/Core/Event/CurrencyUpdatePositionEvent.php +++ b/core/lib/Thelia/Core/Event/CurrencyUpdatePositionEvent.php @@ -25,4 +25,4 @@ namespace Thelia\Core\Event; class CurrencyUpdatePositionEvent extends BaseUpdatePositionEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php index 9bee163ae..3a57d53a4 100755 --- a/core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php @@ -9,12 +9,11 @@ namespace Thelia\Core\Event; - use Symfony\Component\EventDispatcher\Event; use Thelia\Model\Customer; -class CustomerCreateOrUpdateEvent extends ActionEvent { - +class CustomerCreateOrUpdateEvent extends ActionEvent +{ //base parameters for creating new customer protected $title; protected $firstname; @@ -39,9 +38,8 @@ class CustomerCreateOrUpdateEvent extends ActionEvent { */ protected $customer; - /** - * @param int $title the title customer id + * @param int $title the title customer id * @param string $firstname * @param string $lastname * @param string $address1 @@ -51,15 +49,15 @@ class CustomerCreateOrUpdateEvent extends ActionEvent { * @param string $cellphone * @param string $zipcode * @param string $city - * @param int $country the country id + * @param int $country the country id * @param string $email - * @param string $password plain password, don't put hash password, it will hashes again + * @param string $password plain password, don't put hash password, it will hashes again * @param $lang - * @param int $reseller if customer is a reseller - * @param int $sponsor customer's id sponsor + * @param int $reseller if customer is a reseller + * @param int $sponsor customer's id sponsor * @param float $discount */ - function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount) + public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount) { $this->address1 = $address1; $this->address2 = $address2; @@ -231,7 +229,4 @@ class CustomerCreateOrUpdateEvent extends ActionEvent { return $this->customer; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/CustomerEvent.php b/core/lib/Thelia/Core/Event/CustomerEvent.php index 656f023c9..191b67e78 100755 --- a/core/lib/Thelia/Core/Event/CustomerEvent.php +++ b/core/lib/Thelia/Core/Event/CustomerEvent.php @@ -43,5 +43,4 @@ class CustomerEvent extends ActionEvent return $this->customer; } - } diff --git a/core/lib/Thelia/Core/Event/CustomerLoginEvent.php b/core/lib/Thelia/Core/Event/CustomerLoginEvent.php index 9a26bba3f..e43968845 100755 --- a/core/lib/Thelia/Core/Event/CustomerLoginEvent.php +++ b/core/lib/Thelia/Core/Event/CustomerLoginEvent.php @@ -23,11 +23,10 @@ namespace Thelia\Core\Event; - use Thelia\Model\Customer; -class CustomerLoginEvent extends ActionEvent { - +class CustomerLoginEvent extends ActionEvent +{ protected $customer; public function __construct(Customer $customer) @@ -39,4 +38,4 @@ class CustomerLoginEvent extends ActionEvent { { return $this->customer; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/ImageEvent.php b/core/lib/Thelia/Core/Event/ImageEvent.php index a105d9f6f..5ea1581cd 100755 --- a/core/lib/Thelia/Core/Event/ImageEvent.php +++ b/core/lib/Thelia/Core/Event/ImageEvent.php @@ -22,8 +22,6 @@ /*************************************************************************************/ namespace Thelia\Core\Event; -use Thelia\Core\HttpFoundation\Request; -use Thelia\Model\Cart; class ImageEvent extends ActionEvent { diff --git a/core/lib/Thelia/Core/Event/MessageCreateEvent.php b/core/lib/Thelia/Core/Event/MessageCreateEvent.php index 0d698168a..172af5f61 100644 --- a/core/lib/Thelia/Core/Event/MessageCreateEvent.php +++ b/core/lib/Thelia/Core/Event/MessageCreateEvent.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Core\Event; -use Thelia\Model\Message; class MessageCreateEvent extends MessageEvent { @@ -79,4 +78,4 @@ class MessageCreateEvent extends MessageEvent return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/MessageDeleteEvent.php b/core/lib/Thelia/Core/Event/MessageDeleteEvent.php index 5513c85a9..241c68463 100644 --- a/core/lib/Thelia/Core/Event/MessageDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/MessageDeleteEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Message; - class MessageDeleteEvent extends MessageEvent { protected $message_id; @@ -45,4 +43,4 @@ class MessageDeleteEvent extends MessageEvent return $this; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/MessageEvent.php b/core/lib/Thelia/Core/Event/MessageEvent.php index 0f46ae590..c0efcf39f 100644 --- a/core/lib/Thelia/Core/Event/MessageEvent.php +++ b/core/lib/Thelia/Core/Event/MessageEvent.php @@ -33,7 +33,8 @@ class MessageEvent extends ActionEvent $this->message = $message; } - public function hasMessage() { + public function hasMessage() + { return ! is_null($this->message); } diff --git a/core/lib/Thelia/Core/Event/MessageUpdateEvent.php b/core/lib/Thelia/Core/Event/MessageUpdateEvent.php index 1b3712266..8c9e2e740 100644 --- a/core/lib/Thelia/Core/Event/MessageUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/MessageUpdateEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event; -use Thelia\Model\Message; - class MessageUpdateEvent extends MessageCreateEvent { protected $message_id; diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 500803f53..c19d3a400 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -204,8 +204,6 @@ final class TheliaEvents */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; - - /** * Sent when creating a Coupon */ @@ -311,7 +309,6 @@ final class TheliaEvents */ const AFTER_COUPON_RULE_DELETE = "action.after_delete_coupon_rule"; - // -- Configuration management --------------------------------------------- const CONFIG_CREATE = "action.createConfig"; @@ -361,5 +358,4 @@ final class TheliaEvents const BEFORE_DELETECURRENCY = "action.before_deleteCurrency"; const AFTER_DELETECURRENCY = "action.after_deleteCurrency"; - } diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index fc2726647..dd6af30d2 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -84,6 +84,7 @@ class Session extends BaseSession public function setCustomerUser(UserInterface $user) { $this->set('thelia.customer_user', $user); + return $this; } @@ -102,6 +103,7 @@ class Session extends BaseSession public function setAdminUser(UserInterface $user) { $this->set('thelia.admin_user', $user); + return $this; } @@ -120,6 +122,7 @@ class Session extends BaseSession public function setReturnToUrl($url) { $this->set('thelia.return_to_url', $url); + return $this; } @@ -180,6 +183,7 @@ class Session extends BaseSession public function setCart($cart_id) { $this->set("thelia.cart_id", $cart_id); + return $this; } @@ -192,6 +196,7 @@ class Session extends BaseSession public function setDelivery($delivery_id) { $this->set("thelia.delivery_id", $delivery_id); + return $this; } @@ -199,4 +204,4 @@ class Session extends BaseSession { return $this->get("thelia.delivery_id"); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Routing/RewritingRouter.php b/core/lib/Thelia/Core/Routing/RewritingRouter.php index 79d5dc80b..2b663a979 100644 --- a/core/lib/Thelia/Core/Routing/RewritingRouter.php +++ b/core/lib/Thelia/Core/Routing/RewritingRouter.php @@ -38,7 +38,6 @@ use Thelia\Model\ConfigQuery; use Thelia\Tools\Redirect; use Thelia\Tools\URL; - /** * Class RewritingRouter * @package Thelia\Core\Routing @@ -114,8 +113,8 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface * * If there is no route with the given name, the generator must throw the RouteNotFoundException. * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters + * @param string $name The name of the route + * @param mixed $parameters An array of parameters * @param Boolean|string $referenceType The type of reference to be generated (one of the constants) * * @return string The generated URL @@ -163,16 +162,16 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface * @throws \Exception|\Thelia\Exception\UrlRewritingException * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException * @throws \Thelia\Exception\RedirectException - * @return array An array of parameters + * @return array An array of parameters * */ public function matchRequest(Request $request) { - if(ConfigQuery::isRewritingEnable()) { + if (ConfigQuery::isRewritingEnable()) { try { $rewrittenUrlData = URL::getInstance()->resolve($request->getPathInfo()); - } catch(UrlRewritingException $e) { - switch($e->getCode()) { + } catch (UrlRewritingException $e) { + switch ($e->getCode()) { case UrlRewritingException::URL_NOT_FOUND : throw new ResourceNotFoundException(); break; @@ -183,23 +182,23 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface /* is the URL redirected ? */ - if(null !== $rewrittenUrlData->redirectedToUrl) { + if (null !== $rewrittenUrlData->redirectedToUrl) { $this->redirect($rewrittenUrlData->redirectedToUrl, 301); } /* define GET arguments in request */ - if(null !== $rewrittenUrlData->view) { + if (null !== $rewrittenUrlData->view) { $request->attributes->set('_view', $rewrittenUrlData->view); - if(null !== $rewrittenUrlData->viewId) { + if (null !== $rewrittenUrlData->viewId) { $request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId); } } - if(null !== $rewrittenUrlData->locale) { + if (null !== $rewrittenUrlData->locale) { $request->query->set('locale', $rewrittenUrlData->locale); } - foreach($rewrittenUrlData->otherParameters as $parameter => $value) { + foreach ($rewrittenUrlData->otherParameters as $parameter => $value) { $request->query->set($parameter, $value); } @@ -216,4 +215,4 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface { Redirect::exec($url, $status); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index 3f60db08f..742bd648b 100755 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -93,12 +93,12 @@ class SecurityContext /** * Check if a user has at least one of the required roles * - * @param UserInterface $user the user - * @param array $roles the roles - * @return boolean true if the user has the required role, false otherwise + * @param UserInterface $user the user + * @param array $roles the roles + * @return boolean true if the user has the required role, false otherwise */ - final public function hasRequiredRole($user, array $roles) { - + final public function hasRequiredRole($user, array $roles) + { if ($user != null) { // Check if user's roles matches required roles $userRoles = $user->getRoles(); @@ -208,4 +208,4 @@ class SecurityContext { $this->getSession()->clearAdminUser(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php index cd7f06ac8..a3323ae2a 100755 --- a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php +++ b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php @@ -29,8 +29,6 @@ use Assetic\Filter; use Assetic\Factory\AssetFactory; use Assetic\Factory\Worker\CacheBustingWorker; use Assetic\AssetWriter; -use Assetic\Asset\AssetCache; -use Assetic\Cache\FilesystemCache; /** * This class is a simple helper for generating assets using Assetic. @@ -139,8 +137,7 @@ class AsseticHelper foreach ($filter_list as $filter) { if ('?' != $filter[0]) { $asset->ensureFilter($fm->get($filter)); - } - elseif (!$debug) { + } elseif (!$debug) { $asset->ensureFilter($fm->get(substr($filter, 1))); } } diff --git a/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php b/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php index 792389b1c..35077f5c4 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php @@ -24,10 +24,8 @@ namespace Thelia\Core\Template\Element; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Propel\Runtime\ActiveQuery\ModelCriteria; -use Thelia\Core\Security\SecurityContext; use Thelia\Model\Tools\ModelCriteriaTools; /** @@ -55,10 +53,10 @@ abstract class BaseI18nLoop extends BaseLoop /** * Setup ModelCriteria for proper i18n processing * - * @param ModelCriteria $search the Propel Criteria to configure - * @param array $columns the i18n columns - * @param string $foreignTable the specified table (default to criteria table) - * @param string $foreignKey the foreign key in this table (default to criteria table) + * @param ModelCriteria $search the Propel Criteria to configure + * @param array $columns the i18n columns + * @param string $foreignTable the specified table (default to criteria table) + * @param string $foreignKey the foreign key in this table (default to criteria table) * @param bool $forceReturn * * @return mixed the locale @@ -66,6 +64,7 @@ abstract class BaseI18nLoop extends BaseLoop protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false) { /* manage translations */ + return ModelCriteriaTools::getI18n( $this->getBackend_context(), $this->getLang(), @@ -77,4 +76,4 @@ abstract class BaseI18nLoop extends BaseLoop $forceReturn ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 209973112..254560453 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -29,7 +29,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Core\Security\SecurityContext; -use Thelia\Model\Tools\ModelCriteriaTools; /** * diff --git a/core/lib/Thelia/Core/Template/Element/LoopResult.php b/core/lib/Thelia/Core/Template/Element/LoopResult.php index 169fdb4f7..f86ab203d 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResult.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResult.php @@ -37,7 +37,7 @@ class LoopResult implements \Iterator public function __construct($modelCollection = null) { $this->position = 0; - if($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) { + if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) { $this->modelCollection = $modelCollection; } } diff --git a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php index cfea52d8f..15bb287b1 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php @@ -38,14 +38,14 @@ class LoopResultRow public function __construct($loopResult = null, $model = null, $versionable = false, $timestampable = false, $countable = true) { - if($model instanceof ActiveRecordInterface) { + if ($model instanceof ActiveRecordInterface) { $this->model = $model; $this->versionable = $versionable; $this->timestampable = $timestampable; } - if($loopResult instanceof LoopResult) { + if ($loopResult instanceof LoopResult) { $this->loopResult = $loopResult; $this->countable = $countable; @@ -95,17 +95,17 @@ class LoopResultRow protected function assignDefaultOutputs() { - if(true === $this->versionable) { - foreach($this->getVersionOutputs() as $output) { + if (true === $this->versionable) { + foreach ($this->getVersionOutputs() as $output) { $this->set($output[0], $this->model->$output[1]()); } } - if(true === $this->timestampable) { - foreach($this->getTimestampOutputs() as $output) { + if (true === $this->timestampable) { + foreach ($this->getTimestampOutputs() as $output) { $this->set($output[0], $this->model->$output[1]()); } } - if(true === $this->countable) { + if (true === $this->countable) { $this->set('LOOP_COUNT', 1 + $this->loopResult->getCount()); $this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count()); } diff --git a/core/lib/Thelia/Core/Template/Loop/Address.php b/core/lib/Thelia/Core/Template/Loop/Address.php index 3ac9370f8..831a8dca1 100755 --- a/core/lib/Thelia/Core/Template/Loop/Address.php +++ b/core/lib/Thelia/Core/Template/Loop/Address.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Collection\ObjectCollection; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -48,7 +47,7 @@ use Thelia\Type; class Address extends BaseLoop { public $timestampable = true; - + /** * @return ArgumentCollection */ @@ -99,7 +98,6 @@ class Address extends BaseLoop $default = $this->getDefault(); - if ($default === true) { $search->filterByIsDefault(1, Criteria::EQUAL); } diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 5c73d0602..253c48da7 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -77,15 +77,15 @@ class AssociatedContent extends Content $product = $this->getProduct(); $category = $this->getCategory(); - if($product === null && $category === null) { + if ($product === null && $category === null) { throw new \InvalidArgumentException('You have to provide either `product` or `category` argument in associated_content loop'); } - if($product !== null) { + if ($product !== null) { $search = ProductAssociatedContentQuery::create(); $search->filterByProductId($product, Criteria::EQUAL); - } elseif($category !== null) { + } elseif ($category !== null) { $search = CategoryAssociatedContentQuery::create(); $search->filterByCategoryId($category, Criteria::EQUAL); diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index ecdc551d2..5ab4a2b4e 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -24,21 +24,16 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\Join; use Thelia\Core\Template\Element\BaseI18nLoop; 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\Argument; -use Thelia\Log\Tlog; - -use Thelia\Model\Base\LangQuery; use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\AttributeQuery; -use Thelia\Model\ConfigQuery; use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -113,17 +108,17 @@ class Attribute extends BaseI18nLoop $product = $this->getProduct(); $category = $this->getCategory(); - if(null !== $product) { + if (null !== $product) { $productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData(); - if(null === $category) { + if (null === $category) { $category = $productCategories; } else { $category = array_merge($category, $productCategories); } } - if(null !== $category) { + if (null !== $category) { $search->filterByCategory( CategoryQuery::create()->filterById($category)->find(), Criteria::IN @@ -132,7 +127,7 @@ class Attribute extends BaseI18nLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); @@ -170,4 +165,4 @@ class Attribute extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php index ca4618f53..1d94e889e 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -24,17 +24,14 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\Join; use Thelia\Core\Template\Element\BaseI18nLoop; 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\Argument; -use Thelia\Log\Tlog; use Thelia\Model\Base\AttributeAvQuery; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -95,13 +92,13 @@ class AttributeAvailability extends BaseI18nLoop $attribute = $this->getAttribute(); - if(null !== $attribute) { + if (null !== $attribute) { $search->filterByAttributeId($attribute, Criteria::IN); } $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); @@ -139,4 +136,4 @@ class AttributeAvailability extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php index 78cf33e21..f2af0887d 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeCombination.php @@ -24,19 +24,16 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\Join; use Thelia\Core\Template\Element\BaseI18nLoop; 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\Argument; -use Thelia\Log\Tlog; use Thelia\Model\Base\AttributeCombinationQuery; use Thelia\Model\Map\AttributeAvTableMap; use Thelia\Model\Map\AttributeTableMap; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -100,7 +97,7 @@ class AttributeCombination extends BaseI18nLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'); @@ -134,4 +131,4 @@ class AttributeCombination extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php index 3b4e54be6..2aaa173dc 100644 --- a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php +++ b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php @@ -28,13 +28,13 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\ModuleQuery; - /** * Class Delivery * @package Thelia\Core\Template\Loop * @author Manuel Raynaud */ -class BaseSpecificModule extends BaseI18nLoop { +class BaseSpecificModule extends BaseI18nLoop +{ public $timestampable = true; /** @@ -93,12 +93,10 @@ class BaseSpecificModule extends BaseI18nLoop { { $search = ModuleQuery::create(); - if(null !== $id = $this->getId()) - { + if (null !== $id = $this->getId()) { $search->filterById($id); } - if (null !== $exclude = $this->getExclude()) { $search->filterById($exclude, Criteria::NOT_IN); } @@ -106,4 +104,4 @@ class BaseSpecificModule extends BaseI18nLoop { return $search; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 8e4d78683..f65afdf40 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -72,8 +72,6 @@ class Cart extends BaseLoop public function exec(&$pagination) { - - $cart = $this->getCart($this->request); $cartItems = $cart->getCartItems(); $result = new LoopResult($cartItems); diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 68ae33507..91cb90b0a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Log\Tlog; use Thelia\Model\CategoryQuery; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; @@ -101,7 +99,7 @@ class Category extends BaseI18nLoop /* manage translations */ $locale = $this->configureI18nProcessing($search); - $id = $this->getId(); + $id = $this->getId(); if (!is_null($id)) { $search->filterById($id, Criteria::IN); @@ -113,8 +111,7 @@ class Category extends BaseI18nLoop $search->filterByParent($parent); } - - $current = $this->getCurrent(); + $current = $this->getCurrent(); if ($current === true) { $search->filterById($this->request->get("category_id")); @@ -122,7 +119,6 @@ class Category extends BaseI18nLoop $search->filterById($this->request->get("category_id"), Criteria::NOT_IN); } - $exclude = $this->getExclude(); if (!is_null($exclude)) { @@ -130,11 +126,11 @@ class Category extends BaseI18nLoop } if ($this->getVisible() != BooleanOrBothType::ANY) - $search->filterByVisible($this->getVisible() ? 1 : 0); + $search->filterByVisible($this->getVisible() ? 1 : 0); $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); @@ -179,23 +175,23 @@ class Category extends BaseI18nLoop $loopResultRow = new LoopResultRow($loopResult, $category, $this->versionable, $this->timestampable, $this->countable); $loopResultRow - ->set("ID", $category->getId()) + ->set("ID", $category->getId()) ->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED')) ->set("LOCALE",$locale) - ->set("TITLE", $category->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("PARENT", $category->getParent()) - ->set("URL", $category->getUrl($locale)) - ->set("PRODUCT_COUNT", $category->countChild()) - ->set("VISIBLE", $category->getVisible() ? "1" : "0") - ->set("POSITION", $category->getPosition()) - ; + ->set("TITLE", $category->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("PARENT", $category->getParent()) + ->set("URL", $category->getUrl($locale)) + ->set("PRODUCT_COUNT", $category->countChild()) + ->set("VISIBLE", $category->getVisible() ? "1" : "0") + ->set("POSITION", $category->getPosition()) + ; $loopResult->addRow($loopResultRow); } return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Config.php b/core/lib/Thelia/Core/Template/Loop/Config.php index 8e03de636..78f53489b 100644 --- a/core/lib/Thelia/Core/Template/Loop/Config.php +++ b/core/lib/Thelia/Core/Template/Loop/Config.php @@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\LangQuery; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\ConfigQuery; use Thelia\Type\BooleanOrBothType; @@ -114,7 +113,7 @@ class Config extends BaseI18nLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case 'id': $search->orderById(Criteria::ASC); diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index baec33344..2d849b218 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -35,7 +35,6 @@ use Thelia\Model\FolderQuery; use Thelia\Model\Map\ContentTableMap; use Thelia\Model\ContentFolderQuery; use Thelia\Model\ContentQuery; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index 0aeb62b15..f14b97efc 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\CountryQuery; -use Thelia\Model\ConfigQuery; /** * diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 9b3ebb615..2fb49e8b9 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -34,13 +34,9 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Base\CategoryQuery; -use Thelia\Model\ConfigQuery; use Thelia\Model\CouponQuery; use Thelia\Model\Coupon as MCoupon; -use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Type; -use Thelia\Type\BooleanOrBothType; /** * Created by JetBrains PhpStorm. @@ -95,7 +91,6 @@ class Coupon extends BaseI18nLoop /** @var Lang $lang */ $lang = $request->getSession()->getLang(); - /** @var MCoupon $coupon */ foreach ($coupons as $coupon) { $loopResultRow = new LoopResultRow(); diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php index b7261ba45..a1f936300 100755 --- a/core/lib/Thelia/Core/Template/Loop/Currency.php +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\CurrencyQuery; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type\EnumListType; @@ -109,7 +108,7 @@ class Currency extends BaseI18nLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case 'id': $search->orderById(Criteria::ASC); diff --git a/core/lib/Thelia/Core/Template/Loop/Customer.php b/core/lib/Thelia/Core/Template/Loop/Customer.php index 9861be29a..e0ce92c76 100755 --- a/core/lib/Thelia/Core/Template/Loop/Customer.php +++ b/core/lib/Thelia/Core/Template/Loop/Customer.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Collection\ObjectCollection; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -48,7 +47,7 @@ use Thelia\Type; class Customer extends BaseLoop { public $timestampable = true; - + /** * @return ArgumentCollection */ diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index 7ef46eedc..a0e9ebb7a 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -26,7 +26,6 @@ use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\Argument; - /** * Class Delivery * @package Thelia\Core\Template\Loop @@ -60,7 +59,7 @@ class Delivery extends BaseSpecificModule $loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable); $moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace()); - if($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) { + if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) { throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode())); } $moduleInstance = $moduleReflection->newInstance(); @@ -82,4 +81,4 @@ class Delivery extends BaseSpecificModule return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 14b7afaf5..7f412e4b0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\FeatureQuery; -use Thelia\Model\ConfigQuery; use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Type\TypeCollection; use Thelia\Type; diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index 38bee46f0..093cea24a 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\Base\FeatureAvQuery; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 998dfe4e0..30a8dcf27 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -24,19 +24,15 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\Join; use Thelia\Core\Template\Element\BaseI18nLoop; 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\Argument; -use Thelia\Log\Tlog; use Thelia\Model\Base\FeatureProductQuery; -use Thelia\Model\ConfigQuery; use Thelia\Model\Map\FeatureAvTableMap; -use Thelia\Model\Map\FeatureProductTableMap; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -107,18 +103,18 @@ class FeatureValue extends BaseI18nLoop } $excludeFeatureAvailability = $this->getExclude_feature_availability(); - if($excludeFeatureAvailability == true) { + if ($excludeFeatureAvailability == true) { $search->filterByFeatureAvId(null, Criteria::NULL); } $excludeDefaultValues = $this->getExclude_personal_values(); - if($excludeDefaultValues == true) { + if ($excludeDefaultValues == true) { $search->filterByByDefault(null, Criteria::NULL); } $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE'); @@ -157,4 +153,4 @@ class FeatureValue extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index ca07ffa02..cfd54db4f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Log\Tlog; use Thelia\Model\FolderQuery; -use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; @@ -83,7 +81,7 @@ class Folder extends BaseI18nLoop /* manage translations */ $locale = $this->configureI18nProcessing($search); - $id = $this->getId(); + $id = $this->getId(); if (!is_null($id)) { $search->filterById($id, Criteria::IN); @@ -95,8 +93,7 @@ class Folder extends BaseI18nLoop $search->filterByParent($parent); } - - $current = $this->getCurrent(); + $current = $this->getCurrent(); if ($current === true) { $search->filterById($this->request->get("folder_id")); @@ -104,7 +101,6 @@ class Folder extends BaseI18nLoop $search->filterById($this->request->get("folder_id"), Criteria::NOT_IN); } - $exclude = $this->getExclude(); if (!is_null($exclude)) { @@ -117,7 +113,7 @@ class Folder extends BaseI18nLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); @@ -157,23 +153,23 @@ class Folder extends BaseI18nLoop $loopResultRow = new LoopResultRow($loopResult, $folder, $this->versionable, $this->timestampable, $this->countable); $loopResultRow - ->set("ID", $folder->getId()) + ->set("ID", $folder->getId()) ->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED')) ->set("LOCALE",$locale) ->set("TITLE",$folder->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("PARENT", $folder->getParent()) + ->set("PARENT", $folder->getParent()) ->set("URL", $folder->getUrl($locale)) - ->set("CONTENT_COUNT", $folder->countChild()) - ->set("VISIBLE", $folder->getVisible() ? "1" : "0") - ->set("POSITION", $folder->getPosition()) - ; + ->set("CONTENT_COUNT", $folder->countChild()) + ->set("VISIBLE", $folder->getVisible() ? "1" : "0") + ->set("POSITION", $folder->getPosition()) + ; $loopResult->addRow($loopResultRow); } return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index 793b5c03e..c7714731b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -25,8 +25,6 @@ namespace Thelia\Core\Template\Loop; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Event\ImageEvent; -use Thelia\Model\CategoryImageQuery; -use Thelia\Model\ProductImageQuery; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Type\TypeCollection; @@ -99,7 +97,7 @@ class Image extends BaseI18nLoop ); // Add possible image sources - foreach($this->possible_sources as $source) { + foreach ($this->possible_sources as $source) { $collection->addArgument(Argument::createIntTypeArgument($source)); } @@ -109,12 +107,12 @@ class Image extends BaseI18nLoop /** * Dynamically create the search query, and set the proper filter and order * - * @param string $source a valid source identifier (@see $possible_sources) - * @param int $object_id the source object ID + * @param string $source a valid source identifier (@see $possible_sources) + * @param int $object_id the source object ID * @return ModelCriteria the propel Query object */ - protected function createSearchQuery($source, $object_id) { - + protected function createSearchQuery($source, $object_id) + { $object = ucfirst($source); $queryClass = sprintf("\Thelia\Model\%sImageQuery", $object); @@ -159,12 +157,12 @@ class Image extends BaseI18nLoop /** * Dynamically create the search query, and set the proper filter and order * - * @param string $object_type (returned) the a valid source identifier (@see $possible_sources) - * @param string $object_id (returned) the ID of the source object + * @param string $object_type (returned) the a valid source identifier (@see $possible_sources) + * @param string $object_id (returned) the ID of the source object * @return ModelCriteria the propel Query object */ - protected function getSearchQuery(&$object_type, &$object_id) { - + protected function getSearchQuery(&$object_type, &$object_id) + { $search = null; // Check form source="product" source_id="123" style arguments @@ -184,10 +182,9 @@ class Image extends BaseI18nLoop $object_type = $source; $object_id = $source_id; - } - else { + } else { // Check for product="id" folder="id", etc. style arguments - foreach($this->possible_sources as $source) { + foreach ($this->possible_sources as $source) { $argValue = intval($this->getArgValue($source)); @@ -247,7 +244,7 @@ class Image extends BaseI18nLoop $effects = explode(',', $effects); } - switch($this->getResizeMode()) { + switch ($this->getResizeMode()) { case 'crop' : $resize_mode = \Thelia\Action\Image::EXACT_RATIO_WITH_CROP; break; @@ -316,8 +313,7 @@ class Image extends BaseI18nLoop ; $loopResult->addRow($loopResultRow); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Ignore the result and log an error Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args); } @@ -325,4 +321,4 @@ class Image extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Message.php b/core/lib/Thelia/Core/Template/Loop/Message.php index ad6bd29aa..bea662572 100644 --- a/core/lib/Thelia/Core/Template/Loop/Message.php +++ b/core/lib/Thelia/Core/Template/Loop/Message.php @@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\LangQuery; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\MessageQuery; use Thelia\Type\BooleanOrBothType; diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index b7a7c13fe..f6ab423ab 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -31,11 +31,10 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Log\Tlog; use Thelia\Model\CategoryQuery; use Thelia\Model\CountryQuery; -use Thelia\Model\Map\FeatureProductTableMap; +use Thelia\Model\CurrencyQuery; use Thelia\Model\Map\ProductPriceTableMap; use Thelia\Model\Map\ProductSaleElementsTableMap; use Thelia\Model\Map\ProductTableMap; @@ -54,8 +53,6 @@ use Thelia\Type\BooleanOrBothType; * Class Product * @package Thelia\Core\Template\Loop * @author Etienne Roudeix - * - * @todo : manage currency in price filter */ class Product extends BaseI18nLoop { @@ -87,6 +84,7 @@ class Product extends BaseI18nLoop Argument::createBooleanTypeArgument('current_category'), Argument::createIntTypeArgument('depth', 1), Argument::createBooleanOrBothTypeArgument('visible', 1), + Argument::createIntTypeArgument('currency'), new Argument( 'order', new TypeCollection( @@ -137,6 +135,19 @@ class Product extends BaseI18nLoop */ public function exec(&$pagination) { + $currencyId = $this->getCurrency(); + if(null !== $currencyId) { + $currency = CurrencyQuery::create()->findOneById($currencyId); + if(null === $currency) { + throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); + } + } else { + $currency = $this->request->getSession()->getCurrency(); + } + + $defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1); + $defaultCurrencySuffix = '_default_currency'; + $search = ProductQuery::create(); /* manage translations */ @@ -144,7 +155,7 @@ class Product extends BaseI18nLoop $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); $isPSELeftJoinList = array(); - $isProductPriceLeftJoinList = array(); + $isProductPriceFirstLeftJoin = array(); $id = $this->getId(); @@ -165,8 +176,8 @@ class Product extends BaseI18nLoop $depth = $this->getDepth(); - if(null !== $depth) { - foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) { + if (null !== $depth) { + foreach (CategoryQuery::findAllChild($category, $depth) as $subCategory) { $categories->prepend($subCategory); } } @@ -184,7 +195,7 @@ class Product extends BaseI18nLoop $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1') ->where('NOT ISNULL(`is_new`.ID)'); - } else if($new === false) { + } elseif ($new === false) { $isPSELeftJoinList[] = 'is_new'; $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0') @@ -198,7 +209,7 @@ class Product extends BaseI18nLoop $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) ->where('`is_promo`.PROMO' . Criteria::EQUAL . '1') ->where('NOT ISNULL(`is_promo`.ID)'); - } else if($promo === false) { + } elseif ($promo === false) { $isPSELeftJoinList[] = 'is_promo'; $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) ->where('`is_promo`.PROMO' . Criteria::EQUAL . '0') @@ -232,68 +243,111 @@ class Product extends BaseI18nLoop ->where('NOT ISNULL(`is_max_weight`.ID)'); } - $min_price = $this->getMin_price(); - - if(null !== $min_price) { - $isPSELeftJoinList[] = 'is_min_price'; - $isProductPriceLeftJoinList['is_min_price'] = 'min_price_data'; - $minPriceJoin = new Join(); - $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data'); - $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); - - $search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN) - ->addJoinObject($minPriceJoin) - ->condition('in_promo', '`is_min_price`.promo'. Criteria::EQUAL .'1') - ->condition('not_in_promo', '`is_min_price`.promo'. Criteria::NOT_EQUAL .'1') - ->condition('min_promo_price', '`min_price_data`.promo_price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) - ->condition('min_price', '`min_price_data`.price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR) - ->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_min_price') - ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') - ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); - } - - $max_price = $this->getMax_price(); - - if(null !== $max_price) { - $isPSELeftJoinList[] = 'is_max_price'; - $isProductPriceLeftJoinList['is_max_price'] = 'max_price_data'; - $minPriceJoin = new Join(); - $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data'); - $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); - - $search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN) - ->addJoinObject($minPriceJoin) - ->condition('in_promo', '`is_max_price`.promo'. Criteria::EQUAL .'1') - ->condition('not_in_promo', '`is_max_price`.promo'. Criteria::NOT_EQUAL .'1') - ->condition('min_promo_price', '`max_price_data`.promo_price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) - ->condition('max_price', '`max_price_data`.price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR) - ->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_max_price') - ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') - ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); - } - - if( $attributeNonStrictMatch != '*' ) { - if($attributeNonStrictMatch == 'none') { + if ($attributeNonStrictMatch != '*') { + if ($attributeNonStrictMatch == 'none') { $actuallyUsedAttributeNonStrictMatchList = $isPSELeftJoinList; } else { $actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($isPSELeftJoinList, $attributeNonStrictMatch)); } - foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) { + foreach ($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) { if($key == 0) continue; $search->where('`' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID'); } } + $min_price = $this->getMin_price(); + + if (null !== $min_price) { + + if (false === ConfigQuery::useTaxFreeAmounts()) { + // @todo + } + + $isPSELeftJoinList[] = 'is_min_price'; + $isProductPriceFirstLeftJoin = array('is_min_price', 'min_price_data'); + + $minPriceJoin = new Join(); + $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data'); + $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN) + ->addJoinObject($minPriceJoin, 'is_min_price_join') + ->addJoinCondition('is_min_price_join', '`min_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT); + + if ($defaultCurrency->getId() != $currency->getId()) { + $minPriceJoinDefaultCurrency = new Join(); + $minPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data' . $defaultCurrencySuffix); + $minPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN); + + $search->addJoinObject($minPriceJoinDefaultCurrency, 'is_min_price_join' . $defaultCurrencySuffix) + ->addJoinCondition('is_min_price_join' . $defaultCurrencySuffix, '`min_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT); + + /** + * In propel we trust : $currency->getRate() always returns a float. + * Or maybe not : rate value is checked as a float in overloaded getRate method. + */ + $MinPriceToCompareAsSQL = 'CASE WHEN ISNULL(CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END) THEN + CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `min_price_data' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . ' + ELSE + CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END + END'; + } else { + $MinPriceToCompareAsSQL = 'CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END'; + } + + $search->where('ROUND(' . $MinPriceToCompareAsSQL . ', 2)>=?', $min_price, \PDO::PARAM_STR); + } + + $max_price = $this->getMax_price(); + + if (null !== $max_price) { + $isPSELeftJoinList[] = 'is_max_price'; + $isProductPriceFirstLeftJoin = array('is_max_price', 'max_price_data'); + + $maxPriceJoin = new Join(); + $maxPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data'); + $maxPriceJoin->setJoinType(Criteria::LEFT_JOIN); + + $search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN) + ->addJoinObject($maxPriceJoin, 'is_max_price_join') + ->addJoinCondition('is_max_price_join', '`max_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT); + + if ($defaultCurrency->getId() != $currency->getId()) { + $maxPriceJoinDefaultCurrency = new Join(); + $maxPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data' . $defaultCurrencySuffix); + $maxPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN); + + $search->addJoinObject($maxPriceJoinDefaultCurrency, 'is_max_price_join' . $defaultCurrencySuffix) + ->addJoinCondition('is_max_price_join' . $defaultCurrencySuffix, '`max_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT); + + /** + * In propel we trust : $currency->getRate() always returns a float. + * Or maybe not : rate value is checked as a float in overloaded getRate method. + */ + $MaxPriceToCompareAsSQL = 'CASE WHEN ISNULL(CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END) THEN + CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `max_price_data' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . ' + ELSE + CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END + END'; + + } else { + $MaxPriceToCompareAsSQL = 'CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END'; + } + + $search->where('ROUND(' . $MaxPriceToCompareAsSQL . ', 2)<=?', $max_price, \PDO::PARAM_STR); + } + /* * for ordering and outputs, the product will be : * - new if at least one the criteria matching PSE is new * - in promo if at least one the criteria matching PSE is in promo */ - if(count($isProductPriceLeftJoinList) == 0) { - if(count($isPSELeftJoinList) == 0) { + /* if we don't have any join yet, let's make a global one */ + if (empty($isProductPriceFirstLeftJoin)) { + if (count($isPSELeftJoinList) == 0) { $joiningTable = "global"; $isPSELeftJoinList[] = $joiningTable; $search->joinProductSaleElements('global', Criteria::LEFT_JOIN); @@ -301,13 +355,22 @@ class Product extends BaseI18nLoop $joiningTable = $isPSELeftJoinList[0]; } - $isProductPriceLeftJoinList[$joiningTable] = 'global_price_data'; + $isProductPriceFirstLeftJoin = array($joiningTable, 'global_price_data'); - $minPriceJoin = new Join(); - $minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data'); - $minPriceJoin->setJoinType(Criteria::LEFT_JOIN); + $globalPriceJoin = new Join(); + $globalPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data'); + $globalPriceJoin->setJoinType(Criteria::LEFT_JOIN); - $search->addJoinObject($minPriceJoin); + $search->addJoinObject($globalPriceJoin, 'global_price_join') + ->addJoinCondition('global_price_join', '`global_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT); + + if ($defaultCurrency->getId() != $currency->getId()) { + $globalPriceJoinDefaultCurrency = new Join(); + $globalPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data' . $defaultCurrencySuffix); + $globalPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN); + $search->addJoinObject($globalPriceJoinDefaultCurrency, 'global_price_join' . $defaultCurrencySuffix) + ->addJoinCondition('global_price_join' . $defaultCurrencySuffix, '`global_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT); + } } /* @@ -326,25 +389,34 @@ class Product extends BaseI18nLoop */ $booleanMatchedPromoList = array(); $booleanMatchedNewnessList = array(); - foreach($isPSELeftJoinList as $isPSELeftJoin) { + foreach ($isPSELeftJoinList as $isPSELeftJoin) { $booleanMatchedPromoList[] = '`' . $isPSELeftJoin . '`.PROMO'; $booleanMatchedNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS'; } - $booleanMatchedPriceList = array(); - foreach($isProductPriceLeftJoinList as $pSE => $isProductPriceLeftJoin) { - $booleanMatchedPriceList[] = 'CASE WHEN `' . $pSE . '`.PROMO=1 THEN `' . $isProductPriceLeftJoin . '`.PROMO_PRICE ELSE `' . $isProductPriceLeftJoin . '`.PRICE END'; - } $search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPromoList) . '), 2)', 'main_product_is_promo'); $search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedNewnessList) . '), 2)', 'main_product_is_new'); - $search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_highest_price'); - $search->withColumn('ROUND(MIN(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_lowest_price'); + $booleanMatchedPrice = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . '`.PRICE END'; + $booleanMatchedPriceDefaultCurrency = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PRICE END'; + + if ($defaultCurrency->getId() != $currency->getId()) { + /** + * In propel we trust : $currency->getRate() always returns a float. + * Or maybe not : rate value is checked as a float in overloaded getRate method. + */ + $priceToCompareAsSQL = 'CASE WHEN ISNULL(' . $booleanMatchedPrice .') THEN ' . $booleanMatchedPriceDefaultCurrency . ' * ' . $currency->getRate() . ' ELSE ' . $booleanMatchedPrice . ' END'; + } else { + $priceToCompareAsSQL = $booleanMatchedPrice; + } + + $search->withColumn('ROUND(MAX(' . $priceToCompareAsSQL . '), 2)', 'real_highest_price'); + $search->withColumn('ROUND(MIN(' . $priceToCompareAsSQL . '), 2)', 'real_lowest_price'); $current = $this->getCurrent(); if ($current === true) { $search->filterById($this->request->get("product_id")); - } elseif($current === false) { + } elseif ($current === false) { $search->filterById($this->request->get("product_id"), Criteria::NOT_IN); } @@ -361,7 +433,7 @@ class Product extends BaseI18nLoop )->find(), Criteria::IN ); - } elseif($current_category === false) { + } elseif ($current_category === false) { $search->filterByCategory( CategoryQuery::create()->filterByProduct( ProductCategoryQuery::create()->filterByProductId( @@ -395,9 +467,9 @@ class Product extends BaseI18nLoop $feature_availability = $this->getFeature_availability(); - if(null !== $feature_availability) { - foreach($feature_availability as $feature => $feature_choice) { - foreach($feature_choice['values'] as $feature_av) { + if (null !== $feature_availability) { + foreach ($feature_availability as $feature => $feature_choice) { + foreach ($feature_choice['values'] as $feature_av) { $featureAlias = 'fa_' . $feature; if($feature_av != '*') $featureAlias .= '_' . $feature_av; @@ -409,7 +481,7 @@ class Product extends BaseI18nLoop /* format for mysql */ $sqlWhereString = $feature_choice['expression']; - if($sqlWhereString == '*') { + if ($sqlWhereString == '*') { $sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)'; } else { $sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString); @@ -423,9 +495,9 @@ class Product extends BaseI18nLoop $feature_values = $this->getFeature_values(); - if(null !== $feature_values) { - foreach($feature_values as $feature => $feature_choice) { - foreach($feature_choice['values'] as $feature_value) { + if (null !== $feature_values) { + foreach ($feature_values as $feature => $feature_choice) { + foreach ($feature_choice['values'] as $feature_value) { $featureAlias = 'fv_' . $feature; if($feature_value != '*') $featureAlias .= '_' . $feature_value; @@ -437,7 +509,7 @@ class Product extends BaseI18nLoop /* format for mysql */ $sqlWhereString = $feature_choice['expression']; - if($sqlWhereString == '*') { + if ($sqlWhereString == '*') { $sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)'; } else { $sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString); @@ -453,7 +525,7 @@ class Product extends BaseI18nLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); @@ -489,7 +561,7 @@ class Product extends BaseI18nLoop case "given_id": if(null === $id) throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); - foreach($id as $singleId) { + foreach ($id as $singleId) { $givenIdMatched = 'given_id_matched_' . $singleId; $search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched); $search->orderBy($givenIdMatched, Criteria::DESC); diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index ec4c73230..f1bbb198d 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -24,18 +24,16 @@ namespace Thelia\Core\Template\Loop; 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\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Log\Tlog; use Thelia\Model\Base\ProductSaleElementsQuery; -use Thelia\Model\ConfigQuery; use Thelia\Model\CountryQuery; +use Thelia\Model\CurrencyQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -52,7 +50,7 @@ use Thelia\Type; class ProductSaleElements extends BaseLoop { public $timestampable = true; - + /** * @return ArgumentCollection */ @@ -81,6 +79,7 @@ class ProductSaleElements extends BaseLoop * @param $pagination * * @return \Thelia\Core\Template\Element\LoopResult + * @throws \InvalidArgumentException */ public function exec(&$pagination) { @@ -92,24 +91,39 @@ class ProductSaleElements extends BaseLoop $orders = $this->getOrder(); - foreach($orders as $order) { + foreach ($orders as $order) { switch ($order) { - case "alpha": - //$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + case "min_price": + $search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC); break; - case "alpha_reverse": - //$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE); + case "max_price": + $search->addDescendingOrderByColumn('real_lowest_price'); break; - case "attribute": - //$search->orderByPosition(Criteria::ASC); + case "promo": + $search->addDescendingOrderByColumn('main_product_is_promo'); break; - case "attribute_reverse": - //$search->orderByPosition(Criteria::DESC); + case "new": + $search->addDescendingOrderByColumn('main_product_is_new'); break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); } } - $currency = $this->getCurrency(); + $currencyId = $this->getCurrency(); + if (null !== $currencyId) { + $currency = CurrencyQuery::create()->findOneById($currencyId); + if (null === $currency) { + throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); + } + } else { + $currency = $this->request->getSession()->getCurrency(); + } + + $defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1); + $defaultCurrencySuffix = '_default_currency'; $search->joinProductPrice('price', Criteria::INNER_JOIN); //->addJoinCondition('price', ''); @@ -153,4 +167,4 @@ class ProductSaleElements extends BaseLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php index 4243f83f1..3cd59d665 100755 --- a/core/lib/Thelia/Core/Template/Loop/Title.php +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\CustomerTitleQuery; -use Thelia\Model\ConfigQuery; /** * diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php index 90079abf5..9e3fde416 100755 --- a/core/lib/Thelia/Core/Template/ParserContext.php +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Template; use Thelia\Model\ConfigQuery; use Thelia\Core\HttpFoundation\Request; -use Thelia\Tools\URL; use Thelia\Form\BaseForm; /** * The parser context is an application-wide context, which stores var-value pairs. diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index f19eded95..7ad557256 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -39,9 +39,9 @@ class SmartyAssetsManager /** * Creates a new SmartyAssetsManager instance * - * @param string $web_root the disk path to the web root - * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated - * @param boolean $developmentMode true / false. If true, assets are not cached, and always generated. + * @param string $web_root the disk path to the web root + * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated + * @param boolean $developmentMode true / false. If true, assets are not cached, and always generated. */ public function __construct($web_root, $path_relative_to_web_root, $developmentMode) { diff --git a/core/lib/Thelia/Core/Template/Smarty/Exception/SmartyPluginException.php b/core/lib/Thelia/Core/Template/Smarty/Exception/SmartyPluginException.php index fdaf93608..77efa2d17 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Exception/SmartyPluginException.php +++ b/core/lib/Thelia/Core/Template/Smarty/Exception/SmartyPluginException.php @@ -23,11 +23,10 @@ namespace Thelia\Core\Template\Smarty\Exception; - /** * Class SmartyPluginException * @package Thelia\Core\Template\Smarty\Exception * @author Manuel Raynaud */ class SmartyPluginException extends \SmartyException -{} \ No newline at end of file +{} diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php index bb9770520..5608fc168 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -26,7 +26,6 @@ namespace Thelia\Core\Template\Smarty\Plugins; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Tools\URL; -use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Security\SecurityContext; /** @@ -43,7 +42,8 @@ class AdminUtilities extends AbstractSmartyPlugin $this->securityContext = $securityContext; } - public function generatePositionChangeBlock($params, &$smarty) { + public function generatePositionChangeBlock($params, &$smarty) + { // The required permissions $permission = $this->getParam($params, 'permission'); @@ -77,13 +77,11 @@ class AdminUtilities extends AbstractSmartyPlugin $position, URL::getInstance()->absoluteUrl($path, array('mode' => 'down', $url_parameter => $id)) ); - } - else { + } else { return $position; } } - /** * Generates the link of a sortable column header * @@ -111,12 +109,10 @@ class AdminUtilities extends AbstractSmartyPlugin if ($current_order == $order) { $icon = 'up'; $order_change = $reverse_order; - } - else if ($current_order == $reverse_order) { + } elseif ($current_order == $reverse_order) { $icon = 'down'; $order_change = $order; - } - else { + } else { $order_change = $order; } @@ -128,7 +124,6 @@ class AdminUtilities extends AbstractSmartyPlugin return sprintf('%s%s', $output, URL::getInstance()->absoluteUrl($path, array('order' => $order_change)), $label); } - /** * Define the various smarty plugins handled by this class * @@ -141,4 +136,4 @@ class AdminUtilities extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'admin_position_block' , $this, 'generatePositionChangeBlock'), ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index fded12c0e..6f83bdcfd 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -85,7 +85,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin { $productId = $this->request->get('product_id'); - if($productId !== null) { + if ($productId !== null) { $search = ProductQuery::create() ->filterById($productId); @@ -98,7 +98,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin { $categoryId = $this->request->get('category_id'); - if($categoryId !== null) { + if ($categoryId !== null) { $search = CategoryQuery::create() ->filterById($categoryId); @@ -111,7 +111,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin { $contentId = $this->request->get('content_id'); - if($contentId !== null) { + if ($contentId !== null) { $search = ContentQuery::create() ->filterById($contentId); @@ -124,7 +124,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin { $folderId = $this->request->get('folder_id'); - if($folderId !== null) { + if ($folderId !== null) { $search = FolderQuery::create() ->filterById($folderId); @@ -175,7 +175,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') { $lang = $this->getNormalizedParam($params, array('lang')); - if($lang === null) { + if ($lang === null) { $lang = $this->request->getSession()->getLang()->getId(); } @@ -193,7 +193,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin $data = $search->findOne(); $noGetterData = array(); - foreach($columns as $column) { + foreach ($columns as $column) { $noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column); } @@ -218,7 +218,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin if (null != $data) { $keyAttribute = strtoupper($attribute); - if(array_key_exists($keyAttribute, $noGetterData)) { + if (array_key_exists($keyAttribute, $noGetterData)) { return $noGetterData[$keyAttribute]; } @@ -226,7 +226,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin if (method_exists($data, $getter)) { $return = $data->$getter(); - if($return instanceof \DateTime) { + if ($return instanceof \DateTime) { if (array_key_exists("format", $params)) { $format = $params["format"]; } else { diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 625c89e1f..9ae840019 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -107,8 +107,7 @@ class Form extends AbstractSmartyPlugin $template->assign("form_error", $instance->hasError() ? true : false); $template->assign("form_error_message", $instance->getErrorMessage()); - } - else { + } else { return $content; } } @@ -201,7 +200,6 @@ class Form extends AbstractSmartyPlugin } } - protected function assignFieldErrorVars(\Smarty_Internal_Template $template, array $errors) { $template->assign("message", $errors[0]->getMessage()); @@ -223,7 +221,6 @@ class Form extends AbstractSmartyPlugin if (null == $fieldName) throw new \InvalidArgumentException("'field' parameter is missing"); - if (empty($instance->getView()[$fieldName])) throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName())); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php index 3deffc1aa..536eb2a4e 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php @@ -62,8 +62,8 @@ class Format extends AbstractSmartyPlugin * {format_date date=$dateTimeObject output="date"} will output the date using the default date system format * {format_date date=$dateTimeObject} will output with the default datetime system format * - * @param array $params - * @param null $template + * @param array $params + * @param null $template * @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException * @return string */ @@ -76,7 +76,7 @@ class Format extends AbstractSmartyPlugin $date = $params["date"]; - if(!$date instanceof \DateTime) { + if (!$date instanceof \DateTime) { return ""; } @@ -103,9 +103,9 @@ class Format extends AbstractSmartyPlugin * ex : {format_number number="1246.12" decimals="1" dec_point="," thousands_sep=" "} will output "1 246,1" * * @param $params - * @param null $template + * @param null $template * @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException - * @return string the expected number formatted + * @return string the expected number formatted */ public function formatNumber($params, $template = null) { @@ -115,13 +115,12 @@ class Format extends AbstractSmartyPlugin $number = $params["number"]; - if(empty($number)) { + if (empty($number)) { return ""; } $lang = $this->request->getSession()->getLang(); - $decimals = array_key_exists("decimals", $params) ? $params["decimals"] : $lang->getDecimals(); $decPoint = array_key_exists("dec_point", $params) ? $params["dec_point"] : $lang->getDecimalSeparator(); $thousandsSep = array_key_exists("thousands_sep", $params) ? $params["thousands_sep"] : $lang->getThousandsSeparator(); @@ -139,4 +138,4 @@ class Format extends AbstractSmartyPlugin new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber") ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index 2c7601dc4..6ed09fe2b 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -32,7 +32,6 @@ use Thelia\Core\Template\Element\Exception\ElementNotFoundException; use Thelia\Core\Template\Element\Exception\InvalidElementException; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Security\SecurityContext; class TheliaLoop extends AbstractSmartyPlugin @@ -70,7 +69,7 @@ class TheliaLoop extends AbstractSmartyPlugin */ public static function getPagination($loopId) { - if(!empty(self::$pagination[$loopId])) { + if (!empty(self::$pagination[$loopId])) { return self::$pagination[$loopId]; } else { return null; @@ -84,7 +83,7 @@ class TheliaLoop extends AbstractSmartyPlugin { $type = $this->getParam($params, 'type'); - if (null == $type) { + if (null == $type) { throw new \InvalidArgumentException("Missing 'type' parameter in count arguments"); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index f6c20ecfb..905c5bb5b 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -54,7 +54,6 @@ class UrlGenerator extends AbstractSmartyPlugin $url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target'))); if ($target != null) $url .= '#'.$target; - return $url; } @@ -154,13 +153,13 @@ class UrlGenerator extends AbstractSmartyPlugin protected function getNavigateToMethod($to) { - if($to === null) { + if ($to === null) { throw new \InvalidArgumentException("Missing 'to' parameter in `navigate` substitution."); } $navigateToValues = $this->getNavigateToValues(); - if(!array_key_exists($to, $navigateToValues)) { + if (!array_key_exists($to, $navigateToValues)) { throw new \InvalidArgumentException("Incorrect value for parameter `to` in `navigate` substitution."); } diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index f0b207425..d76dd8dfa 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -65,7 +65,7 @@ class SmartyParser extends Smarty implements ParserInterface $this->setTemplate($template ?: ConfigQuery::read('active-template', 'default')); $this->debugging = $debug; - + // Prevent smarty ErrorException: Notice: Undefined index bla bla bla... $this->error_reporting = E_ALL ^ E_NOTICE; @@ -93,7 +93,7 @@ class SmartyParser extends Smarty implements ParserInterface public static function theliaEscape($content, $smarty) { - if(is_scalar($content)) { + if (is_scalar($content)) { return htmlspecialchars($content ,ENT_QUOTES, Smarty::$_CHARSET); } else { return $content; diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index e5148e408..9aedaaa29 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -32,17 +32,16 @@ namespace Thelia\Core; * @author Manuel Raynaud */ +use Propel\Runtime\Connection\ConnectionWrapper; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Validator\Tests\Fixtures\Reference; use Symfony\Component\Yaml\Yaml; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Thelia\Core\Bundle; use Thelia\Core\Event\TheliaEvents; -use Thelia\Log\Tlog; use Thelia\Config\DatabaseConfiguration; use Thelia\Config\DefinePropel; use Thelia\Core\TheliaContainerBuilder; @@ -81,9 +80,10 @@ class Thelia extends Kernel $manager = new ConnectionManagerSingle(); $manager->setConfiguration($definePropel->getConfig()); $serviceContainer->setConnectionManager('thelia', $manager); - + $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); + $con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true); if ($this->isDebug()) { - $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); + $con->useDebug(true); } } diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index 319173f5f..cf1d35195 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -150,7 +150,7 @@ class TheliaHttpKernel extends HttpKernel $currency = $request->getSession()->getCurrency(false); } - if(null === $currency) { + if (null === $currency) { $currency = Model\Currency::getDefaultCurrency(); } diff --git a/core/lib/Thelia/Core/Translation/Translator.php b/core/lib/Thelia/Core/Translation/Translator.php index 770091403..22dc47afd 100755 --- a/core/lib/Thelia/Core/Translation/Translator.php +++ b/core/lib/Thelia/Core/Translation/Translator.php @@ -19,12 +19,12 @@ class Translator extends BaseTranslator /** * Return this class instance, only once instanciated. * - * @throws \RuntimeException if the class has not been instanciated. + * @throws \RuntimeException if the class has not been instanciated. * @return \Thelia\Core\Translation\Translator the instance. */ - public static function getInstance() { + public static function getInstance() + { if (self::$instance == null) throw new \RuntimeException("Translator instance is not initialized."); - return self::$instance; } diff --git a/core/lib/Thelia/Exception/ImageException.php b/core/lib/Thelia/Exception/ImageException.php index 60774dabf..948ee07f0 100755 --- a/core/lib/Thelia/Exception/ImageException.php +++ b/core/lib/Thelia/Exception/ImageException.php @@ -27,8 +27,8 @@ use Thelia\Log\Tlog; class ImageException extends \RuntimeException { - public function __construct($message, $code = null, $previous = null) { - + public function __construct($message, $code = null, $previous = null) + { Tlog::getInstance()->addError($message); parent::__construct($message, $code, $previous); diff --git a/core/lib/Thelia/Exception/MissingAdapterException.php b/core/lib/Thelia/Exception/MissingAdapterException.php index 645020cab..3659dcc68 100644 --- a/core/lib/Thelia/Exception/MissingAdapterException.php +++ b/core/lib/Thelia/Exception/MissingAdapterException.php @@ -41,8 +41,8 @@ class MissingAdapterException extends \RuntimeException /** * {@inheritdoc} */ - public function __construct($message, $code = null, $previous = null) { - + public function __construct($message, $code = null, $previous = null) + { Tlog::getInstance()->addError($message); parent::__construct($message, $code, $previous); diff --git a/core/lib/Thelia/Exception/NotImplementedException.php b/core/lib/Thelia/Exception/NotImplementedException.php index 991f4d325..1240ea82b 100644 --- a/core/lib/Thelia/Exception/NotImplementedException.php +++ b/core/lib/Thelia/Exception/NotImplementedException.php @@ -24,7 +24,6 @@ namespace Thelia\Exception; use Symfony\Component\DependencyInjection\Exception\BadMethodCallException; -use Thelia\Log\Tlog; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Exception/TaxEngineException.php b/core/lib/Thelia/Exception/TaxEngineException.php index 2a2718d4b..d56862ab6 100755 --- a/core/lib/Thelia/Exception/TaxEngineException.php +++ b/core/lib/Thelia/Exception/TaxEngineException.php @@ -23,8 +23,6 @@ namespace Thelia\Exception; -use Thelia\Log\Tlog; - class TaxEngineException extends \RuntimeException { const UNKNOWN_EXCEPTION = 0; @@ -35,8 +33,9 @@ class TaxEngineException extends \RuntimeException const BAD_AMOUNT_FORMAT = 601; - public function __construct($message, $code = null, $previous = null) { - if($code === null) { + public function __construct($message, $code = null, $previous = null) + { + if ($code === null) { $code = self::UNKNOWN_EXCEPTION; } parent::__construct($message, $code, $previous); diff --git a/core/lib/Thelia/Exception/UrlRewritingException.php b/core/lib/Thelia/Exception/UrlRewritingException.php index 0df566a6b..6f789230b 100755 --- a/core/lib/Thelia/Exception/UrlRewritingException.php +++ b/core/lib/Thelia/Exception/UrlRewritingException.php @@ -23,8 +23,6 @@ namespace Thelia\Exception; -use Thelia\Log\Tlog; - class UrlRewritingException extends \Exception { const UNKNOWN_EXCEPTION = 0; @@ -33,8 +31,9 @@ class UrlRewritingException extends \Exception const RESOLVER_NULL_SEARCH = 800; - public function __construct($message, $code = null, $previous = null) { - if($code === null) { + public function __construct($message, $code = null, $previous = null) + { + if ($code === null) { $code = self::UNKNOWN_EXCEPTION; } parent::__construct($message, $code, $previous); diff --git a/core/lib/Thelia/Form/AddressCreateForm.php b/core/lib/Thelia/Form/AddressCreateForm.php index 3f953fe38..472a7429c 100644 --- a/core/lib/Thelia/Form/AddressCreateForm.php +++ b/core/lib/Thelia/Form/AddressCreateForm.php @@ -24,7 +24,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; - /** * Class AddressCreateForm * @package Thelia\Form @@ -130,4 +129,4 @@ class AddressCreateForm extends BaseForm { return "thelia_address_creation"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/AddressUpdateForm.php b/core/lib/Thelia/Form/AddressUpdateForm.php index aa969831b..556841261 100644 --- a/core/lib/Thelia/Form/AddressUpdateForm.php +++ b/core/lib/Thelia/Form/AddressUpdateForm.php @@ -24,14 +24,13 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; - /** * Class AddressUpdateForm * @package Thelia\Form * @author Manuel Raynaud */ -class AddressUpdateForm extends AddressCreateForm { - +class AddressUpdateForm extends AddressCreateForm +{ /** * * in this function you add all the fields you need for your Form. @@ -56,7 +55,6 @@ class AddressUpdateForm extends AddressCreateForm { { parent::buildForm(); - } /** @@ -66,4 +64,4 @@ class AddressUpdateForm extends AddressCreateForm { { return "thelia_address_update"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/CategoryModificationForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php index a27389324..d9de36d16 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -22,9 +22,6 @@ /*************************************************************************************/ namespace Thelia\Form; -use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Model\LangQuery; -use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; @@ -52,4 +49,4 @@ class CategoryModificationForm extends CategoryCreationForm { return "thelia_category_modification"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/ConfigCreationForm.php b/core/lib/Thelia/Form/ConfigCreationForm.php index b2a0c11bb..e52f44c29 100644 --- a/core/lib/Thelia/Form/ConfigCreationForm.php +++ b/core/lib/Thelia/Form/ConfigCreationForm.php @@ -60,7 +60,7 @@ class ConfigCreationForm extends BaseForm new Constraints\NotBlank() ) )) - ->add("value", "text", array( + ->add("value", "text", array( "label" => "Value *", "label_attr" => array( "for" => "value" diff --git a/core/lib/Thelia/Form/ConfigModificationForm.php b/core/lib/Thelia/Form/ConfigModificationForm.php index ce508137f..257af38c5 100644 --- a/core/lib/Thelia/Form/ConfigModificationForm.php +++ b/core/lib/Thelia/Form/ConfigModificationForm.php @@ -23,8 +23,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Model\LangQuery; -use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\Validator\Constraints\GreaterThan; class ConfigModificationForm extends BaseForm diff --git a/core/lib/Thelia/Form/CouponCreationForm.php b/core/lib/Thelia/Form/CouponCreationForm.php index 4761bb28f..d63a4284d 100755 --- a/core/lib/Thelia/Form/CouponCreationForm.php +++ b/core/lib/Thelia/Form/CouponCreationForm.php @@ -139,7 +139,7 @@ class CouponCreationForm extends BaseForm ) ->add( 'locale', - 'hidden', + 'hidden', array( 'constraints' => array( new NotBlank() diff --git a/core/lib/Thelia/Form/CurrencyModificationForm.php b/core/lib/Thelia/Form/CurrencyModificationForm.php index 3f0b1f152..c56791e3d 100644 --- a/core/lib/Thelia/Form/CurrencyModificationForm.php +++ b/core/lib/Thelia/Form/CurrencyModificationForm.php @@ -22,9 +22,6 @@ /*************************************************************************************/ namespace Thelia\Form; -use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Model\LangQuery; -use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\Validator\Constraints\GreaterThan; class CurrencyModificationForm extends CurrencyCreationForm @@ -42,4 +39,4 @@ class CurrencyModificationForm extends CurrencyCreationForm { return "thelia_currency_modification"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 3081ceed7..63dc186aa 100755 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -22,12 +22,9 @@ /*************************************************************************************/ namespace Thelia\Form; -use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Email; -use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Translation\Translator; -use Thelia\Model\CustomerQuery; class CustomerLogin extends BaseForm { diff --git a/core/lib/Thelia/Form/MessageModificationForm.php b/core/lib/Thelia/Form/MessageModificationForm.php index a23f66e28..c8f20448d 100644 --- a/core/lib/Thelia/Form/MessageModificationForm.php +++ b/core/lib/Thelia/Form/MessageModificationForm.php @@ -23,8 +23,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Model\LangQuery; -use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\Validator\Constraints\GreaterThan; class MessageModificationForm extends BaseForm @@ -41,7 +39,7 @@ class MessageModificationForm extends BaseForm ) )) ->add("secured" , "text" , array( - "label" => "Prevent mailing template modification or deletion, except for super-admin" + "label" => "Prevent mailing template modification or deletion, except for super-admin" )) ->add("locale" , "text" , array()) ->add("title" , "text" , array( diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php index 7c0a51a31..9d1851252 100644 --- a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -89,4 +89,4 @@ trait StandardDescriptionFieldsTrait ) )); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index 767e2dc37..26d6573a9 100644 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -2276,7 +2276,10 @@ abstract class Currency implements ActiveRecordInterface $productPricesToDelete = $this->getProductPrices(new Criteria(), $con)->diff($productPrices); - $this->productPricesScheduledForDeletion = $productPricesToDelete; + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productPricesScheduledForDeletion = clone $productPricesToDelete; foreach ($productPricesToDelete as $productPriceRemoved) { $productPriceRemoved->setCurrency(null); diff --git a/core/lib/Thelia/Model/Base/ProductPrice.php b/core/lib/Thelia/Model/Base/ProductPrice.php index 15502a385..e92ca2cfa 100644 --- a/core/lib/Thelia/Model/Base/ProductPrice.php +++ b/core/lib/Thelia/Model/Base/ProductPrice.php @@ -58,12 +58,6 @@ abstract class ProductPrice implements ActiveRecordInterface */ protected $virtualColumns = array(); - /** - * The value for the id field. - * @var int - */ - protected $id; - /** * The value for the product_sale_elements_id field. * @var int @@ -372,17 +366,6 @@ abstract class ProductPrice implements ActiveRecordInterface return array_keys(get_object_vars($this)); } - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - /** * Get the [product_sale_elements_id] column value. * @@ -467,27 +450,6 @@ abstract class ProductPrice implements ActiveRecordInterface } } - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\ProductPrice The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ProductPriceTableMap::ID; - } - - - return $this; - } // setId() - /** * Set the value of [product_sale_elements_id] column. * @@ -659,28 +621,25 @@ abstract class ProductPrice implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductPriceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductPriceTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductPriceTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)]; $this->product_sale_elements_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductPriceTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductPriceTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)]; $this->currency_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductPriceTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductPriceTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; $this->price = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductPriceTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductPriceTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; $this->promo_price = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductPriceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductPriceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductPriceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductPriceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -693,7 +652,7 @@ abstract class ProductPrice implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = ProductPriceTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ProductPriceTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductPrice object", 0, $e); @@ -934,15 +893,8 @@ abstract class ProductPrice implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ProductPriceTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductPriceTableMap::ID . ')'); - } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ProductPriceTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } if ($this->isColumnModified(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID)) { $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID'; } @@ -972,9 +924,6 @@ abstract class ProductPrice implements ActiveRecordInterface $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; case 'PRODUCT_SALE_ELEMENTS_ID': $stmt->bindValue($identifier, $this->product_sale_elements_id, PDO::PARAM_INT); break; @@ -1001,13 +950,6 @@ abstract class ProductPrice implements ActiveRecordInterface throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - $this->setNew(false); } @@ -1056,24 +998,21 @@ abstract class ProductPrice implements ActiveRecordInterface { switch ($pos) { case 0: - return $this->getId(); - break; - case 1: return $this->getProductSaleElementsId(); break; - case 2: + case 1: return $this->getCurrencyId(); break; - case 3: + case 2: return $this->getPrice(); break; - case 4: + case 3: return $this->getPromoPrice(); break; - case 5: + case 4: return $this->getCreatedAt(); break; - case 6: + case 5: return $this->getUpdatedAt(); break; default: @@ -1099,19 +1038,18 @@ abstract class ProductPrice implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['ProductPrice'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['ProductPrice'][serialize($this->getPrimaryKey())])) { return '*RECURSION*'; } - $alreadyDumpedObjects['ProductPrice'][$this->getPrimaryKey()] = true; + $alreadyDumpedObjects['ProductPrice'][serialize($this->getPrimaryKey())] = true; $keys = ProductPriceTableMap::getFieldNames($keyType); $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getProductSaleElementsId(), - $keys[2] => $this->getCurrencyId(), - $keys[3] => $this->getPrice(), - $keys[4] => $this->getPromoPrice(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), + $keys[0] => $this->getProductSaleElementsId(), + $keys[1] => $this->getCurrencyId(), + $keys[2] => $this->getPrice(), + $keys[3] => $this->getPromoPrice(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1161,24 +1099,21 @@ abstract class ProductPrice implements ActiveRecordInterface { switch ($pos) { case 0: - $this->setId($value); - break; - case 1: $this->setProductSaleElementsId($value); break; - case 2: + case 1: $this->setCurrencyId($value); break; - case 3: + case 2: $this->setPrice($value); break; - case 4: + case 3: $this->setPromoPrice($value); break; - case 5: + case 4: $this->setCreatedAt($value); break; - case 6: + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1205,13 +1140,12 @@ abstract class ProductPrice implements ActiveRecordInterface { $keys = ProductPriceTableMap::getFieldNames($keyType); - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setProductSaleElementsId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCurrencyId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPromoPrice($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + if (array_key_exists($keys[0], $arr)) $this->setProductSaleElementsId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCurrencyId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPrice($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPromoPrice($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1223,7 +1157,6 @@ abstract class ProductPrice implements ActiveRecordInterface { $criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME); - if ($this->isColumnModified(ProductPriceTableMap::ID)) $criteria->add(ProductPriceTableMap::ID, $this->id); if ($this->isColumnModified(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); if ($this->isColumnModified(ProductPriceTableMap::CURRENCY_ID)) $criteria->add(ProductPriceTableMap::CURRENCY_ID, $this->currency_id); if ($this->isColumnModified(ProductPriceTableMap::PRICE)) $criteria->add(ProductPriceTableMap::PRICE, $this->price); @@ -1245,29 +1178,36 @@ abstract class ProductPrice implements ActiveRecordInterface public function buildPkeyCriteria() { $criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME); - $criteria->add(ProductPriceTableMap::ID, $this->id); + $criteria->add(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); + $criteria->add(ProductPriceTableMap::CURRENCY_ID, $this->currency_id); return $criteria; } /** - * Returns the primary key for this object (row). - * @return int + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array */ public function getPrimaryKey() { - return $this->getId(); + $pks = array(); + $pks[0] = $this->getProductSaleElementsId(); + $pks[1] = $this->getCurrencyId(); + + return $pks; } /** - * Generic method to set the primary key (id column). + * Set the [composite] primary key. * - * @param int $key Primary key. + * @param array $keys The elements of the composite key (order must match the order in XML file). * @return void */ - public function setPrimaryKey($key) + public function setPrimaryKey($keys) { - $this->setId($key); + $this->setProductSaleElementsId($keys[0]); + $this->setCurrencyId($keys[1]); } /** @@ -1277,7 +1217,7 @@ abstract class ProductPrice implements ActiveRecordInterface public function isPrimaryKeyNull() { - return null === $this->getId(); + return (null === $this->getProductSaleElementsId()) && (null === $this->getCurrencyId()); } /** @@ -1301,7 +1241,6 @@ abstract class ProductPrice implements ActiveRecordInterface $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } } @@ -1434,7 +1373,6 @@ abstract class ProductPrice implements ActiveRecordInterface */ public function clear() { - $this->id = null; $this->product_sale_elements_id = null; $this->currency_id = null; $this->price = null; diff --git a/core/lib/Thelia/Model/Base/ProductPriceQuery.php b/core/lib/Thelia/Model/Base/ProductPriceQuery.php index 275aebbb2..9790d00ef 100644 --- a/core/lib/Thelia/Model/Base/ProductPriceQuery.php +++ b/core/lib/Thelia/Model/Base/ProductPriceQuery.php @@ -21,7 +21,6 @@ use Thelia\Model\Map\ProductPriceTableMap; * * * - * @method ChildProductPriceQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildProductPriceQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column * @method ChildProductPriceQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column * @method ChildProductPriceQuery orderByPrice($order = Criteria::ASC) Order by the price column @@ -29,7 +28,6 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPriceQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductPriceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * - * @method ChildProductPriceQuery groupById() Group by the id column * @method ChildProductPriceQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column * @method ChildProductPriceQuery groupByCurrencyId() Group by the currency_id column * @method ChildProductPriceQuery groupByPrice() Group by the price column @@ -52,7 +50,6 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPrice findOne(ConnectionInterface $con = null) Return the first ChildProductPrice matching the query * @method ChildProductPrice findOneOrCreate(ConnectionInterface $con = null) Return the first ChildProductPrice matching the query, or a new ChildProductPrice object populated from the query conditions when no match is found * - * @method ChildProductPrice findOneById(int $id) Return the first ChildProductPrice filtered by the id column * @method ChildProductPrice findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildProductPrice filtered by the product_sale_elements_id column * @method ChildProductPrice findOneByCurrencyId(int $currency_id) Return the first ChildProductPrice filtered by the currency_id column * @method ChildProductPrice findOneByPrice(double $price) Return the first ChildProductPrice filtered by the price column @@ -60,7 +57,6 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPrice findOneByCreatedAt(string $created_at) Return the first ChildProductPrice filtered by the created_at column * @method ChildProductPrice findOneByUpdatedAt(string $updated_at) Return the first ChildProductPrice filtered by the updated_at column * - * @method array findById(int $id) Return ChildProductPrice objects filtered by the id column * @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildProductPrice objects filtered by the product_sale_elements_id column * @method array findByCurrencyId(int $currency_id) Return ChildProductPrice objects filtered by the currency_id column * @method array findByPrice(double $price) Return ChildProductPrice objects filtered by the price column @@ -114,10 +110,10 @@ abstract class ProductPriceQuery extends ModelCriteria * Go fast if the query is untouched. * * - * $obj = $c->findPk(12, $con); + * $obj = $c->findPk(array(12, 34), $con); * * - * @param mixed $key Primary key to use for the query + * @param array[$product_sale_elements_id, $currency_id] $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * * @return ChildProductPrice|array|mixed the result, formatted by the current formatter @@ -127,7 +123,7 @@ abstract class ProductPriceQuery extends ModelCriteria if ($key === null) { return null; } - if ((null !== ($obj = ProductPriceTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = ProductPriceTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { // the object is already in the instance pool return $obj; } @@ -155,10 +151,11 @@ abstract class ProductPriceQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_SALE_ELEMENTS_ID, CURRENCY_ID, PRICE, PROMO_PRICE, CREATED_AT, UPDATED_AT FROM product_price WHERE ID = :p0'; + $sql = 'SELECT PRODUCT_SALE_ELEMENTS_ID, CURRENCY_ID, PRICE, PROMO_PRICE, CREATED_AT, UPDATED_AT FROM product_price WHERE PRODUCT_SALE_ELEMENTS_ID = :p0 AND CURRENCY_ID = :p1'; try { $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); @@ -168,7 +165,7 @@ abstract class ProductPriceQuery extends ModelCriteria if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { $obj = new ChildProductPrice(); $obj->hydrate($row); - ProductPriceTableMap::addInstanceToPool($obj, (string) $key); + ProductPriceTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -197,7 +194,7 @@ abstract class ProductPriceQuery extends ModelCriteria /** * Find objects by primary key * - * $objs = $c->findPks(array(12, 56, 832), $con); + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); * * @param array $keys Primary keys to use for the query * @param ConnectionInterface $con an optional connection object @@ -227,8 +224,10 @@ abstract class ProductPriceQuery extends ModelCriteria */ public function filterByPrimaryKey($key) { + $this->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProductPriceTableMap::CURRENCY_ID, $key[1], Criteria::EQUAL); - return $this->addUsingAlias(ProductPriceTableMap::ID, $key, Criteria::EQUAL); + return $this; } /** @@ -240,49 +239,17 @@ abstract class ProductPriceQuery extends ModelCriteria */ public function filterByPrimaryKeys($keys) { - - return $this->addUsingAlias(ProductPriceTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildProductPriceQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ProductPriceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ProductPriceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProductPriceTableMap::CURRENCY_ID, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); } - return $this->addUsingAlias(ProductPriceTableMap::ID, $id, $comparison); + return $this; } /** @@ -699,7 +666,9 @@ abstract class ProductPriceQuery extends ModelCriteria public function prune($productPrice = null) { if ($productPrice) { - $this->addUsingAlias(ProductPriceTableMap::ID, $productPrice->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond0', $this->getAliasedColName(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID), $productPrice->getProductSaleElementsId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProductPriceTableMap::CURRENCY_ID), $productPrice->getCurrencyId(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php index f79d9a246..4c14580ff 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElements.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -2248,7 +2248,10 @@ abstract class ProductSaleElements implements ActiveRecordInterface $productPricesToDelete = $this->getProductPrices(new Criteria(), $con)->diff($productPrices); - $this->productPricesScheduledForDeletion = $productPricesToDelete; + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productPricesScheduledForDeletion = clone $productPricesToDelete; foreach ($productPricesToDelete as $productPriceRemoved) { $productPriceRemoved->setProductSaleElements(null); diff --git a/core/lib/Thelia/Model/ConfigQuery.php b/core/lib/Thelia/Model/ConfigQuery.php index 87b506e93..ced3783fe 100755 --- a/core/lib/Thelia/Model/ConfigQuery.php +++ b/core/lib/Thelia/Model/ConfigQuery.php @@ -42,4 +42,9 @@ class ConfigQuery extends BaseConfigQuery { { return self::read('active-template', 'default'); } + + public static function useTaxFreeAmounts() + { + return self::read('use_tax_free_amounts', 'default') == 1; + } } // ConfigQuery diff --git a/core/lib/Thelia/Model/Currency.php b/core/lib/Thelia/Model/Currency.php index 843211d5a..6ec452456 100755 --- a/core/lib/Thelia/Model/Currency.php +++ b/core/lib/Thelia/Model/Currency.php @@ -2,6 +2,7 @@ namespace Thelia\Model; +use Propel\Runtime\Exception\PropelException; use Thelia\Model\Base\Currency as BaseCurrency; use Thelia\Core\Event\TheliaEvents; use Propel\Runtime\Connection\ConnectionInterface; @@ -80,4 +81,19 @@ class Currency extends BaseCurrency { { $this->dispatchEvent(TheliaEvents::AFTER_DELETECURRENCY, new CurrencyEvent($this)); } + + /** + * Get the [rate] column value. + * + * @return double + * @throws PropelException + */ + public function getRate() + { + if(false === filter_var($this->rate, FILTER_VALIDATE_FLOAT)) { + throw new PropelException('Currency::rate is not float value'); + } + + return $this->rate; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/Map/ProductPriceTableMap.php b/core/lib/Thelia/Model/Map/ProductPriceTableMap.php index 1a6274e2d..86a22b680 100644 --- a/core/lib/Thelia/Model/Map/ProductPriceTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductPriceTableMap.php @@ -57,7 +57,7 @@ class ProductPriceTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,12 +67,7 @@ class ProductPriceTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; - - /** - * the column name for the ID field - */ - const ID = 'product_price.ID'; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the PRODUCT_SALE_ELEMENTS_ID field @@ -116,12 +111,12 @@ class ProductPriceTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductSaleElementsId', 'CurrencyId', 'Price', 'PromoPrice', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productSaleElementsId', 'currencyId', 'price', 'promoPrice', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductPriceTableMap::ID, ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductPriceTableMap::CURRENCY_ID, ProductPriceTableMap::PRICE, ProductPriceTableMap::PROMO_PRICE, ProductPriceTableMap::CREATED_AT, ProductPriceTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_SALE_ELEMENTS_ID', 'CURRENCY_ID', 'PRICE', 'PROMO_PRICE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_sale_elements_id', 'currency_id', 'price', 'promo_price', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('ProductSaleElementsId', 'CurrencyId', 'Price', 'PromoPrice', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('productSaleElementsId', 'currencyId', 'price', 'promoPrice', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductPriceTableMap::CURRENCY_ID, ProductPriceTableMap::PRICE, ProductPriceTableMap::PROMO_PRICE, ProductPriceTableMap::CREATED_AT, ProductPriceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_SALE_ELEMENTS_ID', 'CURRENCY_ID', 'PRICE', 'PROMO_PRICE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('product_sale_elements_id', 'currency_id', 'price', 'promo_price', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -131,12 +126,12 @@ class ProductPriceTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductSaleElementsId' => 1, 'CurrencyId' => 2, 'Price' => 3, 'PromoPrice' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productSaleElementsId' => 1, 'currencyId' => 2, 'price' => 3, 'promoPrice' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(ProductPriceTableMap::ID => 0, ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID => 1, ProductPriceTableMap::CURRENCY_ID => 2, ProductPriceTableMap::PRICE => 3, ProductPriceTableMap::PROMO_PRICE => 4, ProductPriceTableMap::CREATED_AT => 5, ProductPriceTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_SALE_ELEMENTS_ID' => 1, 'CURRENCY_ID' => 2, 'PRICE' => 3, 'PROMO_PRICE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_sale_elements_id' => 1, 'currency_id' => 2, 'price' => 3, 'promo_price' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('ProductSaleElementsId' => 0, 'CurrencyId' => 1, 'Price' => 2, 'PromoPrice' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('productSaleElementsId' => 0, 'currencyId' => 1, 'price' => 2, 'promoPrice' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID => 0, ProductPriceTableMap::CURRENCY_ID => 1, ProductPriceTableMap::PRICE => 2, ProductPriceTableMap::PROMO_PRICE => 3, ProductPriceTableMap::CREATED_AT => 4, ProductPriceTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_SALE_ELEMENTS_ID' => 0, 'CURRENCY_ID' => 1, 'PRICE' => 2, 'PROMO_PRICE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('product_sale_elements_id' => 0, 'currency_id' => 1, 'price' => 2, 'promo_price' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -153,11 +148,10 @@ class ProductPriceTableMap extends TableMap $this->setPhpName('ProductPrice'); $this->setClassName('\\Thelia\\Model\\ProductPrice'); $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); + $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER', 'product_sale_elements', 'ID', true, null, null); - $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null); + $this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null); + $this->addForeignPrimaryKey('CURRENCY_ID', 'CurrencyId', 'INTEGER' , 'currency', 'ID', true, null, null); $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); $this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); @@ -186,6 +180,59 @@ class ProductPriceTableMap extends TableMap ); } // getBehaviors() + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProductPrice $obj A \Thelia\Model\ProductPrice object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getProductSaleElementsId(), (string) $obj->getCurrencyId())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ProductPrice object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ProductPrice) { + $key = serialize(array((string) $value->getProductSaleElementsId(), (string) $value->getCurrencyId())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductPrice object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + /** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * @@ -200,11 +247,11 @@ class ProductPriceTableMap extends TableMap public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -222,11 +269,7 @@ class ProductPriceTableMap extends TableMap public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; + return $pks; } /** @@ -324,7 +367,6 @@ class ProductPriceTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(ProductPriceTableMap::ID); $criteria->addSelectColumn(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID); $criteria->addSelectColumn(ProductPriceTableMap::CURRENCY_ID); $criteria->addSelectColumn(ProductPriceTableMap::PRICE); @@ -332,7 +374,6 @@ class ProductPriceTableMap extends TableMap $criteria->addSelectColumn(ProductPriceTableMap::CREATED_AT); $criteria->addSelectColumn(ProductPriceTableMap::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); $criteria->addSelectColumn($alias . '.CURRENCY_ID'); $criteria->addSelectColumn($alias . '.PRICE'); @@ -390,7 +431,17 @@ class ProductPriceTableMap extends TableMap $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME); - $criteria->add(ProductPriceTableMap::ID, (array) $values, Criteria::IN); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProductPriceTableMap::CURRENCY_ID, $value[1])); + $criteria->addOr($criterion); + } } $query = ProductPriceQuery::create()->mergeWith($criteria); @@ -436,10 +487,6 @@ class ProductPriceTableMap extends TableMap $criteria = $criteria->buildCriteria(); // build Criteria from ProductPrice object } - if ($criteria->containsKey(ProductPriceTableMap::ID) && $criteria->keyContainsValue(ProductPriceTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductPriceTableMap::ID.')'); - } - // Set the correct dbName $query = ProductPriceQuery::create()->mergeWith($criteria); diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 145da3c02..9d76e08f3 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -46,9 +46,10 @@ abstract class BaseModule extends ContainerAware public function getContainer() { - if($this->hasContainer() === false) { + if ($this->hasContainer() === false) { throw new \RuntimeException("Sorry, container his not available in this context"); } + return $this->container; } diff --git a/core/lib/Thelia/Module/BaseModuleInterface.php b/core/lib/Thelia/Module/BaseModuleInterface.php index 2db450830..5cfd98409 100644 --- a/core/lib/Thelia/Module/BaseModuleInterface.php +++ b/core/lib/Thelia/Module/BaseModuleInterface.php @@ -23,15 +23,14 @@ namespace Thelia\Module; - use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -interface BaseModuleInterface { - +interface BaseModuleInterface +{ public function setRequest(Request $request); public function getRequest(); public function setDispatcher(EventDispatcherInterface $dispatcher); public function getDispatcher(); -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Module/DeliveryModuleInterface.php b/core/lib/Thelia/Module/DeliveryModuleInterface.php index b8ffcfc01..ba218ac4d 100644 --- a/core/lib/Thelia/Module/DeliveryModuleInterface.php +++ b/core/lib/Thelia/Module/DeliveryModuleInterface.php @@ -23,9 +23,8 @@ namespace Thelia\Module; - -interface DeliveryModuleInterface extends BaseModuleInterface { - +interface DeliveryModuleInterface extends BaseModuleInterface +{ /** * * calculate and return delivery price @@ -33,4 +32,4 @@ interface DeliveryModuleInterface extends BaseModuleInterface { * @return mixed */ public function calculate($country = null); -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Action/AddressTest.php b/core/lib/Thelia/Tests/Action/AddressTest.php index 68fc97923..69f5b5329 100644 --- a/core/lib/Thelia/Tests/Action/AddressTest.php +++ b/core/lib/Thelia/Tests/Action/AddressTest.php @@ -26,7 +26,6 @@ use Thelia\Action\Address; use Thelia\Core\Event\AddressCreateOrUpdateEvent; use Thelia\Model\Base\CustomerQuery; - /** * * test address eventListener @@ -120,7 +119,6 @@ class AddressTest extends \PHPUnit_Framework_TestCase $actionAddress = new Address($this->getContainer()); $actionAddress->update($addressEvent); - $updatedAddress = $addressEvent->getAddress(); $this->assertInstanceOf("Thelia\Model\Address", $updatedAddress); $this->assertFalse($updatedAddress->isNew()); @@ -142,4 +140,4 @@ class AddressTest extends \PHPUnit_Framework_TestCase } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Action/ImageTest.php b/core/lib/Thelia/Tests/Action/ImageTest.php index 8cc6e5644..f08da25b9 100755 --- a/core/lib/Thelia/Tests/Action/ImageTest.php +++ b/core/lib/Thelia/Tests/Action/ImageTest.php @@ -30,7 +30,6 @@ use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Action\Image; use Thelia\Core\Event\ImageEvent; use Thelia\Model\ConfigQuery; -use Thelia\Tools\URL; /** * Class ImageTest @@ -78,7 +77,8 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup } } - public static function setUpBeforeClass() { + public static function setUpBeforeClass() + { $dir = THELIA_WEB_DIR."/cache/tests"; if ($dh = @opendir($dir)) { while ($file = readdir($dh)) { @@ -91,7 +91,8 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup } } - public function tearDown() { + public function tearDown() + { // restore cache configuration. $config = ConfigQuery::create()->filterByName('image_cache_dir_from_web_root')->findOne(); @@ -249,7 +250,6 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup $image->processImage($event); } - /** * Apply all transformations */ @@ -343,7 +343,8 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup $image->processImage($event); } - public function testClearTestsCache() { + public function testClearTestsCache() + { $event = new ImageEvent($this->request); $event->setCacheSubdirectory('tests'); @@ -353,7 +354,8 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup $image->clearCache($event); } - public function testClearWholeCache() { + public function testClearWholeCache() + { $event = new ImageEvent($this->request); $image = new Image($this->getContainer()); @@ -366,7 +368,8 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup * * @expectedException \InvalidArgumentException */ - public function testClearUnallowedPathCache() { + public function testClearUnallowedPathCache() + { $event = new ImageEvent($this->request); $event->setCacheSubdirectory('../../../..'); @@ -375,4 +378,4 @@ class ImageTest extends \Thelia\Tests\TestCaseWithURLToolSetup $image->clearCache($event); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Command/CacheClearTest.php b/core/lib/Thelia/Tests/Command/CacheClearTest.php index 741fad299..00d54cb3b 100755 --- a/core/lib/Thelia/Tests/Command/CacheClearTest.php +++ b/core/lib/Thelia/Tests/Command/CacheClearTest.php @@ -97,8 +97,7 @@ class CacheClearTest extends \PHPUnit_Framework_TestCase "command" => $command->getName(), "--env" => "test" )); - } - else { + } else { throw new \RuntimeException(""); } } diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php index 70d6e498c..ccc04fbfc 100644 --- a/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php +++ b/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php @@ -130,7 +130,6 @@ class ConstraintFactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } - /** * Check the Rules serialization module */ @@ -180,8 +179,8 @@ class ConstraintFactoryTest extends \PHPUnit_Framework_TestCase $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $unserializedRules = $constraintFactory->unserializeCouponRuleCollection($serializedRules); - $expected = (string)$rules; - $actual = (string)$unserializedRules; + $expected = (string) $rules; + $actual = (string) $unserializedRules; $this->assertEquals($expected, $actual); } diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php index 28ac4b952..01e9dde69 100644 --- a/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php +++ b/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php @@ -76,7 +76,6 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmountManager::INPUT2 => 'EUR'); $rule1->setValidatorsFromForm($operators, $values); - $rules = new CouponRuleCollection(); $rules->add($rule1); @@ -111,7 +110,6 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase AvailableForTotalAmountManager::INPUT2 => 'EUR'); $rule1->setValidatorsFromForm($operators, $values); - $rules = new CouponRuleCollection(); $rules->add($rule1); @@ -216,7 +214,6 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual, 'Constraints validator always think Customer is matching rules'); } - public function testVariableOpComparisonSuccess() { $ConstraintValidator = new ConstraintValidator(); diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php index bfcde8a21..4c6da4ad2 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php @@ -151,7 +151,6 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase // $this->assertEquals($expected, $actual); // } - /** * Check if test inferior operator is working * @@ -512,7 +511,6 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } - /** * Check if test superior operator is working * @@ -585,7 +583,6 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } - /** * Check currency is checked * @@ -658,7 +655,6 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } - /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php index cc5caee2a..76a744848 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php @@ -177,10 +177,6 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase // $this->assertEquals($expected, $actual); // } - - - - /** * Check if test inferior operator is working * @@ -501,7 +497,6 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } - /** * Check if test superior operator is working * @@ -661,7 +656,6 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase // // } - /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index c86e827b6..0b29baa62 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -416,8 +416,6 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase // $this->assertFalse($actual); // } - - /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php index afb7b8c80..db281bcc5 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php @@ -25,7 +25,6 @@ namespace Thelia\Coupon; use InvalidArgumentException; use Thelia\Constraint\Validator\CustomerParam; -use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\QuantityParam; use Thelia\Model\Customer; diff --git a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php index afcc62f6e..806cedf8d 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php @@ -24,7 +24,6 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\QuantityParam; /** diff --git a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php index 677117348..be03743d3 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php @@ -24,7 +24,6 @@ namespace Thelia\Coupon; use InvalidArgumentException; -use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Constraint\Validator\RepeatedDateParam; /** diff --git a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php index 513e85836..c5565a322 100644 --- a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php +++ b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php @@ -23,7 +23,6 @@ namespace Thelia\Coupon; -use Symfony\Component\Intl\Exception\NotImplementedException; use Thelia\Constraint\Validator\RepeatedIntervalParam; /** diff --git a/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php b/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php index 177802078..3ecae7c01 100755 --- a/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php +++ b/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php @@ -68,7 +68,6 @@ class DefaultControllerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($request->attributes->get('_view'), 'foo'); } - public function testNoActionWithAttribute() { $defaultController = new DefaultController(); diff --git a/core/lib/Thelia/Tests/Core/Template/Smarty/Plugins/FormatTest.php b/core/lib/Thelia/Tests/Core/Template/Smarty/Plugins/FormatTest.php index 38c00b55f..e8d5ff0fc 100644 --- a/core/lib/Thelia/Tests/Core/Template/Smarty/Plugins/FormatTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Smarty/Plugins/FormatTest.php @@ -168,7 +168,6 @@ class FormatTest extends \PHPUnit_Framework_TestCase $this->assertEquals($dateTime->format("Y-m-d H:i:s"), $render); } - /** * test formatNumber without mandatory parameters * @@ -269,6 +268,4 @@ class FormatTest extends \PHPUnit_Framework_TestCase return $mock; } - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 5a3d7881f..d0662442a 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -25,10 +25,8 @@ namespace Thelia\Coupon; use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; use Thelia\Coupon\Type\CouponInterface; -use Thelia\Coupon\Type\RemoveXAmountManager; use Thelia\Tools\PhpUnitUtils; /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 8467852ac..990309f28 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -25,7 +25,6 @@ namespace Thelia\Coupon; use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; use Thelia\Coupon\Type\RemoveXAmountManager; diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 7fc327df6..b5d6529b1 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -24,7 +24,6 @@ namespace Thelia\Coupon; use PHPUnit_Framework_TestCase; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\RuleValidator; diff --git a/core/lib/Thelia/Tests/Rewriting/RewritingResolverTest.php b/core/lib/Thelia/Tests/Rewriting/RewritingResolverTest.php index 6cd4bdf42..97a6eebc0 100755 --- a/core/lib/Thelia/Tests/Rewriting/RewritingResolverTest.php +++ b/core/lib/Thelia/Tests/Rewriting/RewritingResolverTest.php @@ -120,7 +120,7 @@ class RewritingResolverTest extends \PHPUnit_Framework_TestCase $collection = new ObjectCollection(); $collection->setModel('\Thelia\Model\RewritingArgument'); - for($i=0; $i<3; $i++) { + for ($i=0; $i<3; $i++) { $ra = new RewritingArgument(); $ra->setParameter('foo' . $i); $ra->setValue('bar' . $i); @@ -132,7 +132,6 @@ class RewritingResolverTest extends \PHPUnit_Framework_TestCase $collection->append($ra); } - $resolverQuery = $this->getMock('\Thelia\Model\RewritingUrlQuery', array('getResolverSearch')); $resolverQuery->expects($this->any()) ->method('getResolverSearch') diff --git a/core/lib/Thelia/Tests/TestCaseWithURLToolSetup.php b/core/lib/Thelia/Tests/TestCaseWithURLToolSetup.php index 927f7cf62..e0fd3f678 100644 --- a/core/lib/Thelia/Tests/TestCaseWithURLToolSetup.php +++ b/core/lib/Thelia/Tests/TestCaseWithURLToolSetup.php @@ -28,15 +28,15 @@ namespace Thelia\Tests; * * @package Thelia\Tests\TestCaseWithURLSetup */ -class TestCaseWithURLToolSetup extends \PHPUnit_Framework_TestCase { - - - public function __construct() { +class TestCaseWithURLToolSetup extends \PHPUnit_Framework_TestCase +{ + public function __construct() + { $this->setupURLTool(); } - protected function setupURLTool() { - + protected function setupURLTool() + { $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); $context = new \Symfony\Component\Routing\RequestContext( @@ -61,4 +61,4 @@ class TestCaseWithURLToolSetup extends \PHPUnit_Framework_TestCase { new \Thelia\Tools\URL($container); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Tools/URLTest.php b/core/lib/Thelia/Tests/Tools/URLTest.php index 86804f5c0..bf70e91c6 100755 --- a/core/lib/Thelia/Tests/Tools/URLTest.php +++ b/core/lib/Thelia/Tests/Tools/URLTest.php @@ -62,8 +62,8 @@ class URLTest extends \PHPUnit_Framework_TestCase new \Thelia\Tools\URL($container); } - public function testGetIndexPage() { - + public function testGetIndexPage() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->getIndexPage(); $this->assertEquals('http://localhost/thelia/index.php', $url); @@ -81,7 +81,8 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://localhost/', $url); } - public function testGetBaseUrl() { + public function testGetBaseUrl() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->getBaseUrl(); $this->assertEquals('http://localhost/thelia/index.php', $url); @@ -95,7 +96,8 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://localhost/', $url); } - public function testAbsoluteUrl() { + public function testAbsoluteUrl() + { $this->context->setBaseUrl('/'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('/path/to/action'); $this->assertEquals('http://localhost/path/to/action', $url); @@ -113,8 +115,8 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://localhost/thelia/index.php/path/to/action', $url); } - public function testAbsoluteUrlOnAbsolutePath() { - + public function testAbsoluteUrlOnAbsolutePath() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('http://myhost/path/to/action'); $this->assertEquals('http://myhost/path/to/action', $url); @@ -128,8 +130,8 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://myhost/path/to/action', $url); } - public function testAbsoluteUrlOnAbsolutePathWithParameters() { - + public function testAbsoluteUrlOnAbsolutePathWithParameters() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('http://myhost/path/to/action', array("p1" => "v1", "p2" => "v2")); $this->assertEquals('http://myhost/path/to/action?p1=v1&p2=v2', $url); @@ -143,7 +145,8 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://myhost/path/to/action?p1=v1&p2=v2', $url); } - public function testAbsoluteUrlOnAbsolutePathWithParametersAddParameters() { + public function testAbsoluteUrlOnAbsolutePathWithParametersAddParameters() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('http://myhost/path/to/action?p0=v0', array("p1" => "v1", "p2" => "v2")); $this->assertEquals('http://myhost/path/to/action?p0=v0&p1=v1&p2=v2', $url); @@ -157,7 +160,8 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://myhost/path/to/action?p0=v0&p1=v1&p2=v2', $url); } - public function testAbsoluteUrlWithParameters() { + public function testAbsoluteUrlWithParameters() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('/path/to/action', array("p1" => "v1", "p2" => "v2")); $this->assertEquals('http://localhost/thelia/index.php/path/to/action?p1=v1&p2=v2', $url); @@ -179,13 +183,15 @@ class URLTest extends \PHPUnit_Framework_TestCase $this->assertEquals('http://localhost/path/to/action?p1=v1&p2=v2', $url); } - public function testAbsoluteUrlPathOnly() { + public function testAbsoluteUrlPathOnly() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('/path/to/action', array(), URL::PATH_TO_FILE); $this->assertEquals('http://localhost/thelia/path/to/action', $url); } - public function testAbsoluteUrlPathOnlyWithParameters() { + public function testAbsoluteUrlPathOnlyWithParameters() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('/path/to/action', array("p1" => "v1", "p2" => "v2"), URL::PATH_TO_FILE); $this->assertEquals('http://localhost/thelia/path/to/action?p1=v1&p2=v2', $url); @@ -200,7 +206,8 @@ class URLTest extends \PHPUnit_Framework_TestCase } - public function testAbsoluteUrlFromIndexWithParameters() { + public function testAbsoluteUrlFromIndexWithParameters() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('/', array("p1" => "v1", "p2" => "v2")); $this->assertEquals('http://localhost/thelia/index.php/?p1=v1&p2=v2', $url); @@ -215,7 +222,8 @@ class URLTest extends \PHPUnit_Framework_TestCase } - public function testAbsoluteUrlPathOnlyFromIndexWithParameters() { + public function testAbsoluteUrlPathOnlyFromIndexWithParameters() + { $this->context->setBaseUrl('/thelia/index.php'); $url = \Thelia\Tools\URL::getInstance()->absoluteUrl('/', array("p1" => "v1", "p2" => "v2"), URL::PATH_TO_FILE); $this->assertEquals('http://localhost/thelia/?p1=v1&p2=v2', $url); diff --git a/core/lib/Thelia/Tools/DateTimeFormat.php b/core/lib/Thelia/Tools/DateTimeFormat.php index bd6161389..50c757536 100755 --- a/core/lib/Thelia/Tools/DateTimeFormat.php +++ b/core/lib/Thelia/Tools/DateTimeFormat.php @@ -24,7 +24,6 @@ namespace Thelia\Tools; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\DependencyInjection\ContainerInterface; class DateTimeFormat { @@ -46,7 +45,7 @@ class DateTimeFormat $format = null; - if($lang) { + if ($lang) { switch ($output) { case "date" : $format = $lang->getDateFormat(); @@ -63,4 +62,4 @@ class DateTimeFormat return $format; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tools/I18n.php b/core/lib/Thelia/Tools/I18n.php index 4467bebcd..1f3ff57dd 100644 --- a/core/lib/Thelia/Tools/I18n.php +++ b/core/lib/Thelia/Tools/I18n.php @@ -54,4 +54,4 @@ class I18n return \DateTime::createFromFormat($currentDateFormat, $date); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tools/PhpUnitUtils.php b/core/lib/Thelia/Tools/PhpUnitUtils.php index 89bd3b148..e60c22fe1 100644 --- a/core/lib/Thelia/Tools/PhpUnitUtils.php +++ b/core/lib/Thelia/Tools/PhpUnitUtils.php @@ -50,6 +50,7 @@ class PhpUnitUtils $class = new \ReflectionClass(get_class($obj)); $method = $class->getMethod($name); $method->setAccessible(true); + return $method->invokeArgs($obj, $args); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tools/Rest/ResponseRest.php b/core/lib/Thelia/Tools/Rest/ResponseRest.php index 8618d460f..75d511d78 100644 --- a/core/lib/Thelia/Tools/Rest/ResponseRest.php +++ b/core/lib/Thelia/Tools/Rest/ResponseRest.php @@ -9,7 +9,6 @@ use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; - /** * Class ResponseRest Create a serialized Response * diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index ffb81992d..d0dcd127d 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -62,9 +62,9 @@ class URL * @throws \RuntimeException if the class has not been instanciated. * @return \Thelia\Tools\URL the instance. */ - public static function getInstance() { + public static function getInstance() + { if (self::$instance == null) throw new \RuntimeException("URL instance is not initialized."); - return self::$instance; } @@ -122,7 +122,7 @@ class URL $base_url = $this->getBaseUrl(); // TODO fix this ugly patch - if(strpos($path, "index_dev.php")) { + if (strpos($path, "index_dev.php")) { $path = str_replace('index_dev.php', '', $path); } @@ -148,7 +148,6 @@ class URL $sepChar = strstr($base, '?') === false ? '?' : '&'; if ('' !== $queryString = rtrim($queryString, "&")) $queryString = $sepChar . $queryString; - return $base . $queryString; } @@ -192,12 +191,12 @@ class URL */ public function retrieve($view, $viewId, $viewLocale) { - if(ConfigQuery::isRewritingEnable()) { + if (ConfigQuery::isRewritingEnable()) { $this->retriever->loadViewUrl($view, $viewLocale, $viewId); } else { $allParametersWithoutView = array(); $allParametersWithoutView['locale'] = $viewLocale; - if(null !== $viewId) { + if (null !== $viewId) { $allParametersWithoutView[$view . '_id'] = $viewId; } $this->retriever->rewrittenUrl = null; @@ -216,19 +215,19 @@ class URL */ public function retrieveCurrent(Request $request) { - if(ConfigQuery::isRewritingEnable()) { + if (ConfigQuery::isRewritingEnable()) { $view = $request->attributes->get('_view', null); $viewLocale = $request->query->get('locale', null); $viewId = $view === null ? null : $request->query->get($view . '_id', null); $allOtherParameters = $request->query->all(); - if($view !== null) { + if ($view !== null) { unset($allOtherParameters['view']); - if($viewId !== null) { + if ($viewId !== null) { unset($allOtherParameters[$view . '_id']); } } - if($viewLocale !== null) { + if ($viewLocale !== null) { unset($allOtherParameters['locale']); } @@ -236,7 +235,7 @@ class URL } else { $allParametersWithoutView = $viewOtherParameters; $allParametersWithoutView['locale'] = $viewLocale; - if(null !== $viewId) { + if (null !== $viewId) { $allParametersWithoutView[$view . '_id'] = $viewId; } $this->retriever->rewrittenUrl = null; @@ -256,6 +255,7 @@ class URL public function resolve($url) { $this->resolver->load($url); + return $this->resolver; } -} \ No newline at end of file +} diff --git a/install/insert.sql b/install/insert.sql index 8b577fb8e..da1414ce3 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -7,6 +7,7 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`date_format`,`time_format INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES ('session_config.default', '1', 1, 1, NOW(), NOW()), ('verifyStock', '1', 0, 0, NOW(), NOW()), +('active-template', 'default', 0, 0, NOW(), NOW()), ('default_lang_without_translation', '1', 0, 0, NOW(), NOW()), ('rewriting_enable', '0', 0, 0, NOW(), NOW()), ('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()), @@ -15,7 +16,8 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat ('images_library_path', 'local/media/images', 0, 0, NOW(), NOW()), ('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()), ('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()), -('page_not_found_view', '404.html', 0, 0, NOW(), NOW()); +('page_not_found_view', '404.html', 0, 0, NOW(), NOW()), +('use_tax_free_amounts', 1, 1, 0, NOW(), NOW()); INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES diff --git a/install/thelia.sql b/install/thelia.sql index d38d45379..0346ffba8 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1213,14 +1213,13 @@ DROP TABLE IF EXISTS `product_price`; CREATE TABLE `product_price` ( - `id` INTEGER NOT NULL AUTO_INCREMENT, `product_sale_elements_id` INTEGER NOT NULL, `currency_id` INTEGER NOT NULL, `price` FLOAT NOT NULL, `promo_price` FLOAT, `created_at` DATETIME, `updated_at` DATETIME, - PRIMARY KEY (`id`), + PRIMARY KEY (`product_sale_elements_id`,`currency_id`), INDEX `idx_product_price_product_sale_elements_id` (`product_sale_elements_id`), INDEX `idx_product_price_currency_id` (`currency_id`), CONSTRAINT `fk_product_price_product_sale_elements_id` diff --git a/local/config/schema.xml b/local/config/schema.xml index 39f649650..afb7b2c41 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,4 +1,4 @@ - + @@ -924,9 +924,8 @@
- - - + + diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/DebugBar/DataCollector/PropelCollector.php index 881b1b64a..823a31666 100644 --- a/local/modules/DebugBar/DataCollector/PropelCollector.php +++ b/local/modules/DebugBar/DataCollector/PropelCollector.php @@ -115,14 +115,52 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa */ public function log($level, $message, array $context = array()) { + list($sql, $duration_str) = $this->parseAndLogSqlQuery($message); + + $message = "$sql ($duration_str)"; + } + + /** + * Parse a log line to extract query information + * + * @param string $message + */ + protected function parseAndLogSqlQuery($message) + { + $parts = explode('|', $message, 3); + $duration = 0; + $memory = 0; + if (count($parts) > 1) { + $sql = trim($parts[2]); + + if (preg_match('/([0-9]+\.[0-9]+)/', $parts[0], $matches)) { + $duration = (float) $matches[1]; + } + + if (preg_match('/([0-9]+\.[0-9]+)([A-Z]{1,2})/', $parts[1], $matches)) { + $memory = (float) $matches[1]; + if ($matches[2] == 'KB') { + $memory *= 1024; + } else if ($matches[2] == 'MB') { + $memory *= 1024 * 1024; + } + } + } else { + $sql = $parts[0]; + } + + $this->statements[] = array( - 'sql' => $message, + 'sql' => $sql, 'is_success' => true, - 'duration' => 0, - 'duration_str' => $this->formatDuration(1), - 'memory' => 1, - 'memory_str' => $this->formatBytes(1) + 'duration' => $duration, + 'duration_str' => $this->formatDuration($duration), + 'memory' => $memory, + 'memory_str' => $this->formatBytes($memory) ); + $this->accumulatedTime += $duration; + $this->peakMemory = max($this->peakMemory, $memory); + return array($sql, $this->formatDuration($duration)); } /** diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php index 9a333b1d6..70a896433 100644 --- a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php +++ b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php @@ -26,6 +26,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\an; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use DebugBar\DebugBar as BaseDebugBar; +use Thelia\Tools\URL; /** * Class DebugBar @@ -52,12 +53,63 @@ class DebugBar extends AbstractSmartyPlugin return $render; } + public function renderCss($params, \Smarty_Internal_Template $template) + { + $render = ""; + if($this->debugMode) + { + $webFile = "cache/debugbar.css"; + $cssFile = THELIA_WEB_DIR ."/".$webFile; + + if(!file_exists($cssFile)) { + $javascriptRenderer = $this->debugBar->getJavascriptRenderer(); + $assetCss = $javascriptRenderer->getAsseticCollection("css"); + + foreach($assetCss->all() as $asset) { + if(strpos($asset->getSourcePath(), "font-awesome") !== false) { + $assetCss->removeLeaf($asset); + } + } + + file_put_contents($cssFile, $assetCss->dump()); + } + $render = sprintf('', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE)); + } + return $render; + } + + public function renderJs($params, \Smarty_Internal_Template $template) + { + $render = ""; + if($this->debugMode) + { + $webFile = "cache/debugbar.js"; + $cacheFile = THELIA_WEB_DIR ."/".$webFile; + + if (!file_exists($cacheFile)) { + $javascriptRenderer = $this->debugBar->getJavascriptRenderer(); + $assetJs = $javascriptRenderer->getAsseticCollection("js"); + + foreach($assetJs->all() as $asset) { + if(strpos($asset->getSourcePath(), "jquery") !== false) { + $assetJs->removeLeaf($asset); + } + } + + file_put_contents($cacheFile, $assetJs->dump()); + } + + $render = sprintf('', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE)); + } + return $render; + } + public function renderHead($params, \Smarty_Internal_Template $template) { $render = ""; if ($this->debugMode) { $javascriptRenderer = $this->debugBar->getJavascriptRenderer(); - $assets = $javascriptRenderer->getAsseticCollection(); + $assets = $javascriptRenderer->getAssets(); $cssCollection = $assets[0]; $jsCollection = $assets[1]; @@ -75,8 +127,9 @@ class DebugBar extends AbstractSmartyPlugin public function getPluginDescriptors() { return array( - new SmartyPluginDescriptor("function", "debugbar_renderHead", $this, "renderHead"), - new SmartyPluginDescriptor("function", "debugbar_render", $this, "render") + new SmartyPluginDescriptor("function", "debugbar_rendercss", $this, "renderCss"), + new SmartyPluginDescriptor("function", "debugbar_renderjs", $this, "renderJs"), + new SmartyPluginDescriptor("function", "debugbar_renderresult", $this, "render") ); } } \ No newline at end of file diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 1a21b9165..942557600 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -23,7 +23,7 @@ {/stylesheets} - {debugbar_renderHead} + {debugbar_rendercss} {block name="after-bootstrap-css"}{/block} @@ -36,8 +36,6 @@ {* Modules css are included here *} {module_include location='head_css'} - - {debugbar_renderHead} @@ -225,11 +223,13 @@ + {debugbar_renderjs} + {debugbar_renderresult} + {block name="after-javascript-include"}{/block} {block name="javascript-initialization"}{/block} - {debugbar_render} {* Modules scripts are included now *} {module_include location='footer_js'} diff --git a/templates/admin/default/includes/generic-js-dialog.html b/templates/admin/default/includes/generic-js-dialog.html index f1be39f03..051aefd29 100644 --- a/templates/admin/default/includes/generic-js-dialog.html +++ b/templates/admin/default/includes/generic-js-dialog.html @@ -15,7 +15,7 @@ Parameters: {* re-display the form creation dialog if it contains errors *} {form name="{$form_name}"} - {if #form_error} + {if $form_error} $('#{$dialog_id}').modal(); {/if} {/form} diff --git a/templates/admin/default/includes/thelia_news_feed.html b/templates/admin/default/includes/thelia_news_feed.html index 8ef8e2528..6b957c426 100755 --- a/templates/admin/default/includes/thelia_news_feed.html +++ b/templates/admin/default/includes/thelia_news_feed.html @@ -3,8 +3,8 @@ {loop type="feed" name="thelia_feeds" url="http://thelia.net/Flux-rss.html?id_rubrique=8" limit="3"}

{$DATE}

-

{$TITLE|strip_tags}

+

{$TITLE|strip_tags}

{$DESCRIPTION|strip_tags|truncate:250:"...":true}

-

{intl l='Lire la suite »'}

+

{intl l='Lire la suite »'}

{/loop} diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 6bf781a3c..3b2fe5dcd 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -30,7 +30,7 @@ URL: http://www.thelia.net {stylesheets file='assets/less/styles.less' filters='less,cssembed'} {/stylesheets} - + {debugbar_rendercss} {block name="stylesheet"}{/block} @@ -397,6 +397,9 @@ URL: http://www.thelia.net {/javascripts} +{debugbar_renderjs} +{debugbar_renderresult} + diff --git a/templates/default_save/includes/footer.html b/templates/default_save/includes/footer.html index 2f14e2fd8..0b876c3ac 100755 --- a/templates/default_save/includes/footer.html +++ b/templates/default_save/includes/footer.html @@ -13,6 +13,7 @@ }); }); - {debugbar_render} + {debugbar_renderjs} + {debugbar_renderresult} \ No newline at end of file diff --git a/templates/default_save/includes/header.html b/templates/default_save/includes/header.html index b605ecbb7..7161145a5 100755 --- a/templates/default_save/includes/header.html +++ b/templates/default_save/includes/header.html @@ -7,7 +7,7 @@ {stylesheets file='../assets/css/*' filters='less,cssembed'} {/stylesheets} - {debugbar_renderHead} + {debugbar_rendercss}
diff --git a/templates/default_save/product.html b/templates/default_save/product.html index f3d6a4cb6..f78b7e296 100755 --- a/templates/default_save/product.html +++ b/templates/default_save/product.html @@ -6,14 +6,14 @@ Index : {navigate to="index"}
{ifloop rel="product"} -{loop type="product" name="product" current="true"} +{loop type="product" name="product" current="true" min_price="50" max_price="100"}

PRODUCT ({$ID}) : {$REF}

{$TITLE}

{$DESCRIPTION}

-

Starting by {$BEST_PRICE} € HT (TAX : {$BEST_PRICE_TAX} ; {$BEST_TAXED_PRICE} € TTC)

+

Starting by {$BEST_PRICE} {currency attr="symbol"} HT (TAX : {$BEST_PRICE_TAX} ; {$BEST_TAXED_PRICE} {currency attr="symbol"} TTC)

{ifloop rel="acc"}

Accessories

@@ -66,7 +66,7 @@ Index : {navigate to="index"}
{$ATTRIBUTE_TITLE} = {$ATTRIBUTE_AVAILABILITY_TITLE}
{/loop}
{$WEIGHT} g -
{if $IS_PROMO == 1} {$PROMO_PRICE} € HT // TAX : {$PROMO_PRICE_TAX} ; {$TAXED_PROMO_PRICE} € TTC (instead of {$PRICE HT} // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} € TTC){else} {$PRICE} € HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} € TTC{/if} +
{if $IS_PROMO == 1} {$PROMO_PRICE} {currency attr="symbol"} HT // TAX : {$PROMO_PRICE_TAX} ; {$TAXED_PROMO_PRICE} {currency attr="symbol"} TTC (instead of {$PRICE_HT} // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC){else} {$PRICE} {currency attr="symbol"} HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC{/if}

Add