Fixed customer front controller, events, addec admion config.
This commit is contained in:
44
core/lib/Thelia/Core/Event/CategoryChangeEvent.php
Normal file
44
core/lib/Thelia/Core/Event/CategoryChangeEvent.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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\Event;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryCreateEvent extends ActionEvent
|
||||
{
|
||||
protected $category_id;
|
||||
protected $locale;
|
||||
protected $title;
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
protected $url;
|
||||
protected $visibility;
|
||||
protected $parent;
|
||||
|
||||
public function __construct($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
}
|
||||
@@ -30,28 +30,18 @@ class CategoryChangePositionEvent extends ActionEvent
|
||||
const POSITION_DOWN = 2;
|
||||
const POSITION_ABSOLUTE = 3;
|
||||
|
||||
protected $id;
|
||||
protected $category_id;
|
||||
protected $mode;
|
||||
protected $position;
|
||||
protected $category;
|
||||
|
||||
public function __construct($id, $mode, $position = null)
|
||||
public function __construct($category_id, $mode, $position = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->category_id = $category_id;
|
||||
$this->mode = $mode;
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getMode()
|
||||
{
|
||||
return $this->mode;
|
||||
@@ -81,4 +71,15 @@ class CategoryChangePositionEvent extends ActionEvent
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategoryId()
|
||||
{
|
||||
return $this->category_id;
|
||||
}
|
||||
|
||||
public function setCategoryId($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,5 @@ class CategoryCreateEvent extends ActionEvent
|
||||
public function setCreatedCategory(Category $created_category)
|
||||
{
|
||||
$this->created_category = $created_category;
|
||||
var_dump($this->created_category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,22 +26,22 @@ use Thelia\Model\Category;
|
||||
|
||||
class CategoryDeleteEvent extends ActionEvent
|
||||
{
|
||||
protected $id;
|
||||
protected $category_id;
|
||||
protected $deleted_category;
|
||||
|
||||
public function __construct($id)
|
||||
public function __construct($category_id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
public function getCategoryId()
|
||||
{
|
||||
return $this->id;
|
||||
return $this->category_id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
public function setCategoryId($category_id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
|
||||
public function getDeletedCategory()
|
||||
|
||||
@@ -26,22 +26,22 @@ use Thelia\Model\Category;
|
||||
|
||||
class CategoryToggleVisibilityEvent extends ActionEvent
|
||||
{
|
||||
protected $id;
|
||||
protected $category_id;
|
||||
protected $category;
|
||||
|
||||
public function __construct($id)
|
||||
public function __construct($category_id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
public function getCategoryId()
|
||||
{
|
||||
return $this->id;
|
||||
return $this->category_id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
public function setCategoryId($category_id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
class CustomerLoginEvent {
|
||||
class CustomerLoginEvent extends ActionEvent {
|
||||
|
||||
protected $customer;
|
||||
|
||||
|
||||
@@ -59,12 +59,7 @@ class ControllerListener implements EventSubscriberInterface
|
||||
$event = new ActionEventFactory($request, $action, $event->getKernel()->getContainer()->getParameter("thelia.actionEvent"));
|
||||
$actionEvent = $event->createActionEvent();
|
||||
$dispatcher->dispatch("action.".$action, $actionEvent);
|
||||
|
||||
// Process form errors
|
||||
if ($actionEvent->hasErrorForm()) {
|
||||
$this->parserContext->setErrorForm($actionEvent->getErrorForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
|
||||
@@ -55,8 +55,6 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface
|
||||
);
|
||||
|
||||
$this->options = array_merge($defaults, $options);
|
||||
|
||||
$this->loginForm->bind($this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,6 +60,16 @@ class SecurityContext
|
||||
return $this->getSession()->getAdminUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an admin user is logged in.
|
||||
*
|
||||
* @return true if an admin user is logged in, false otherwise.
|
||||
*/
|
||||
public function hasAdminUser()
|
||||
{
|
||||
return $this->getSession()->getAdminUser() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently authenticated customer, or null if none is defined
|
||||
*
|
||||
@@ -70,6 +80,16 @@ class SecurityContext
|
||||
return $this->getSession()->getCustomerUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a customer user is logged in.
|
||||
*
|
||||
* @return true if a customer is logged in, false otherwise.
|
||||
*/
|
||||
public function hasCustomerUser()
|
||||
{
|
||||
return $this->getSession()->getCustomerUser() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user has at least one of the required roles
|
||||
*
|
||||
|
||||
@@ -138,7 +138,7 @@ abstract class BaseLoop
|
||||
} elseif ($value !== null && !$argument->type->isValid($value)) {
|
||||
/* check type */
|
||||
$faultActor[] = $argument->name;
|
||||
$faultDetails[] = sprintf('Invalid value for "%s" argument in loop type: %s, name: %s', $argument->name, $loopType, $loopName);
|
||||
$faultDetails[] = sprintf('Invalid value "%s" for "%s" argument in loop type: %s, name: %s', $value, $argument->name, $loopType, $loopName);
|
||||
} else {
|
||||
/* set default */
|
||||
/* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
|
||||
|
||||
@@ -79,7 +79,7 @@ class Category extends BaseLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'random'))
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'visible', 'visible_reverse', 'random'))
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
@@ -146,6 +146,12 @@ class Category extends BaseLoop
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "visible":
|
||||
$search->orderByVisible(Criteria::ASC);
|
||||
break;
|
||||
case "visible_reverse":
|
||||
$search->orderByVisible(Criteria::DESC);
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
@@ -173,7 +179,7 @@ class Category extends BaseLoop
|
||||
$loopResultRow
|
||||
->set("ID", $category->getId())
|
||||
->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("TITLE",$category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("TITLE", $category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
|
||||
@@ -63,7 +63,6 @@ class Image extends BaseLoop
|
||||
|
||||
$queryClass = sprintf("\Thelia\Model\%sImageQuery", $object);
|
||||
$filterMethod = sprintf("filterBy%sId", $object);
|
||||
$mapClass = sprintf("\Thelia\Model\Map\%sI18nTableMap", $object);
|
||||
|
||||
// xxxImageQuery::create()
|
||||
$method = new \ReflectionMethod($queryClass, 'create');
|
||||
@@ -73,19 +72,16 @@ class Image extends BaseLoop
|
||||
$method = new \ReflectionMethod($queryClass, $filterMethod);
|
||||
$method->invoke($search, $object_id);
|
||||
|
||||
$map = new \ReflectionClass($mapClass);
|
||||
$title_map = $map->getConstant('TITLE');
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
// Results ordering
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn($title_map);
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn($title_map);
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual-reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
@@ -122,7 +118,7 @@ class Image extends BaseLoop
|
||||
|
||||
$source_id = $this->getSourceId();
|
||||
|
||||
// echo "source = ".$this->getSource().", id=".$id."<br />";
|
||||
// echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."<br />";
|
||||
|
||||
if (is_null($source_id)) {
|
||||
throw new \InvalidArgumentException("'source_id' argument cannot be null if 'source' argument is specified.");
|
||||
@@ -167,6 +163,9 @@ class Image extends BaseLoop
|
||||
|
||||
$search = $this->getSearchQuery($object_type, $object_id);
|
||||
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (! is_null($id)) {
|
||||
@@ -207,8 +206,7 @@ class Image extends BaseLoop
|
||||
|
||||
}
|
||||
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
|
||||
@@ -56,11 +56,15 @@ class ParserContext implements \IteratorAggregate
|
||||
public function setErrorForm(BaseForm $form)
|
||||
{
|
||||
$this->set('error_form', $form);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setGeneralError($error)
|
||||
{
|
||||
$this->set('general_error', $error);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getErrorForm()
|
||||
|
||||
Reference in New Issue
Block a user