From 7c4ebe6bf7507a4bc67eee0f327d4cce11db4553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Chans=C3=A9aume?= Date: Mon, 28 Apr 2014 12:30:31 +0200 Subject: [PATCH] php cs fixer --- .../Template/Smarty/Plugins/CartPostage.php | 39 +++++++------------ core/lib/Thelia/Tools/Redirect.php | 6 +-- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/CartPostage.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/CartPostage.php index 72f6947cf..151dfa1b8 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/CartPostage.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/CartPostage.php @@ -15,15 +15,10 @@ namespace Thelia\Core\Template\Smarty\Plugins; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Util\PropelModelPager; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Core\Template\Element\BaseLoop; -use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; -use Thelia\Core\Template\Element\Exception\ElementNotFoundException; -use Thelia\Core\Template\Element\Exception\InvalidElementException; use Thelia\Core\Translation\Translator; -use Thelia\Log\Tlog; use Thelia\Model\AddressQuery; use Thelia\Model\ConfigQuery; use Thelia\Model\Country; @@ -45,14 +40,12 @@ class CartPostage extends AbstractSmartyPlugin protected $loopDefinition = array(); - /** @var \Thelia\Core\HttpFoundation\Request The Request */ protected $request; /** @var \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher The Dispatcher */ protected $dispatcher; - /** @var \Thelia\Core\Security\SecurityContext The Security Context */ protected $securityContext; @@ -74,7 +67,6 @@ class CartPostage extends AbstractSmartyPlugin /** @var boolean $isCustomizable indicate if customer can change the country */ protected $isCustomizable = true; - /** * @param ContainerInterface $container */ @@ -88,7 +80,6 @@ class CartPostage extends AbstractSmartyPlugin $this->translator = $container->get("thelia.translator"); } - /** * Get postage amount for cart * @@ -103,7 +94,7 @@ class CartPostage extends AbstractSmartyPlugin public function postage($params, $content, $template, &$repeat) { - if ( ! $repeat) { + if (! $repeat) { return $content; } @@ -122,28 +113,27 @@ class CartPostage extends AbstractSmartyPlugin $template->assign('is_customizable', $this->isCustomizable); } - /** * Retrieve the delivery country for a customer * * The rules : - * - the country of the delivery address of the customer related to the + * - the country of the delivery address of the customer related to the * cart if it exists - * - the country saved in cookie if customer have changed + * - the country saved in cookie if customer have changed * the default country * - the default country for the shop if exists * - the country related to the customer based on browser preferences * - default country * * - * @param \Thelia\Model\Customer $customer + * @param \Thelia\Model\Customer $customer * @return \Thelia\Model\Country */ protected function getDeliveryCountry(Customer $customer = null) { // get country from customer addresses - if (null !== $customer){ + if (null !== $customer) { $address = AddressQuery::create() ->filterByCustomerId($customer->getId()) ->filterByIsDefault(1) @@ -152,6 +142,7 @@ class CartPostage extends AbstractSmartyPlugin if (null !== $address) { $this->isCustomizable = false; + return $address->getCountry(); } } @@ -160,20 +151,20 @@ class CartPostage extends AbstractSmartyPlugin $cookieName = ConfigQuery::read('front_cart_country_cookie_name', 'fcccn'); if ($this->request->cookies->has($cookieName)) { $cookieVal = $this->request->cookies->getInt($cookieName, 0); - if (0 !== $cookieVal){ + if (0 !== $cookieVal) { $country = CountryQuery::create()->findPk($cookieVal); - if (null !== $country){ + if (null !== $country) { return $country; } } } // get default country for store. - try{ + try { $country = Country::getDefaultCountry(); + return $country; - } - catch (\LogicException $e) { + } catch (\LogicException $e) { ; } @@ -191,11 +182,10 @@ class CartPostage extends AbstractSmartyPlugin } - /** * Retrieve the cheapest delivery for country * - * @param \Thelia\Model\Country $country + * @param \Thelia\Model\Country $country * @return DeliveryModuleInterface */ protected function getCheapestDelivery(Country $country) @@ -207,7 +197,7 @@ class CartPostage extends AbstractSmartyPlugin ->find(); ; - foreach ($deliveryModules as $deliveryModule){ + foreach ($deliveryModules as $deliveryModule) { /** @var DeliveryModuleInterface $moduleInstance */ $moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode())); @@ -222,7 +212,7 @@ class CartPostage extends AbstractSmartyPlugin if ($moduleInstance->isValidDelivery($country)) { $postage = $moduleInstance->getPostage($country); - if ( null === $this->postage || $this->postage > $postage) { + if (null === $this->postage || $this->postage > $postage) { $this->postage = $postage; $this->deliveryId = $deliveryModule->getId(); } @@ -235,7 +225,6 @@ class CartPostage extends AbstractSmartyPlugin } - /** * Defines the various smarty plugins handled by this class * diff --git a/core/lib/Thelia/Tools/Redirect.php b/core/lib/Thelia/Tools/Redirect.php index 2411924bf..faad58b2e 100644 --- a/core/lib/Thelia/Tools/Redirect.php +++ b/core/lib/Thelia/Tools/Redirect.php @@ -22,10 +22,8 @@ class Redirect { if (false == Tlog::getInstance()->showRedirect($url)) { $response = new RedirectResponse($url, $status); - foreach ($cookies as $cookie) - { - if (!$cookie instanceof Cookie) - { + foreach ($cookies as $cookie) { + if (!$cookie instanceof Cookie) { throw new \InvalidArgumentException(sprintf('Third parameter is not a valid Cookie object.')); } $response->headers->setCookie($cookie);