Fixed getUrl()

This commit is contained in:
franck
2013-08-31 15:52:42 +02:00
parent 533f18bcec
commit 6d5d0f6606
17 changed files with 214 additions and 131 deletions

View File

@@ -77,7 +77,7 @@ class Config extends BaseAction implements EventSubscriberInterface
$search = ConfigQuery::create();
if (null !== $config = $search->findById($event->getConfigId())) {
if (null !== $config = $search->findOneById($event->getConfigId())) {
$config
->setDispatcher($this->getDispatcher())
@@ -98,7 +98,7 @@ class Config extends BaseAction implements EventSubscriberInterface
$search = ConfigQuery::create();
if (null !== $config = ConfigQuery::create()->findById($event->getConfigId())) {
if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) {
$config
->setDispatcher($this->getDispatcher())
@@ -127,10 +127,10 @@ class Config extends BaseAction implements EventSubscriberInterface
{
$this->checkAuth("ADMIN", "admin.configuration.variables.delete");
if (null !== $config = ConfigQuery::create()->findById($event->getConfigId())) {
if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) {
if (! $config->getSecured()) {
$config->setDispatcher($this->getDispatcher())->delete();
$config->setDispatcher($this->getDispatcher());
$config->delete();
}
}
}

View File

@@ -32,6 +32,11 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.category" class="Thelia\Action\Config">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -35,22 +35,22 @@
<default key="_controller">Thelia\Controller\Admin\CategoryController::processAction</default>
</route>
<!-- Routes to the Config controller -->
<!-- Routes to the Config (system variables) controller -->
<route id="admin.config.default" path="/admin/configuration/config">
<default key="_controller">Thelia\Controller\Admin\ConfigController::defaultAction</default>
<route id="admin.configuration.variables.default" path="/admin/configuration/variables">
<default key="_controller">Thelia\Controller\Admin\VariablesController::defaultAction</default>
</route>
<route id="admin.config.create" path="/admin/config/configuration/create">
<default key="_controller">Thelia\Controller\Admin\ConfigController::createAction</default>
<route id="admin.configuration.variables.create" path="/admin/configuration/variables/create">
<default key="_controller">Thelia\Controller\Admin\VariablesController::createAction</default>
</route>
<route id="admin.config.change" path="/admin/config/configuration/change">
<default key="_controller">Thelia\Controller\Admin\ConfigController::changeAction</default>
<route id="admin.configuration.variables.change" path="/admin/configuration/variables/change">
<default key="_controller">Thelia\Controller\Admin\VariablesController::changeAction</default>
</route>
<route id="admin.config.delete" path="/admin/config/configuration/delete">
<default key="_controller">Thelia\Controller\Admin\ConfigController::deleteAction</default>
<route id="admin.configuration.variables.delete" path="/admin/configuration/variables/delete">
<default key="_controller">Thelia\Controller\Admin\VariablesController::deleteAction</default>
</route>

View File

@@ -23,16 +23,24 @@
namespace Thelia\Controller\Admin;
class ConfigController extends BaseAdminController
use Thelia\Core\Event\ConfigDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
class VariablesController extends BaseAdminController
{
public function defaultAction() {
$this->render('config');
return $this->render('variables');
}
public function createAction() {
}
public function deleteAction() {
$event = new ConfigDeleteEvent($this->getRequest()->get('id'));
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
$this->redirect(URL::adminViewUrl('variables'));
}
public function updateAction() {

View File

@@ -81,7 +81,7 @@ class CategoryPath extends BaseI18nLoop
$search = CategoryQuery::create();
$this->configureI18nProcessing($search, array('TITLE'));
$locale = $this->configureI18nProcessing($search, array('TITLE'));
$search->filterById($id);
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
@@ -99,7 +99,7 @@ class CategoryPath extends BaseI18nLoop
$loopResultRow
->set("TITLE",$category->getVirtualColumn('i18n_TITLE'))
->set("URL", $category->getUrl())
->set("URL", $category->getUrl($locale))
->set("ID", $category->getId())
;

View File

@@ -22,9 +22,7 @@
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
@@ -34,6 +32,7 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CategoryQuery;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
use Thelia\Core\Template\Element\BaseI18nLoop;
/**
*
@@ -46,19 +45,17 @@ use Thelia\Type\BooleanOrBothType;
* @package Thelia\Core\Template\Loop
* @author Franck Allimant <franck@cqfdev.fr>
*/
class CategoryTree extends BaseLoop
class CategoryTree extends BaseI18nLoop
{
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('category', null, true),
Argument::createIntTypeArgument('depth', PHP_INT_MAX),
Argument::createBooleanOrBothTypeArgument('visible', true, false),
Argument::createIntListTypeArgument('exclude', array())
);
return new ArgumentCollection(Argument::createIntTypeArgument('category', null, true),
Argument::createIntTypeArgument('depth', PHP_INT_MAX),
Argument::createBooleanOrBothTypeArgument('visible', true, false),
Argument::createIntListTypeArgument('exclude', array()));
}
// changement de rubrique
@@ -66,7 +63,11 @@ class CategoryTree extends BaseLoop
{
if ($level > $max_level) return;
$search = CategoryQuery::create();
$search = CategoryQuery::create();
$locale = $this->configureI18nProcessing($search, array(
'TITLE'
));
$search->filterByParent($parent);
@@ -82,18 +83,15 @@ class CategoryTree extends BaseLoop
$loopResultRow = new LoopResultRow();
$loopResultRow
->set("ID", $result->getId())
->set("TITLE",$result->getTitle())
->set("PARENT", $result->getParent())
->set("URL", $result->getUrl())
->set("VISIBLE", $result->getVisible() ? "1" : "0")
->set("LEVEL", $level)
$loopResultRow
->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
;
$loopResult->addRow($loopResultRow);
$loopResult->addRow($loopResultRow);
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
}
}
@@ -105,7 +103,7 @@ class CategoryTree extends BaseLoop
public function exec(&$pagination)
{
$id = $this->getCategory();
$depth = $this->getDepth();
$depth = $this->getDepth();
$visible = $this->getVisible();
$exclude = $this->getExclude();

View File

@@ -57,7 +57,7 @@ class Config extends BaseI18nLoop
return new ArgumentCollection(
Argument::createIntTypeArgument('id'),
Argument::createIntListTypeArgument('exclude'),
Argument::createAnyTypeArgument('name'),
Argument::createAnyTypeArgument('variable'),
Argument::createBooleanOrBothTypeArgument('hidden'),
Argument::createBooleanOrBothTypeArgument('secured')
);
@@ -71,11 +71,11 @@ class Config extends BaseI18nLoop
public function exec(&$pagination)
{
$id = $this->getId();
$name = $this->getName();
$name = $this->getVariable();
$search = ConfigQuery::create();
$this->configureI18nProcessing($search);
$this->configureI18nProcessing($search);
if (! is_null($id))
$search->filterById($id);
@@ -113,6 +113,7 @@ class Config extends BaseI18nLoop
->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("HIDDEN" , $result->getHidden())
->set("SECURED" , $result->getSecured())
->set("CREATE_DATE" , $result->getCreatedAt())
->set("UPDATE_DATE" , $result->getUpdatedAt())
;

View File

@@ -219,7 +219,7 @@ class SmartyParser extends Smarty implements ParserInterface
$fileName .= ".html";
if (!file_exists($fileName)) {
throw new ResourceNotFoundException(sprintf("%s file (%s) not found in %s template", $file, $fileName, $this->template));
throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template));
}
}

View File

@@ -59,6 +59,8 @@ class Config extends BaseConfig {
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new ConfigEvent($this));
return true;
}
public function postDelete(ConnectionInterface $con = null)

View File

@@ -102,38 +102,6 @@ class Customer extends BaseCustomer implements UserInterface
}
}
public function preInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef());
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, $customerEvent);
return true;
}
public function postInsert(ConnectionInterface $con = null)
{
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::AFTER_CREATECUSTOMER, $customerEvent);
}
public function preUpdate(ConnectionInterface $con = null)
{
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent);
return true;
}
public function postUpdate(ConnectionInterface $con = null)
{
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent);
}
protected function generateRef()
{
return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true);
@@ -202,4 +170,57 @@ class Customer extends BaseCustomer implements UserInterface
public function getRoles() {
return array(new Role('CUSTOMER'));
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef());
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, new CustomerEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CREATECUSTOMER, new CustomerEvent($this));
}
/**
* {@inheritDoc}
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, new CustomerEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, new CustomerEvent($this));
}
/**
* {@inheritDoc}
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new CustomerEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONFIG, new CustomerEvent($this));
}
}

View File

@@ -40,6 +40,8 @@ trait ModelEventDispatcherTrait {
public function setDispatcher(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
return $this;
}
protected function dispatchEvent($eventName, ActionEvent $event)