diff --git a/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php b/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php new file mode 100644 index 000000000..a52f0eb86 --- /dev/null +++ b/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Core\HttpKernel\Exceptions; + +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as BaseNotFountHttpException; +/** + * Class NotFountHttpException + * @author Manuel Raynaud + */ +class NotFountHttpException extends BaseNotFountHttpException { + + protected $adminContext = false; + + public function __construct($message = null, \Exception $previous = null, $code = 0, $adminContext = false) + { + $this->adminContext = $adminContext; + + parent::__construct($message, $previous, $code); + } + + public function isAdminContext() + { + return $this->adminContext === true; + + } +} \ 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 6ed09fe2b..37801f4c8 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -67,12 +67,12 @@ class TheliaLoop extends AbstractSmartyPlugin * * @return \PropelModelPager */ - public static function getPagination($loopId) + public static function getPagination($loopName) { - if (!empty(self::$pagination[$loopId])) { - return self::$pagination[$loopId]; + if (array_key_exists($loopName, self::$pagination)) { + return self::$pagination[$loopName]; } else { - return null; + throw new \InvalidArgumentException("Loop $loopName is not defined"); } } @@ -242,16 +242,10 @@ class TheliaLoop extends AbstractSmartyPlugin if (null == $loopName) throw new \InvalidArgumentException("Missing 'rel' parameter in page loop"); - // Find loop results in the current template vars - /* $loopResults = $template->getTemplateVars($loopName); - if (empty($loopResults)) { - throw new \InvalidArgumentException("Loop $loopName is not defined."); - }*/ - // Find pagination $pagination = self::getPagination($loopName); - if ($pagination === null) { - throw new \InvalidArgumentException("Loop $loopName is not defined"); + if ($pagination === null) { // loop gas no result + return ''; } if ($pagination->getNbResults() == 0) { diff --git a/core/lib/Thelia/Model/Address.php b/core/lib/Thelia/Model/Address.php index 5ce697e8f..dbd334ba2 100755 --- a/core/lib/Thelia/Model/Address.php +++ b/core/lib/Thelia/Model/Address.php @@ -58,6 +58,10 @@ class Address extends BaseAddress { */ public function preDelete(ConnectionInterface $con = null) { + if($this->getIsDefault()) { + return false; + } + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this)); return true; } @@ -71,14 +75,4 @@ class Address extends BaseAddress { $this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this)); } - public function preSave() - { - $valid = true; - if($this->getIsDefault()) { - $valid = false; - } - - return $valid; - } - } diff --git a/core/lib/Thelia/Rewriting/RewritingRetriever.php b/core/lib/Thelia/Rewriting/RewritingRetriever.php index 8289942f2..dfdbab05c 100755 --- a/core/lib/Thelia/Rewriting/RewritingRetriever.php +++ b/core/lib/Thelia/Rewriting/RewritingRetriever.php @@ -56,12 +56,14 @@ class RewritingRetriever * @param $viewLocale * @param null $viewId */ - public function loadViewUrl($view, $viewLocale, $viewId = null) + public function loadViewUrl($view, $viewLocale = null, $viewId = null) { $this->search = $this->rewritingUrlQuery->getViewUrlQuery($view, $viewLocale, $viewId); $allParametersWithoutView = array(); - $allParametersWithoutView['locale'] = $viewLocale; + if(null !== $viewId) { + $allParametersWithoutView['locale'] = $viewLocale; + } if(null !== $viewId) { $allParametersWithoutView[$view . '_id'] = $viewId; } diff --git a/core/lib/Thelia/Tests/Action/CustomerTest.php b/core/lib/Thelia/Tests/Action/CustomerTest.php index b70d39428..10ba01587 100644 --- a/core/lib/Thelia/Tests/Action/CustomerTest.php +++ b/core/lib/Thelia/Tests/Action/CustomerTest.php @@ -86,6 +86,8 @@ class CustomerTest extends \PHPUnit_Framework_TestCase $addressCreated = $customerCreated->getDefaultAddress(); + $this->assertInstanceOf("Thelia\Model\Address", $addressCreated); + $this->assertEquals($customerCreateEvent->getFirstname(), $addressCreated->getFirstname()); $this->assertEquals($customerCreateEvent->getLastname(), $addressCreated->getLastname()); $this->assertEquals($customerCreateEvent->getTitle(), $addressCreated->getTitleId()); diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 05084c0c1..b415844cd 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -232,10 +232,10 @@ class URL $this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters); } else { - $allParametersWithoutView = $viewOtherParameters; - $allParametersWithoutView['locale'] = $viewLocale; - if (null !== $viewId) { - $allParametersWithoutView[$view . '_id'] = $viewId; + $allParametersWithoutView = $request->query->all(); + $view = $request->attributes->get('_view'); + if(isset($allOtherParameters['view'])) { + unset($allOtherParameters['view']); } $this->retriever->rewrittenUrl = null; $this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView); diff --git a/templates/default_save/debug.html b/templates/default_save/debug.html index 5f2d2965d..a00acf9d3 100755 --- a/templates/default_save/debug.html +++ b/templates/default_save/debug.html @@ -1,5 +1,8 @@ -{*loop type="product" name="fsdq"} - {format_date date=$CREATE_DATE} -{/loop*} +

Category page

-::{product attr="createdAt" output="time" format='i'};;
\ No newline at end of file +{loop type="category" name="categoryloop" id="500"} + TOTO +{/loop} + +{pageloop rel="categoryloop"} +{/pageloop} \ No newline at end of file diff --git a/templates/default_save/index.html b/templates/default_save/index.html index 53834febf..7ca21bccb 100755 --- a/templates/default_save/index.html +++ b/templates/default_save/index.html @@ -1,6 +1,8 @@ {include file="includes/header.html"}
+ Here you are : {navigate to="current"} + {loop type="auth" name="auth_test" context="front" roles="CUSTOMER"}

Customer is authentified :-)