fix typo in method name
This commit is contained in:
@@ -59,7 +59,7 @@ abstract class ActionEvent extends Event
|
||||
public function __construct(Request $request, $action)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->action = $action;
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,6 +89,32 @@ final class TheliaEvents
|
||||
*/
|
||||
const CREATECUSTOMER_CUSTOMREF = "customer.creation.customref";
|
||||
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
*/
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful insert of a new category in the database.
|
||||
*/
|
||||
const AFTER_CREATECATEGORY = "action.after_createcategory";
|
||||
/**
|
||||
* Sent befonre deleting a category
|
||||
*/
|
||||
const BEFORE_DELETECATEGORY = "action.before_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful delete of a category from the database.
|
||||
*/
|
||||
const AFTER_DELETECATEGORY = "action.after_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful change of a category in the database.
|
||||
*/
|
||||
const AFTER_CHANGECATEGORY = "action.after_changecategory";
|
||||
|
||||
|
||||
/**
|
||||
* sent when a new existing cat id duplicated. This append when current customer is different from current cart
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,6 @@ class ActionEventFactory
|
||||
{
|
||||
if (array_key_exists($this->action, $this->className)) {
|
||||
$class = new \ReflectionClass($this->className[$this->action]);
|
||||
|
||||
// return $class->newInstance($this->request, $this->action);
|
||||
} else {
|
||||
$class = new \ReflectionClass($this->defaultClassName);
|
||||
|
||||
@@ -78,26 +78,6 @@ class Session extends BaseSession
|
||||
return $this->remove('admin_user');
|
||||
}
|
||||
|
||||
// -- Error form -----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param string $formName the form name
|
||||
*/
|
||||
public function setErrorFormName($formName)
|
||||
{
|
||||
$this->set('error_form', $formName);
|
||||
}
|
||||
|
||||
public function getErrorFormName()
|
||||
{
|
||||
return $this->get('error_form', null);
|
||||
}
|
||||
|
||||
public function clearErrorFormName()
|
||||
{
|
||||
return $this->remove('error_form');
|
||||
}
|
||||
|
||||
// -- Return page ----------------------------------------------------------
|
||||
|
||||
public function setReturnToUrl($url)
|
||||
|
||||
@@ -107,7 +107,7 @@ class SecurityContext {
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
final public function isGranted($roles, $permissions)
|
||||
final public function isGranted(array $roles, array $permissions)
|
||||
{
|
||||
if ($this->isAuthenticated() === true) {
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ abstract class BaseLoop
|
||||
return array(
|
||||
Argument::createIntTypeArgument('offset', 0),
|
||||
Argument::createIntTypeArgument('page'),
|
||||
Argument::createIntTypeArgument('limit', 10),
|
||||
Argument::createIntTypeArgument('limit', PHP_INT_MAX),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,19 @@ class Argument
|
||||
);
|
||||
}
|
||||
|
||||
public static function createBooleanOrBothTypeArgument($name, $default=null, $mandatory=false, $empty=true)
|
||||
{
|
||||
return new Argument(
|
||||
$name,
|
||||
new TypeCollection(
|
||||
new Type\BooleanOrBothType()
|
||||
),
|
||||
$default,
|
||||
$mandatory,
|
||||
$empty
|
||||
);
|
||||
}
|
||||
|
||||
public static function createIntListTypeArgument($name, $default=null, $mandatory=false, $empty=true)
|
||||
{
|
||||
return new Argument(
|
||||
|
||||
@@ -11,8 +11,37 @@ namespace Thelia\Core\Template\Loop;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
class Cart extends BaseLoop {
|
||||
use \Thelia\Cart\CartTrait;
|
||||
/**
|
||||
*
|
||||
* define all args used in your loop
|
||||
*
|
||||
* array key is your arg name.
|
||||
*
|
||||
* example :
|
||||
*
|
||||
* return array (
|
||||
* "ref",
|
||||
* "id" => "optional",
|
||||
* "stock" => array(
|
||||
* "optional",
|
||||
* "default" => 10
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -42,30 +71,33 @@ class Cart extends BaseLoop {
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
// TODO: Implement exec() method.
|
||||
$result = new LoopResult();
|
||||
$cart = $this->getCart($this->request);
|
||||
|
||||
if($cart === null) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
$cartItems = $cart->getCartItems();
|
||||
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
//$product->setLocale($this->request->getSession()->getLocale());
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow->set("ITEM_ID", $cartItem->getId());
|
||||
$loopResultRow->set("TITLE", $product->getTitle());
|
||||
$loopResultRow->set("REF", $product->getRef());
|
||||
$loopResultRow->set("QUANTITY", $cartItem->getQuantity());
|
||||
$loopResultRow->set("PRICE", $cartItem->getPrice());
|
||||
$loopResultRow->set("PRODUCT_ID", $product->getId());
|
||||
$result->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* define all args used in your loop
|
||||
*
|
||||
* array key is your arg name.
|
||||
*
|
||||
* example :
|
||||
*
|
||||
* return array (
|
||||
* "ref",
|
||||
* "id" => "optional",
|
||||
* "stock" => array(
|
||||
* "optional",
|
||||
* "default" => 10
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
// TODO: Implement getArgDefinitions() method.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -73,7 +74,7 @@ class Category extends BaseLoop
|
||||
Argument::createIntTypeArgument('parent'),
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('not_empty', 0),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -122,7 +123,8 @@ class Category extends BaseLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
if ($this->getVisible() != BooleanOrBothType::ANY)
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -68,7 +69,7 @@ class CategoryPath extends BaseLoop
|
||||
Argument::createIntTypeArgument('category', null, true),
|
||||
Argument::createIntTypeArgument('depth'),
|
||||
Argument::createIntTypeArgument('level'),
|
||||
Argument::createBooleanTypeArgument('visible', true, false)
|
||||
Argument::createBooleanOrBothTypeArgument('visible', true, false)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,10 +85,12 @@ class CategoryPath extends BaseLoop
|
||||
|
||||
$search = CategoryQuery::create();
|
||||
$search->filterById($id);
|
||||
if ($visible == true) $search->filterByVisible($visible);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$results = array();
|
||||
|
||||
$ids = array();
|
||||
|
||||
do {
|
||||
$category = $search->findOne();
|
||||
|
||||
@@ -106,6 +109,14 @@ class CategoryPath extends BaseLoop
|
||||
$parent = $category->getParent();
|
||||
|
||||
if ($parent > 0) {
|
||||
|
||||
// Prevent circular refererences
|
||||
if (in_array($parent, $ids)) {
|
||||
throw new \LogicException(sprintf("Circular reference detected in category ID=%d hierarchy (category ID=%d appears more than one times in path)", $id, $parent));
|
||||
}
|
||||
|
||||
$ids[] = $parent;
|
||||
|
||||
$search = CategoryQuery::create();
|
||||
$search->filterById($parent);
|
||||
if ($visible == true) $search->filterByVisible($visible);
|
||||
|
||||
@@ -41,6 +41,7 @@ use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -64,7 +65,7 @@ class Content extends BaseLoop
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('current_folder'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -148,7 +149,7 @@ class Content extends BaseLoop
|
||||
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search->filterByVisible($visible);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,7 +62,7 @@ class Feature extends BaseLoop
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('product'),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
@@ -96,7 +97,7 @@ class Feature extends BaseLoop
|
||||
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search->filterByVisible($visible);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
|
||||
@@ -36,6 +36,7 @@ use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
* Class Folder
|
||||
@@ -55,7 +56,7 @@ class Folder extends BaseLoop
|
||||
Argument::createIntTypeArgument('parent'),
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('not_empty', 0),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -104,7 +105,9 @@ class Folder extends BaseLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
$visible = $this->getVisible();
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -80,7 +81,7 @@ class Product extends BaseLoop
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('current_category'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -252,11 +253,10 @@ class Product extends BaseLoop
|
||||
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search->filterByVisible($visible);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
|
||||
@@ -101,7 +101,8 @@ class Form extends AbstractSmartyPlugin
|
||||
// Re-use the errored form
|
||||
$instance = $errorForm;
|
||||
|
||||
$this->parserContext->clearErrorForm();
|
||||
// Don't do that, as we may want to use this form firther in the template code
|
||||
//$this->parserContext->clearErrorForm();
|
||||
}
|
||||
|
||||
$instance->createView();
|
||||
|
||||
@@ -49,7 +49,7 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
// the path to process
|
||||
$path = $this->getParam($params, 'path');
|
||||
|
||||
return URL::absoluteUrl($path, $this->getArgsFromParam($params));
|
||||
return URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
// the related action (optionale)
|
||||
$action = $this->getParam($params, 'action');
|
||||
|
||||
$args = $this->getArgsFromParam($params);
|
||||
$args = $this->getArgsFromParam($params, array('view', 'action'));
|
||||
|
||||
if (! empty($action)) $args['action'] = $action;
|
||||
|
||||
@@ -92,17 +92,23 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL parameters array from a comma separated list or arguments in the
|
||||
* parameters.
|
||||
* Get URL parameters array from parameters.
|
||||
*
|
||||
* @param array $params Smarty function params
|
||||
* @return array the parameters array (either emply, of valued)
|
||||
*/
|
||||
private function getArgsFromParam($params) {
|
||||
private function getArgsFromParam($params, $exclude = array()) {
|
||||
|
||||
$args = $this->getParam($params, array('arguments', 'args'));
|
||||
$pairs = array();
|
||||
|
||||
return $args !== null ? explode($args, ',') : array();
|
||||
foreach($params as $name => $value) {
|
||||
|
||||
if (in_array($name, $exclude)) continue;
|
||||
|
||||
$pairs[$name] = $value;
|
||||
}
|
||||
|
||||
return $pairs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user