Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Etienne Roudeix (1) and Manuel Raynaud (1) # Via Manuel Raynaud (2) and Etienne Roudeix (1) * 'master' of https://github.com/thelia/thelia: fix test suite fix current url bug + fix empty loop pagination exception
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Core\HttpKernel\Exceptions;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as BaseNotFountHttpException;
|
||||
/**
|
||||
* Class NotFountHttpException
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{*loop type="product" name="fsdq"}
|
||||
{format_date date=$CREATE_DATE}
|
||||
{/loop*}
|
||||
<h1>Category page</h1>
|
||||
|
||||
::{product attr="createdAt" output="time" format='i'};;<br />
|
||||
{loop type="category" name="categoryloop" id="500"}
|
||||
TOTO
|
||||
{/loop}
|
||||
|
||||
{pageloop rel="categoryloop"}
|
||||
{/pageloop}
|
||||
@@ -1,6 +1,8 @@
|
||||
{include file="includes/header.html"}
|
||||
<div>
|
||||
|
||||
Here you are : {navigate to="current"}
|
||||
|
||||
{loop type="auth" name="auth_test" context="front" roles="CUSTOMER"}
|
||||
|
||||
<p>Customer is authentified :-)</p>
|
||||
|
||||
Reference in New Issue
Block a user