Merge branch 'master' into template
Conflicts: core/lib/Thelia/Core/Template/Loop/Feed.php
This commit is contained in:
@@ -41,6 +41,7 @@ use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\AttributeEvent;
|
||||
use Thelia\Model\AttributeTemplate;
|
||||
use Thelia\Model\AttributeTemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
class Attribute extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -137,23 +138,33 @@ class Attribute extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(AttributeEvent $event)
|
||||
protected function doAddToAllTemplates(AttributeModel $attribute)
|
||||
{
|
||||
$templates = AttributeTemplateQuery::create()->find();
|
||||
$templates = TemplateQuery::create()->find();
|
||||
|
||||
foreach($templates as $template) {
|
||||
$pat = new AttributeTemplate();
|
||||
|
||||
$pat->setTemplate($template->getId())
|
||||
->setAttributeId($event->getAttribute()->getId())
|
||||
->save();
|
||||
$attribute_template = new AttributeTemplate();
|
||||
|
||||
if (null === AttributeTemplateQuery::create()->filterByAttribute($attribute)->filterByTemplate($template)->findOne()) {
|
||||
$attribute_template
|
||||
->setAttribute($attribute)
|
||||
->setTemplate($template)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(AttributeEvent $event)
|
||||
{
|
||||
$this->doAddToAllTemplates($event->getAttribute());
|
||||
}
|
||||
|
||||
public function removeFromAllTemplates(AttributeEvent $event)
|
||||
{
|
||||
// Delete this attribute from all product templates
|
||||
AttributeTemplateQuery::create()->filterByAttributeId($event->getAttribute()->getId())->delete();
|
||||
AttributeTemplateQuery::create()->filterByAttribute($event->getAttribute())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
->filterByProductSaleElementsId($productSaleElementsId)
|
||||
->findOne();
|
||||
|
||||
$this->doAddItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
||||
$this->doAddItem($cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice);
|
||||
}
|
||||
|
||||
if ($append && $cartItem !== null) {
|
||||
@@ -166,17 +166,18 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
* @param float $quantity
|
||||
* @param ProductPrice $productPrice
|
||||
*/
|
||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, $productSaleElementsId, $quantity, ProductPrice $productPrice)
|
||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice)
|
||||
{
|
||||
$cartItem = new CartItem();
|
||||
$cartItem->setDisptacher($this->getDispatcher());
|
||||
$cartItem
|
||||
->setCart($cart)
|
||||
->setProductId($productId)
|
||||
->setProductSaleElementsId($productSaleElementsId)
|
||||
->setProductSaleElementsId($productSaleElements->getId())
|
||||
->setQuantity($quantity)
|
||||
->setPrice($productPrice->getPrice())
|
||||
->setPromoPrice($productPrice->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30))
|
||||
->save();
|
||||
}
|
||||
|
||||
186
core/lib/Thelia/Action/Feature.php
Normal file
186
core/lib/Thelia/Action/Feature.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?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\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Model\Feature as FeatureModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\FeatureUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureCreateEvent;
|
||||
use Thelia\Core\Event\FeatureDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\FeatureAv;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
use Thelia\Model\FeatureTemplate;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
class Feature extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new feature entry
|
||||
*
|
||||
* @param FeatureCreateEvent $event
|
||||
*/
|
||||
public function create(FeatureCreateEvent $event)
|
||||
{
|
||||
$feature = new FeatureModel();
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setFeature($feature);
|
||||
|
||||
// Add atribute to all product templates if required
|
||||
if ($event->getAddToAllTemplates() != 0) {
|
||||
// TODO: add to all product template
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product feature
|
||||
*
|
||||
* @param FeatureUpdateEvent $event
|
||||
*/
|
||||
public function update(FeatureUpdateEvent $event)
|
||||
{
|
||||
$search = FeatureQuery::create();
|
||||
|
||||
if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setFeature($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature entry
|
||||
*
|
||||
* @param FeatureDeleteEvent $event
|
||||
*/
|
||||
public function delete(FeatureDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setFeature($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $feature = FeatureQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$feature->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $feature->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $feature->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $feature->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
protected function doAddToAllTemplates(FeatureModel $feature)
|
||||
{
|
||||
$templates = TemplateQuery::create()->find();
|
||||
|
||||
foreach($templates as $template) {
|
||||
|
||||
$feature_template = new FeatureTemplate();
|
||||
|
||||
if (null === FeatureTemplateQuery::create()->filterByFeature($feature)->filterByTemplate($template)->findOne()) {
|
||||
$feature_template
|
||||
->setFeature($feature)
|
||||
->setTemplate($template)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(FeatureEvent $event)
|
||||
{
|
||||
$this->doAddToAllTemplates($event->getFeature());
|
||||
}
|
||||
|
||||
public function removeFromAllTemplates(FeatureEvent $event)
|
||||
{
|
||||
// Delete this feature from all product templates
|
||||
FeatureTemplateQuery::create()->filterByFeature($event->getFeature())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FEATURE_CREATE => array("create", 128),
|
||||
TheliaEvents::FEATURE_UPDATE => array("update", 128),
|
||||
TheliaEvents::FEATURE_DELETE => array("delete", 128),
|
||||
TheliaEvents::FEATURE_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES => array("removeFromAllTemplates", 128),
|
||||
TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES => array("addToAllTemplates", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
143
core/lib/Thelia/Action/FeatureAv.php
Normal file
143
core/lib/Thelia/Action/FeatureAv.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?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\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Model\FeatureAv as FeatureAvModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureAvCreateEvent;
|
||||
use Thelia\Core\Event\FeatureAvDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
class FeatureAv extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new feature entry
|
||||
*
|
||||
* @param FeatureAvCreateEvent $event
|
||||
*/
|
||||
public function create(FeatureAvCreateEvent $event)
|
||||
{
|
||||
$feature = new FeatureAvModel();
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setFeatureId($event->getFeatureId())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product feature
|
||||
*
|
||||
* @param FeatureAvUpdateEvent $event
|
||||
*/
|
||||
public function update(FeatureAvUpdateEvent $event)
|
||||
{
|
||||
$search = FeatureAvQuery::create();
|
||||
|
||||
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature entry
|
||||
*
|
||||
* @param FeatureAvDeleteEvent $event
|
||||
*/
|
||||
public function delete(FeatureAvDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$feature->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $feature->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $feature->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $feature->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FEATURE_AV_CREATE => array("create", 128),
|
||||
TheliaEvents::FEATURE_AV_UPDATE => array("update", 128),
|
||||
TheliaEvents::FEATURE_AV_DELETE => array("delete", 128),
|
||||
TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,14 @@ use Thelia\Core\Event\TemplateEvent;
|
||||
use Thelia\Model\TemplateTemplate;
|
||||
use Thelia\Model\TemplateTemplateQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||
use Thelia\Model\AttributeTemplateQuery;
|
||||
use Thelia\Model\AttributeTemplate;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
use Thelia\Model\FeatureTemplate;
|
||||
|
||||
class Template extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -113,6 +121,54 @@ class Template extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addAttribute(TemplateAddAttributeEvent $event) {
|
||||
|
||||
if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||
|
||||
$attribute_template = new AttributeTemplate();
|
||||
|
||||
$attribute_template
|
||||
->setAttributeId($event->getAttributeId())
|
||||
->setTemplate($event->getTemplate())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAttribute(TemplateDeleteAttributeEvent $event) {
|
||||
|
||||
$attribute_template = AttributeTemplateQuery::create()
|
||||
->filterByAttributeId($event->getAttributeId())
|
||||
->filterByTemplate($event->getTemplate())->findOne()
|
||||
;
|
||||
|
||||
if ($attribute_template !== null) $attribute_template->delete();
|
||||
}
|
||||
|
||||
public function addFeature(TemplateAddFeatureEvent $event) {
|
||||
|
||||
if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||
|
||||
$feature_template = new FeatureTemplate();
|
||||
|
||||
$feature_template
|
||||
->setFeatureId($event->getFeatureId())
|
||||
->setTemplate($event->getTemplate())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFeature(TemplateDeleteFeatureEvent $event) {
|
||||
|
||||
$feature_template = FeatureTemplateQuery::create()
|
||||
->filterByFeatureId($event->getFeatureId())
|
||||
->filterByTemplate($event->getTemplate())->findOne()
|
||||
;
|
||||
|
||||
if ($feature_template !== null) $feature_template->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -122,6 +178,13 @@ class Template extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::TEMPLATE_CREATE => array("create", 128),
|
||||
TheliaEvents::TEMPLATE_UPDATE => array("update", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::TEMPLATE_ADD_ATTRIBUTE => array("addAttribute", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE => array("deleteAttribute", 128),
|
||||
|
||||
TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -67,11 +67,21 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.feature" class="Thelia\Action\Feature">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.featureav" class="Thelia\Action\FeatureAv">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.httpException" class="Thelia\Action\HttpException">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
|
||||
@@ -72,11 +72,19 @@
|
||||
<form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/>
|
||||
<form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/>
|
||||
<form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.featureav.creation" class="Thelia\Form\FeatureAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
|
||||
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
|
||||
@@ -234,6 +234,30 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.list" path="/admin/configuration/templates/features/list">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxFeaturesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.add" path="/admin/configuration/templates/features/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::addFeatureAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.delete" path="/admin/configuration/templates/features/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteFeatureAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.list" path="/admin/configuration/templates/attributes/list">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxAttributesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.add" path="/admin/configuration/templates/attributes/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::addAttributeAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.delete" path="/admin/configuration/templates/attributes/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAttributeAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- attribute and attributes value management -->
|
||||
|
||||
@@ -292,6 +316,80 @@
|
||||
|
||||
<!-- end attribute and feature routes management -->
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.update.view" path="/admin/configuration/countries/update/{country_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end countries routes management -->
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
<route id="admin.configuration.features.default" path="/admin/configuration/features">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.create" path="/admin/configuration/features/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.update" path="/admin/configuration/features/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.save" path="/admin/configuration/features/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.delete" path="/admin/configuration/features/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.update-position" path="/admin/configuration/features/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.rem-from-all" path="/admin/configuration/features/remove-from-all-templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::removeFromAllTemplates</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.add-to-all" path="/admin/configuration/features/add-to-all-templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::addToAllTemplates</default>
|
||||
</route>
|
||||
|
||||
|
||||
<route id="admin.configuration.features-av.create" path="/admin/configuration/features-av/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.update" path="/admin/configuration/features-av/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.save" path="/admin/configuration/features-av/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.delete" path="/admin/configuration/features-av/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.update-position" path="/admin/configuration/features-av/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end feature and feature routes management -->
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
<route id="admin.processTemplate" path="/admin/{template}">
|
||||
|
||||
@@ -69,10 +69,10 @@ class ConstraintValidator
|
||||
/**
|
||||
* Do variable comparison
|
||||
*
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param string $o Operator
|
||||
* @param mixed $v2 Variable 2
|
||||
*
|
||||
* @param mixed $v2 Variable 2
|
||||
* @throws \Exception
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Constraint\Rule;
|
||||
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Constraint\Validator\ComparableInterface;
|
||||
@@ -73,6 +74,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
|
||||
/** @var array Values set by Admin in BackOffice */
|
||||
protected $values = array();
|
||||
|
||||
/** @var ConstraintValidator Constaints validator */
|
||||
protected $constraintValidator = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
52
core/lib/Thelia/Controller/Admin/CountryController.php
Normal file
52
core/lib/Thelia/Controller/Admin/CountryController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class CustomerController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CountryController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.country.view")) return $response;
|
||||
return $this->render("countries", array("display_country" => 20));
|
||||
}
|
||||
|
||||
/**
|
||||
* update country action
|
||||
*
|
||||
* @param $country_id
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function updateAction($country_id)
|
||||
{
|
||||
return $this->render("country-edit", array(
|
||||
"country_id" => $country_id
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
196
core/lib/Thelia/Controller/Admin/FeatureAvController.php
Normal file
196
core/lib/Thelia/Controller/Admin/FeatureAvController.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?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\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\FeatureAvDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureAvCreateEvent;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Form\FeatureAvModificationForm;
|
||||
use Thelia\Form\FeatureAvCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages features-av sent by mail
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FeatureAvController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'featureav',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.features-av.view',
|
||||
'admin.configuration.features-av.create',
|
||||
'admin.configuration.features-av.update',
|
||||
'admin.configuration.features-av.delete',
|
||||
|
||||
TheliaEvents::FEATURE_AV_CREATE,
|
||||
TheliaEvents::FEATURE_AV_UPDATE,
|
||||
TheliaEvents::FEATURE_AV_DELETE,
|
||||
null, // No visibility toggle
|
||||
TheliaEvents::FEATURE_AV_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FeatureAvCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FeatureAvModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new FeatureAvCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setFeatureId($formData['feature_id'])
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new FeatureAvUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('featureav_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FeatureAvDeleteEvent($this->getRequest()->get('featureav_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFeatureAv();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new FeatureAvModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFeatureAv() ? $event->getFeatureAv() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return FeatureAvQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('featureav_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getViewArguments()
|
||||
{
|
||||
return array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'order' => $this->getCurrentListOrder()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render(
|
||||
'feature-edit',
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render('feature-edit', $this->getViewArguments());
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
}
|
||||
289
core/lib/Thelia/Controller/Admin/FeatureController.php
Normal file
289
core/lib/Thelia/Controller/Admin/FeatureController.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?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\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\FeatureDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureCreateEvent;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Form\FeatureModificationForm;
|
||||
use Thelia\Form\FeatureCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\FeatureAv;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages features sent by mail
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FeatureController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'feature',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.features.view',
|
||||
'admin.configuration.features.create',
|
||||
'admin.configuration.features.update',
|
||||
'admin.configuration.features.delete',
|
||||
|
||||
TheliaEvents::FEATURE_CREATE,
|
||||
TheliaEvents::FEATURE_UPDATE,
|
||||
TheliaEvents::FEATURE_DELETE,
|
||||
null, // No visibility toggle
|
||||
TheliaEvents::FEATURE_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FeatureCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FeatureModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new FeatureCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
->setAddToAllTemplates($formData['add_to_all'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new FeatureUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the features values (fix it in future version to integrate it in the feature form as a collection)
|
||||
*
|
||||
* @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction()
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
$attr_values = $this->getRequest()->get('feature_values', null);
|
||||
|
||||
if ($attr_values !== null) {
|
||||
|
||||
foreach($attr_values as $id => $value) {
|
||||
|
||||
$event = new FeatureAvUpdateEvent($id);
|
||||
|
||||
$event->setTitle($value);
|
||||
$event->setLocale($this->getCurrentEditionLocale());
|
||||
|
||||
$this->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $event);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('feature_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FeatureDeleteEvent($this->getRequest()->get('feature_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFeature();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum()
|
||||
);
|
||||
|
||||
// Setup features values
|
||||
/*
|
||||
* FIXME : doesn't work. "We get a This form should not contain extra fields." error
|
||||
$attr_av_list = FeatureAvQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFeatureId($object->getId())
|
||||
->find();
|
||||
|
||||
$attr_array = array();
|
||||
|
||||
foreach($attr_av_list as $attr_av) {
|
||||
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
|
||||
}
|
||||
|
||||
$data['feature_values'] = $attr_array;
|
||||
*/
|
||||
|
||||
// Setup the object form
|
||||
return new FeatureModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFeature() ? $event->getFeature() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return FeatureQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('feature_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
return $this->render('features', array('order' => $currentOrder));
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render(
|
||||
'feature-edit',
|
||||
array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'featureav_order' => $this->getFeatureAvListOrder()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'featureav_order' => $this->getFeatureAvListOrder()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.features.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Feature value list order.
|
||||
*
|
||||
* @return string the current list order
|
||||
*/
|
||||
protected function getFeatureAvListOrder()
|
||||
{
|
||||
return $this->getListOrderFromSession(
|
||||
'featureav',
|
||||
'featureav_order',
|
||||
'manual'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Remove from all product templates
|
||||
*/
|
||||
protected function addRemoveFromAllTemplates($eventType)
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.features.update")) return $response;
|
||||
|
||||
try {
|
||||
if (null !== $object = $this->getExistingObject()) {
|
||||
|
||||
$event = new FeatureEvent($object);
|
||||
|
||||
$this->dispatch($eventType, $event);
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove from all product templates
|
||||
*/
|
||||
public function removeFromAllTemplates()
|
||||
{
|
||||
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to all product templates
|
||||
*/
|
||||
public function addToAllTemplates()
|
||||
{
|
||||
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,10 @@ use Thelia\Model\TemplateAv;
|
||||
use Thelia\Model\TemplateAvQuery;
|
||||
use Thelia\Core\Event\TemplateAvUpdateEvent;
|
||||
use Thelia\Core\Event\TemplateEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages templates sent by mail
|
||||
@@ -193,4 +197,106 @@ class TemplateController extends AbstractCrudController
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAjaxFeaturesAction() {
|
||||
return $this->render(
|
||||
'ajax/template-feature-list',
|
||||
array('template_id' => $this->getRequest()->get('template_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getAjaxAttributesAction() {
|
||||
return $this->render(
|
||||
'ajax/template-attribute-list',
|
||||
array('template_id' => $this->getRequest()->get('template_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function addAttributeAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
|
||||
|
||||
$attribute_id = intval($this->getRequest()->get('attribute_id'));
|
||||
|
||||
if ($attribute_id > 0) {
|
||||
$event = new TemplateAddAttributeEvent(
|
||||
$this->getExistingObject(),
|
||||
$attribute_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_ADD_ATTRIBUTE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteAttributeAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
|
||||
|
||||
$event = new TemplateDeleteAttributeEvent(
|
||||
$this->getExistingObject(),
|
||||
intval($this->getRequest()->get('attribute_id'))
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function addFeatureAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
|
||||
|
||||
$feature_id = intval($this->getRequest()->get('feature_id'));
|
||||
|
||||
if ($feature_id > 0) {
|
||||
$event = new TemplateAddFeatureEvent(
|
||||
$this->getExistingObject(),
|
||||
$feature_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_ADD_FEATURE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteFeatureAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
|
||||
|
||||
$event = new TemplateDeleteFeatureEvent(
|
||||
$this->getExistingObject(),
|
||||
intval($this->getRequest()->get('feature_id'))
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_FEATURE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
68
core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php
Normal file
68
core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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;
|
||||
|
||||
class FeatureAvCreateEvent extends FeatureAvEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $feature_id;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
46
core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php
Normal file
46
core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php
Normal file
@@ -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\Event;
|
||||
|
||||
class FeatureAvDeleteEvent extends FeatureAvEvent
|
||||
{
|
||||
protected $featureAv_id;
|
||||
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
}
|
||||
|
||||
public function getFeatureAvId()
|
||||
{
|
||||
return $this->featureAv_id;
|
||||
}
|
||||
|
||||
public function setFeatureAvId($featureAv_id)
|
||||
{
|
||||
$this->featureAv_id = $featureAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/FeatureAvEvent.php
Normal file
52
core/lib/Thelia/Core/Event/FeatureAvEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\FeatureAv;
|
||||
|
||||
class FeatureAvEvent extends ActionEvent
|
||||
{
|
||||
protected $featureAv = null;
|
||||
|
||||
public function __construct(FeatureAv $featureAv = null)
|
||||
{
|
||||
$this->featureAv = $featureAv;
|
||||
}
|
||||
|
||||
public function hasFeatureAv()
|
||||
{
|
||||
return ! is_null($this->featureAv);
|
||||
}
|
||||
|
||||
public function getFeatureAv()
|
||||
{
|
||||
return $this->featureAv;
|
||||
}
|
||||
|
||||
public function setFeatureAv($featureAv)
|
||||
{
|
||||
$this->featureAv = $featureAv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php
Normal file
86
core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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;
|
||||
|
||||
class FeatureAvUpdateEvent extends FeatureAvCreateEvent
|
||||
{
|
||||
protected $featureAv_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
}
|
||||
|
||||
public function getFeatureAvId()
|
||||
{
|
||||
return $this->featureAv_id;
|
||||
}
|
||||
|
||||
public function setFeatureAvId($featureAv_id)
|
||||
{
|
||||
$this->featureAv_id = $featureAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
68
core/lib/Thelia/Core/Event/FeatureCreateEvent.php
Normal file
68
core/lib/Thelia/Core/Event/FeatureCreateEvent.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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;
|
||||
|
||||
class FeatureCreateEvent extends FeatureEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $add_to_all_templates;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddToAllTemplates()
|
||||
{
|
||||
return $this->add_to_all_templates;
|
||||
}
|
||||
|
||||
public function setAddToAllTemplates($add_to_all_templates)
|
||||
{
|
||||
$this->add_to_all_templates = $add_to_all_templates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
46
core/lib/Thelia/Core/Event/FeatureDeleteEvent.php
Normal file
46
core/lib/Thelia/Core/Event/FeatureDeleteEvent.php
Normal file
@@ -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\Event;
|
||||
|
||||
class FeatureDeleteEvent extends FeatureEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/FeatureEvent.php
Normal file
52
core/lib/Thelia/Core/Event/FeatureEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\Feature;
|
||||
|
||||
class FeatureEvent extends ActionEvent
|
||||
{
|
||||
protected $feature = null;
|
||||
|
||||
public function __construct(Feature $feature = null)
|
||||
{
|
||||
$this->feature = $feature;
|
||||
}
|
||||
|
||||
public function hasFeature()
|
||||
{
|
||||
return ! is_null($this->feature);
|
||||
}
|
||||
|
||||
public function getFeature()
|
||||
{
|
||||
return $this->feature;
|
||||
}
|
||||
|
||||
public function setFeature($feature)
|
||||
{
|
||||
$this->feature = $feature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Core/Event/FeatureUpdateEvent.php
Normal file
86
core/lib/Thelia/Core/Event/FeatureUpdateEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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;
|
||||
|
||||
class FeatureUpdateEvent extends FeatureCreateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Template;
|
||||
class TemplateAddAttributeEvent extends TemplateEvent
|
||||
{
|
||||
protected $attribute_id;
|
||||
|
||||
public function __construct(Template $template, $attribute_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->attribute_id = $attribute_id;
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Template;
|
||||
class TemplateAddFeatureEvent extends TemplateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct(Template $template, $feature_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->feature_id = $feature_id;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Template;
|
||||
|
||||
class TemplateDeleteAttributeEvent extends TemplateEvent
|
||||
{
|
||||
protected $attribute_id;
|
||||
|
||||
public function __construct(Template $template, $attribute_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->attribute_id = $attribute_id;
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Template;
|
||||
|
||||
class TemplateDeleteFeatureEvent extends TemplateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct(Template $template, $feature_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->feature_id = $feature_id;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -344,6 +344,12 @@ final class TheliaEvents
|
||||
const TEMPLATE_UPDATE = "action.updateTemplate";
|
||||
const TEMPLATE_DELETE = "action.deleteTemplate";
|
||||
|
||||
const TEMPLATE_ADD_ATTRIBUTE = "action.templateAddAttribute";
|
||||
const TEMPLATE_DELETE_ATTRIBUTE = "action.templateDeleteAttribute";
|
||||
|
||||
const TEMPLATE_ADD_FEATURE = "action.templateAddFeature";
|
||||
const TEMPLATE_DELETE_FEATURE = "action.templateDeleteFeature";
|
||||
|
||||
const BEFORE_CREATETEMPLATE = "action.before_createTemplate";
|
||||
const AFTER_CREATETEMPLATE = "action.after_createTemplate";
|
||||
|
||||
@@ -372,6 +378,25 @@ final class TheliaEvents
|
||||
const BEFORE_DELETEATTRIBUTE = "action.before_deleteAttribute";
|
||||
const AFTER_DELETEATTRIBUTE = "action.after_deleteAttribute";
|
||||
|
||||
// -- Features management ---------------------------------------------
|
||||
|
||||
const FEATURE_CREATE = "action.createFeature";
|
||||
const FEATURE_UPDATE = "action.updateFeature";
|
||||
const FEATURE_DELETE = "action.deleteFeature";
|
||||
const FEATURE_UPDATE_POSITION = "action.updateFeaturePosition";
|
||||
|
||||
const FEATURE_REMOVE_FROM_ALL_TEMPLATES = "action.addFeatureToAllTemplate";
|
||||
const FEATURE_ADD_TO_ALL_TEMPLATES = "action.removeFeatureFromAllTemplate";
|
||||
|
||||
const BEFORE_CREATEFEATURE = "action.before_createFeature";
|
||||
const AFTER_CREATEFEATURE = "action.after_createFeature";
|
||||
|
||||
const BEFORE_UPDATEFEATURE = "action.before_updateFeature";
|
||||
const AFTER_UPDATEFEATURE = "action.after_updateFeature";
|
||||
|
||||
const BEFORE_DELETEFEATURE = "action.before_deleteFeature";
|
||||
const AFTER_DELETEFEATURE = "action.after_deleteFeature";
|
||||
|
||||
// -- Attributes values management ----------------------------------------
|
||||
|
||||
const ATTRIBUTE_AV_CREATE = "action.createAttributeAv";
|
||||
@@ -387,4 +412,22 @@ final class TheliaEvents
|
||||
|
||||
const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv";
|
||||
const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv";
|
||||
|
||||
|
||||
// -- Features values management ----------------------------------------
|
||||
|
||||
const FEATURE_AV_CREATE = "action.createFeatureAv";
|
||||
const FEATURE_AV_UPDATE = "action.updateFeatureAv";
|
||||
const FEATURE_AV_DELETE = "action.deleteFeatureAv";
|
||||
const FEATURE_AV_UPDATE_POSITION = "action.updateFeatureAvPosition";
|
||||
|
||||
const BEFORE_CREATEFEATURE_AV = "action.before_createFeatureAv";
|
||||
const AFTER_CREATEFEATURE_AV = "action.after_createFeatureAv";
|
||||
|
||||
const BEFORE_UPDATEFEATURE_AV = "action.before_updateFeatureAv";
|
||||
const AFTER_UPDATEFEATURE_AV = "action.after_updateFeatureAv";
|
||||
|
||||
const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv";
|
||||
const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv";
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,17 @@ class LoopResult implements \Iterator
|
||||
return count($this->collection);
|
||||
}
|
||||
|
||||
public function getModelCollectionCount()
|
||||
{
|
||||
if ($this->modelCollection instanceof ObjectCollection || $this->modelCollection instanceof PropelModelPager) {
|
||||
return $this->modelCollection->count();
|
||||
} elseif (is_array($this->modelCollection)) {
|
||||
return count($this->modelCollection);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Return the current element
|
||||
|
||||
@@ -107,7 +107,7 @@ class LoopResultRow
|
||||
}
|
||||
if (true === $this->countable) {
|
||||
$this->set('LOOP_COUNT', 1 + $this->loopResult->getCount());
|
||||
$this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count());
|
||||
$this->set('LOOP_TOTAL', $this->loopResult->getModelCollectionCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ class Attribute extends BaseI18nLoop
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('product'),
|
||||
Argument::createIntListTypeArgument('template'),
|
||||
Argument::createIntListTypeArgument('exclude_template'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
@@ -115,15 +116,25 @@ class Attribute extends BaseI18nLoop
|
||||
$template = $productObj->getTemplate();
|
||||
}
|
||||
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
if (null !== $template) {
|
||||
$search->filterById(
|
||||
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('id')->find(),
|
||||
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('attribute_id')->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
|
||||
$exclude_template = $this->getExcludeTemplate();
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
if (null !== $exclude_template) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
|
||||
@@ -38,6 +38,7 @@ use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -60,7 +61,8 @@ class Feature extends BaseI18nLoop
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('product'),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createIntListTypeArgument('template'),
|
||||
Argument::createIntListTypeArgument('exclude_template'),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
@@ -102,22 +104,33 @@ class Feature extends BaseI18nLoop
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
$template = $this->getTemplate();
|
||||
|
||||
if (null !== $product) {
|
||||
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
|
||||
// Find the template assigned to the product.
|
||||
$productObj = ProductQuery::create()->findPk($product);
|
||||
|
||||
if (null === $category) {
|
||||
$category = $productCategories;
|
||||
} else {
|
||||
$category = array_merge($category, $productCategories);
|
||||
}
|
||||
// Ignore if the product cannot be found.
|
||||
if ($productObj !== null)
|
||||
$template = $productObj->getTemplate();
|
||||
}
|
||||
|
||||
// If we have to filter by template, find all features assigned to this template, and filter by found IDs
|
||||
if (null !== $template) {
|
||||
$search->filterById(
|
||||
FeatureTemplateQuery::create()->filterByTemplateId($template)->select('feature_id')->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
|
||||
if (null !== $category) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterById($category)->find(),
|
||||
Criteria::IN
|
||||
$exclude_template = $this->getExcludeTemplate();
|
||||
|
||||
// If we have to filter by template, find all features assigned to this template, and filter by found IDs
|
||||
if (null !== $exclude_template) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
FeatureTemplateQuery::create()->filterByTemplateId($exclude_template)->select('feature_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class Feed extends BaseLoop
|
||||
$indexes[] = $idx;
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($query);
|
||||
$loopResult = new LoopResult($indexes);
|
||||
|
||||
foreach ($indexes as $idx) {
|
||||
|
||||
@@ -92,7 +92,7 @@ class Feed extends BaseLoop
|
||||
|
||||
$date = $item->get_date('d/m/Y');
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $item, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($loopResult, null, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow->set("URL", $item->get_permalink());
|
||||
$loopResultRow->set("TITLE", $item->get_title());
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class AdminLogin extends BaseForm
|
||||
{
|
||||
@@ -34,15 +35,27 @@ class AdminLogin extends BaseForm
|
||||
"constraints" => array(
|
||||
new NotBlank(),
|
||||
new Length(array("min" => 3))
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Username *"),
|
||||
"label_attr" => array(
|
||||
"for" => "username"
|
||||
)
|
||||
))
|
||||
->add("password", "password", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Password *"),
|
||||
"label_attr" => array(
|
||||
"for" => "password"
|
||||
)
|
||||
))
|
||||
->add("remember_me", "checkbox", array(
|
||||
'value' => 'yes'
|
||||
'value' => 'yes',
|
||||
"label" => Translator::getInstance()->trans("Remember me ?"),
|
||||
"label_attr" => array(
|
||||
"for" => "remember_me"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class CartAdd extends BaseForm
|
||||
"required" => true
|
||||
|
||||
))
|
||||
->add("quantity", "text", array(
|
||||
->add("quantity", "number", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(array("methods" => array(
|
||||
|
||||
85
core/lib/Thelia/Form/CountryCreationForm.php
Normal file
85
core/lib/Thelia/Form/CountryCreationForm.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?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\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class CountryCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("area", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country area *"),
|
||||
"label_attr" => array(
|
||||
"for" => "area"
|
||||
)
|
||||
))
|
||||
->add("isocode", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("ISO Code *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isocode"
|
||||
)
|
||||
))
|
||||
->add("isoalpha2", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 2 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha2"
|
||||
)
|
||||
))
|
||||
->add("isoalpha3", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 3 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha3"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_country_creation";
|
||||
}
|
||||
}
|
||||
107
core/lib/Thelia/Form/CountryModificationForm.php
Normal file
107
core/lib/Thelia/Form/CountryModificationForm.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?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\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class CountryModificationForm extends CurrencyCreationForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("short-description", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country short description *"),
|
||||
"label_attr" => array(
|
||||
"for" => "short-description"
|
||||
)
|
||||
))
|
||||
->add("description", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country description *"),
|
||||
"label_attr" => array(
|
||||
"for" => "description"
|
||||
)
|
||||
))
|
||||
->add("area", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country area *"),
|
||||
"label_attr" => array(
|
||||
"for" => "area"
|
||||
)
|
||||
))
|
||||
->add("isocode", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("ISO Code *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isocode"
|
||||
)
|
||||
))
|
||||
->add("isoalpha2", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 2 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha2"
|
||||
)
|
||||
))
|
||||
->add("isoalpha3", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 3 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha3"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_country_modification";
|
||||
}
|
||||
}
|
||||
62
core/lib/Thelia/Form/FeatureAvCreationForm.php
Normal file
62
core/lib/Thelia/Form/FeatureAvCreationForm.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class FeatureAvCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
))
|
||||
)
|
||||
->add("locale" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
->add("feature_id", "hidden", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_featureav_creation";
|
||||
}
|
||||
}
|
||||
66
core/lib/Thelia/Form/FeatureCreationForm.php
Normal file
66
core/lib/Thelia/Form/FeatureCreationForm.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class FeatureCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
))
|
||||
)
|
||||
->add("locale" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
->add("add_to_all" , "checkbox" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Add to all product templates"),
|
||||
"label_attr" => array(
|
||||
"for" => "add_to_all"
|
||||
))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_feature_creation";
|
||||
}
|
||||
}
|
||||
62
core/lib/Thelia/Form/FeatureModificationForm.php
Normal file
62
core/lib/Thelia/Form/FeatureModificationForm.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
|
||||
class FeatureModificationForm extends FeatureCreationForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"constraints" => array(
|
||||
new GreaterThan(
|
||||
array('value' => 0)
|
||||
)
|
||||
)
|
||||
))
|
||||
/* FIXME: doesn't work
|
||||
->add('feature_values', 'collection', array(
|
||||
'type' => 'text',
|
||||
'options' => array('required' => false)
|
||||
))
|
||||
*/
|
||||
;
|
||||
|
||||
// Add standard description fields
|
||||
$this->addStandardDescFields();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_feature_modification";
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $isoalpha3;
|
||||
|
||||
/**
|
||||
* The value for the by_default field.
|
||||
* @var int
|
||||
*/
|
||||
protected $by_default;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -477,6 +483,17 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->isoalpha3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [by_default] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getByDefault()
|
||||
{
|
||||
|
||||
return $this->by_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -626,6 +643,27 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setIsoalpha3()
|
||||
|
||||
/**
|
||||
* Set the value of [by_default] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return \Thelia\Model\Country The current object (for fluent API support)
|
||||
*/
|
||||
public function setByDefault($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->by_default !== $v) {
|
||||
$this->by_default = $v;
|
||||
$this->modifiedColumns[] = CountryTableMap::BY_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setByDefault()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -720,13 +758,16 @@ abstract class Country implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryTableMap::translateFieldName('Isoalpha3', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->isoalpha3 = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->by_default = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -739,7 +780,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 7; // 7 = CountryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 8; // 8 = CountryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e);
|
||||
@@ -1043,6 +1084,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ISOALPHA3';
|
||||
}
|
||||
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
|
||||
}
|
||||
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
@@ -1075,6 +1119,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
case 'ISOALPHA3':
|
||||
$stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'BY_DEFAULT':
|
||||
$stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
@@ -1152,9 +1199,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->getIsoalpha3();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getByDefault();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 7:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1191,8 +1241,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
$keys[2] => $this->getIsocode(),
|
||||
$keys[3] => $this->getIsoalpha2(),
|
||||
$keys[4] => $this->getIsoalpha3(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
$keys[5] => $this->getByDefault(),
|
||||
$keys[6] => $this->getCreatedAt(),
|
||||
$keys[7] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1263,9 +1314,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->setIsoalpha3($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setByDefault($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 7:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1297,8 +1351,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1315,6 +1370,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CountryTableMap::ISOCODE)) $criteria->add(CountryTableMap::ISOCODE, $this->isocode);
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2);
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3);
|
||||
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) $criteria->add(CountryTableMap::BY_DEFAULT, $this->by_default);
|
||||
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1385,6 +1441,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$copyObj->setIsocode($this->getIsocode());
|
||||
$copyObj->setIsoalpha2($this->getIsoalpha2());
|
||||
$copyObj->setIsoalpha3($this->getIsoalpha3());
|
||||
$copyObj->setByDefault($this->getByDefault());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
|
||||
@@ -2287,6 +2344,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->isocode = null;
|
||||
$this->isoalpha2 = null;
|
||||
$this->isoalpha3 = null;
|
||||
$this->by_default = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
@@ -27,6 +27,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery orderByIsocode($order = Criteria::ASC) Order by the isocode column
|
||||
* @method ChildCountryQuery orderByIsoalpha2($order = Criteria::ASC) Order by the isoalpha2 column
|
||||
* @method ChildCountryQuery orderByIsoalpha3($order = Criteria::ASC) Order by the isoalpha3 column
|
||||
* @method ChildCountryQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column
|
||||
* @method ChildCountryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCountryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -35,6 +36,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery groupByIsocode() Group by the isocode column
|
||||
* @method ChildCountryQuery groupByIsoalpha2() Group by the isoalpha2 column
|
||||
* @method ChildCountryQuery groupByIsoalpha3() Group by the isoalpha3 column
|
||||
* @method ChildCountryQuery groupByByDefault() Group by the by_default column
|
||||
* @method ChildCountryQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCountryQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -66,6 +68,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountry findOneByIsocode(string $isocode) Return the first ChildCountry filtered by the isocode column
|
||||
* @method ChildCountry findOneByIsoalpha2(string $isoalpha2) Return the first ChildCountry filtered by the isoalpha2 column
|
||||
* @method ChildCountry findOneByIsoalpha3(string $isoalpha3) Return the first ChildCountry filtered by the isoalpha3 column
|
||||
* @method ChildCountry findOneByByDefault(int $by_default) Return the first ChildCountry filtered by the by_default column
|
||||
* @method ChildCountry findOneByCreatedAt(string $created_at) Return the first ChildCountry filtered by the created_at column
|
||||
* @method ChildCountry findOneByUpdatedAt(string $updated_at) Return the first ChildCountry filtered by the updated_at column
|
||||
*
|
||||
@@ -74,6 +77,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method array findByIsocode(string $isocode) Return ChildCountry objects filtered by the isocode column
|
||||
* @method array findByIsoalpha2(string $isoalpha2) Return ChildCountry objects filtered by the isoalpha2 column
|
||||
* @method array findByIsoalpha3(string $isoalpha3) Return ChildCountry objects filtered by the isoalpha3 column
|
||||
* @method array findByByDefault(int $by_default) Return ChildCountry objects filtered by the by_default column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCountry objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCountry objects filtered by the updated_at column
|
||||
*
|
||||
@@ -164,7 +168,7 @@ abstract class CountryQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -424,6 +428,47 @@ abstract class CountryQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CountryTableMap::ISOALPHA3, $isoalpha3, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the by_default column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByByDefault(1234); // WHERE by_default = 1234
|
||||
* $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
|
||||
* $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $byDefault The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByByDefault($byDefault = null, $comparison = null)
|
||||
{
|
||||
if (is_array($byDefault)) {
|
||||
$useMinMax = false;
|
||||
if (isset($byDefault['min'])) {
|
||||
$this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($byDefault['max'])) {
|
||||
$this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
|
||||
@@ -45,16 +45,18 @@ class Cart extends BaseCart
|
||||
$item->setQuantity($cartItem->getQuantity());
|
||||
$item->setProductSaleElements($productSaleElements);
|
||||
if ($currentDateTime <= $cartItem->getPriceEndOfLife()) {
|
||||
$item->setPrice($cartItem->getPrice());
|
||||
$item->setPromoPrice($cartItem->getPromoPrice());
|
||||
$item->setPrice($cartItem->getPrice())
|
||||
->setPromoPrice($cartItem->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
// TODO : new price EOF or duplicate current priceEOF from $cartItem ?
|
||||
$item->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
||||
->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
||||
} else {
|
||||
$productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
|
||||
|
||||
$item->setPrice($productPrices->getPrice());
|
||||
$item->setPromoPrice($productPrices->getPromoPrice());
|
||||
$item->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
||||
$item->setPrice($productPrices->getPrice())
|
||||
->setPromoPrice($productPrices->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
||||
}
|
||||
$item->save();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,70 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\Feature as BaseFeature;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
|
||||
class Feature extends BaseFeature {
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE, new FeatureEvent($this));
|
||||
|
||||
// Set the current position for the new object
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE, new FeatureEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE, new FeatureEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE, new FeatureEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE, new FeatureEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE, new FeatureEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,78 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\FeatureAv as BaseFeatureAv;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\FeatureAvEvent;
|
||||
|
||||
class FeatureAv extends BaseFeatureAv {
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
/**
|
||||
* when dealing with position, be sure to work insite the current feature.
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
$query->filterByFeatureId($this->getFeatureId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
// Set the current position for the new object
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_AV, new FeatureAvEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_AV, new FeatureAvEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class CountryTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 7;
|
||||
const NUM_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class CountryTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 7;
|
||||
const NUM_HYDRATE_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -94,6 +94,11 @@ class CountryTableMap extends TableMap
|
||||
*/
|
||||
const ISOALPHA3 = 'country.ISOALPHA3';
|
||||
|
||||
/**
|
||||
* the column name for the BY_DEFAULT field
|
||||
*/
|
||||
const BY_DEFAULT = 'country.BY_DEFAULT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -125,12 +130,12 @@ class CountryTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'ByDefault', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'byDefault', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::BY_DEFAULT, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'by_default', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -140,12 +145,12 @@ class CountryTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::CREATED_AT => 5, CountryTableMap::UPDATED_AT => 6, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::BY_DEFAULT => 5, CountryTableMap::CREATED_AT => 6, CountryTableMap::UPDATED_AT => 7, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -169,6 +174,7 @@ class CountryTableMap extends TableMap
|
||||
$this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null);
|
||||
$this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null);
|
||||
$this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null);
|
||||
$this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -351,6 +357,7 @@ class CountryTableMap extends TableMap
|
||||
$criteria->addSelectColumn(CountryTableMap::ISOCODE);
|
||||
$criteria->addSelectColumn(CountryTableMap::ISOALPHA2);
|
||||
$criteria->addSelectColumn(CountryTableMap::ISOALPHA3);
|
||||
$criteria->addSelectColumn(CountryTableMap::BY_DEFAULT);
|
||||
$criteria->addSelectColumn(CountryTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CountryTableMap::UPDATED_AT);
|
||||
} else {
|
||||
@@ -359,6 +366,7 @@ class CountryTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.ISOCODE');
|
||||
$criteria->addSelectColumn($alias . '.ISOALPHA2');
|
||||
$criteria->addSelectColumn($alias . '.ISOALPHA3');
|
||||
$criteria->addSelectColumn($alias . '.BY_DEFAULT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -99,6 +102,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -136,6 +142,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(5));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -183,6 +192,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(5));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
|
||||
@@ -169,6 +170,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -205,6 +209,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -241,6 +248,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -277,6 +287,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -313,6 +326,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -349,6 +365,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -385,6 +404,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -421,6 +443,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -457,6 +482,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -493,6 +521,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -529,6 +560,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -565,6 +599,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -601,6 +638,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -637,6 +677,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
use Thelia\Constraint\Rule\SerializableRule;
|
||||
@@ -192,6 +193,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -224,6 +228,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -256,6 +263,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -288,6 +298,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -320,6 +333,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -352,6 +368,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -384,6 +403,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -416,6 +438,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -448,6 +473,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -480,6 +508,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -512,6 +543,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -544,6 +578,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -570,6 +607,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -602,6 +642,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
Reference in New Issue
Block a user