Merge branch 'master' of https://github.com/thelia/thelia into coupon

* 'master' of https://github.com/thelia/thelia: (102 commits)
  add higher priority to module routing
  update smarty version
  select default country in front register form
  add modal error id changing default country failed
  enabled change default country
  fiw module generator class name issue
  complete javascript for changing default country
  validate country removal
  validate country creation
  implement abstract method from AbstractCrudController in Country Controller
  create country action class
  add pre/post CRUD method in Country model
  create coutry events
  finish customer address update
  complete readme
  update .gitignore file
  add specifig php.ini file for travis
  try to fix travis conf
  remove unused directory
  check session directory permission in install process
  ...
This commit is contained in:
Kahn
2013-10-08 23:22:53 +02:00
481 changed files with 9445 additions and 15685 deletions

View File

@@ -25,8 +25,8 @@ namespace Thelia\Action;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Propel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Address as AddressModel;
use Thelia\Model\Map\AddressTableMap;
@@ -60,6 +60,13 @@ class Address extends BaseAction implements EventSubscriberInterface
$address->delete();
}
public function useDefault(AddressEvent $event)
{
$address = $event->getAddress();
$address->makeItDefault();
}
protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event)
{
$addressModel->setDispatcher($this->getDispatcher());
@@ -86,14 +93,14 @@ class Address extends BaseAction implements EventSubscriberInterface
->save()
;
if($event->getIsDefault()) {
if ($event->getIsDefault()) {
$addressModel->makeItDefault();
}
$event->setAddress($addressModel);
$con->commit();
} catch(PropelException $e) {
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
@@ -125,7 +132,8 @@ class Address extends BaseAction implements EventSubscriberInterface
return array(
TheliaEvents::ADDRESS_CREATE => array("create", 128),
TheliaEvents::ADDRESS_UPDATE => array("update", 128),
TheliaEvents::ADDRESS_DELETE => array("delete", 128)
TheliaEvents::ADDRESS_DELETE => array("delete", 128),
TheliaEvents::ADDRESS_DEFAULT => array('useDefault', 128),
);
}
}

View File

@@ -30,15 +30,11 @@ use Thelia\Model\Attribute as AttributeModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeUpdateEvent;
use Thelia\Core\Event\AttributeCreateEvent;
use Thelia\Core\Event\AttributeDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\Attribute\AttributeUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeCreateEvent;
use Thelia\Core\Event\Attribute\AttributeDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryEvent;
use Thelia\Core\Event\AttributeEvent;
use Thelia\Core\Event\Attribute\AttributeEvent;
use Thelia\Model\AttributeTemplate;
use Thelia\Model\AttributeTemplateQuery;
use Thelia\Model\TemplateQuery;
@@ -130,7 +126,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface
{
$templates = TemplateQuery::create()->find();
foreach($templates as $template) {
foreach ($templates as $template) {
$attribute_template = new AttributeTemplate();
@@ -171,4 +167,4 @@ class Attribute extends BaseAction implements EventSubscriberInterface
);
}
}
}

View File

@@ -30,10 +30,9 @@ use Thelia\Model\AttributeAv as AttributeAvModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeAvCreateEvent;
use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
class AttributeAv extends BaseAction implements EventSubscriberInterface
@@ -63,7 +62,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface
/**
* Change a product attribute
*
* @param AttributeAvUpdateEvent $event
* @param \Thelia\Core\Event\Attribute\AttributeAvUpdateEvent $event
*/
public function update(AttributeAvUpdateEvent $event)
{
@@ -115,7 +114,6 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(AttributeAvQuery::create(), $event);
}
/**
* {@inheritDoc}
*/
@@ -128,4 +126,4 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128),
);
}
}
}

View File

@@ -24,7 +24,6 @@ namespace Thelia\Action;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Model\AdminLog;
use Propel\Runtime\ActiveQuery\PropelQuery;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Event\UpdatePositionEvent;
@@ -50,7 +49,6 @@ class BaseAction
return $this->container->get('event_dispatcher');
}
/**
* Changes object position, selecting absolute ou relative change.
*

View File

@@ -23,10 +23,7 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\CachedFileEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL;
/**
@@ -50,7 +47,7 @@ abstract class BaseCachedFile extends BaseAction
/**
* @return string root of the file cache directory in web space
*/
protected abstract function getCacheDirFromWebRoot();
abstract protected function getCacheDirFromWebRoot();
/**
* Clear the file cache. Is a subdirectory is specified, only this directory is cleared.
@@ -104,9 +101,9 @@ abstract class BaseCachedFile extends BaseAction
/**
* Return the full path of the cached file
*
* @param string $subdir the subdirectory related to cache base
* @param string $filename the filename
* @param string $hashed_options a hash of transformation options, or null if no transformations have been applied
* @param string $subdir the subdirectory related to cache base
* @param string $filename the filename
* @param string $hashed_options a hash of transformation options, or null if no transformations have been applied
* @param boolean $forceOriginalDocument if true, the original file path in the cache dir is returned.
* @return string the cache directory path relative to Web Root
*/
@@ -175,4 +172,4 @@ abstract class BaseCachedFile extends BaseAction
return $path;
}
}
}

View File

@@ -25,7 +25,7 @@ namespace Thelia\Action;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\CartEvent;
use Thelia\Core\Event\Cart\CartEvent;
use Thelia\Model\ProductPrice;
use Thelia\Model\ProductPriceQuery;
use Thelia\Model\CartItem;
@@ -45,7 +45,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
/**
*
* add an article in the current cart
* @param \Thelia\Core\Event\CartEvent $event
* @param \Thelia\Core\Event\Cart\CartEvent $event
*/
public function addItem(CartEvent $event)
{
@@ -77,7 +77,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
*
* Delete specify article present into cart
*
* @param \Thelia\Core\Event\CartEvent $event
* @param \Thelia\Core\Event\Cart\CartEvent $event
*/
public function deleteItem(CartEvent $event)
{
@@ -97,7 +97,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
*
* don't use Form here just test the Request.
*
* @param \Thelia\Core\Event\CartEvent $event
* @param \Thelia\Core\Event\Cart\CartEvent $event
*/
public function changeItem(CartEvent $event)
{

View File

@@ -30,14 +30,13 @@ use Thelia\Model\Category as CategoryModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CategoryUpdateEvent;
use Thelia\Core\Event\CategoryCreateEvent;
use Thelia\Core\Event\CategoryDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\Category\CategoryUpdateEvent;
use Thelia\Core\Event\Category\CategoryCreateEvent;
use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\CategoryAddContentEvent;
use Thelia\Core\Event\CategoryDeleteContentEvent;
use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\Category\CategoryAddContentEvent;
use Thelia\Core\Event\Category\CategoryDeleteContentEvent;
use Thelia\Model\CategoryAssociatedContent;
use Thelia\Model\CategoryAssociatedContentQuery;
@@ -46,7 +45,7 @@ class Category extends BaseAction implements EventSubscriberInterface
/**
* Create a new category entry
*
* @param CategoryCreateEvent $event
* @param \Thelia\Core\Event\Category\CategoryCreateEvent $event
*/
public function create(CategoryCreateEvent $event)
{
@@ -69,7 +68,7 @@ class Category extends BaseAction implements EventSubscriberInterface
/**
* Change a category
*
* @param CategoryUpdateEvent $event
* @param \Thelia\Core\Event\Category\CategoryUpdateEvent $event
*/
public function update(CategoryUpdateEvent $event)
{
@@ -98,7 +97,7 @@ class Category extends BaseAction implements EventSubscriberInterface
/**
* Delete a category entry
*
* @param CategoryDeleteEvent $event
* @param \Thelia\Core\Event\Category\CategoryDeleteEvent $event
*/
public function delete(CategoryDeleteEvent $event)
{
@@ -139,8 +138,8 @@ class Category extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(CategoryQuery::create(), $event);
}
public function addContent(CategoryAddContentEvent $event) {
public function addContent(CategoryAddContentEvent $event)
{
if (CategoryAssociatedContentQuery::create()
->filterByContentId($event->getContentId())
->filterByCategory($event->getCategory())->count() <= 0) {
@@ -156,8 +155,8 @@ class Category extends BaseAction implements EventSubscriberInterface
}
}
public function removeContent(CategoryDeleteContentEvent $event) {
public function removeContent(CategoryDeleteContentEvent $event)
{
$content = CategoryAssociatedContentQuery::create()
->filterByContentId($event->getContentId())
->filterByCategory($event->getCategory())->findOne()
@@ -170,7 +169,6 @@ class Category extends BaseAction implements EventSubscriberInterface
}
}
/**
* {@inheritDoc}
*/

View File

@@ -29,16 +29,16 @@ use Thelia\Model\Config as ConfigModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\ConfigUpdateEvent;
use Thelia\Core\Event\ConfigCreateEvent;
use Thelia\Core\Event\ConfigDeleteEvent;
use Thelia\Core\Event\Config\ConfigUpdateEvent;
use Thelia\Core\Event\Config\ConfigCreateEvent;
use Thelia\Core\Event\Config\ConfigDeleteEvent;
class Config extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new configuration entry
*
* @param ConfigCreateEvent $event
* @param \Thelia\Core\Event\Config\ConfigCreateEvent $event
*/
public function create(ConfigCreateEvent $event)
{
@@ -54,7 +54,7 @@ class Config extends BaseAction implements EventSubscriberInterface
/**
* Change a configuration entry value
*
* @param ConfigUpdateEvent $event
* @param \Thelia\Core\Event\Config\ConfigUpdateEvent $event
*/
public function setValue(ConfigUpdateEvent $event)
{
@@ -74,7 +74,7 @@ class Config extends BaseAction implements EventSubscriberInterface
/**
* Change a configuration entry
*
* @param ConfigUpdateEvent $event
* @param \Thelia\Core\Event\Config\ConfigUpdateEvent $event
*/
public function modify(ConfigUpdateEvent $event)
{
@@ -94,7 +94,7 @@ class Config extends BaseAction implements EventSubscriberInterface
/**
* Delete a configuration entry
*
* @param ConfigDeleteEvent $event
* @param \Thelia\Core\Event\Config\ConfigDeleteEvent $event
*/
public function delete(ConfigDeleteEvent $event)
{

View File

@@ -22,17 +22,20 @@
/*************************************************************************************/
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Content\ContentAddFolderEvent;
use Thelia\Core\Event\Content\ContentCreateEvent;
use Thelia\Core\Event\Content\ContentDeleteEvent;
use Thelia\Core\Event\Content\ContentRemoveFolderEvent;
use Thelia\Core\Event\Content\ContentToggleVisibilityEvent;
use Thelia\Core\Event\Content\ContentUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\ContentFolder;
use Thelia\Model\ContentFolderQuery;
use Thelia\Model\ContentQuery;
use Thelia\Model\Content as ContentModel;
use Thelia\Model\FolderQuery;
/**
* Class Content
@@ -76,17 +79,18 @@ class Content extends BaseAction implements EventSubscriberInterface
->save()
;
$content->updateDefaultFolder($event->getDefaultFolder());
$event->setContent($content);
}
}
public function updatePosition(UpdatePositionEvent $event)
{
if(null !== $content = ContentQuery::create()->findPk($event->getObjectId())) {
if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) {
$content->setDispatcher($this->getDispatcher());
switch($event->getMode())
{
switch ($event->getMode()) {
case UpdatePositionEvent::POSITION_ABSOLUTE:
$content->changeAbsolutePosition($event->getPosition());
break;
@@ -109,6 +113,8 @@ class Content extends BaseAction implements EventSubscriberInterface
->setVisible(!$content->getVisible())
->save();
$event->setContent($content);
}
public function delete(ContentDeleteEvent $event)
@@ -124,6 +130,40 @@ class Content extends BaseAction implements EventSubscriberInterface
}
}
/**
*
* associate a folder to a content if the association already does not exists
*
* @param ContentAddFolderEvent $event
*/
public function addFolder(ContentAddFolderEvent $event)
{
if(ContentFolderQuery::create()
->filterByContent($event->getContent())
->filterByFolderId($event->getFolderId())
->count() <= 0
) {
$contentFolder = new ContentFolder();
$contentFolder
->setFolderId($event->getFolderId())
->setContent($event->getContent())
->setDefaultFolder(false)
->save();
}
}
public function removeFolder(ContentRemoveFolderEvent $event)
{
$contentFolder = ContentFolderQuery::create()
->filterByContent($event->getContent())
->filterByFolderId($event->getFolderId())
->findOne();
if(null !== $contentFolder) {
$contentFolder->delete();
}
}
/**
* Returns an array of event names this subscriber wants to listen to.
@@ -148,13 +188,16 @@ class Content extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
TheliaEvents::CONTENT_CREATE => array("create", 128),
TheliaEvents::CONTENT_UPDATE => array("update", 128),
TheliaEvents::CONTENT_DELETE => array("delete", 128),
TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
TheliaEvents::CONTENT_CREATE => array('create', 128),
TheliaEvents::CONTENT_UPDATE => array('update', 128),
TheliaEvents::CONTENT_DELETE => array('delete', 128),
TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array('toggleVisibility', 128),
TheliaEvents::CONTENT_UPDATE_POSITION => array("updatePosition", 128),
TheliaEvents::CONTENT_UPDATE_POSITION => array('updatePosition', 128),
TheliaEvents::CONTENT_ADD_FOLDER => array('addFolder', 128),
TheliaEvents::CONTENT_REMOVE_FOLDER => array('removeFolder', 128),
);
}
}
}

View File

@@ -0,0 +1,114 @@
<?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\Core\Event\Country\CountryCreateEvent;
use Thelia\Core\Event\Country\CountryDeleteEvent;
use Thelia\Core\Event\Country\CountryToggleDefaultEvent;
use Thelia\Core\Event\Country\CountryUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Country as CountryModel;
use Thelia\Model\CountryQuery;
/**
* Class Country
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Country extends BaseAction implements EventSubscriberInterface
{
public function create(CountryCreateEvent $event)
{
$country = new CountryModel();
$country
->setIsocode($event->getIsocode())
->setIsoalpha2($event->getIsoAlpha2())
->setIsoalpha3($event->getIsoAlpha3())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->save();
$event->setCountry($country);
}
public function update(CountryUpdateEvent $event)
{
}
public function delete(CountryDeleteEvent $event)
{
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
$country->delete();
$event->setCountry($country);
}
}
public function toggleDefault(CountryToggleDefaultEvent $event)
{
if( null !== $country = CountryQuery::create()->findPk($event->getCountryId()))
{
$country->toggleDefault();
$event->setCountry($country);
}
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::COUNTRY_CREATE => array('create', 128),
TheliaEvents::COUNTRY_UPDATE => array('update', 128),
TheliaEvents::COUNTRY_DELETE => array('delete', 128),
TheliaEvents::COUNTRY_TOGGLE_DEFAULT => array('toggleDefault', 128)
);
}
}

View File

@@ -30,9 +30,9 @@ use Thelia\Model\Currency as CurrencyModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CurrencyUpdateEvent;
use Thelia\Core\Event\CurrencyCreateEvent;
use Thelia\Core\Event\CurrencyDeleteEvent;
use Thelia\Core\Event\Currency\CurrencyUpdateEvent;
use Thelia\Core\Event\Currency\CurrencyCreateEvent;
use Thelia\Core\Event\Currency\CurrencyDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\UpdatePositionEvent;
@@ -41,7 +41,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
/**
* Create a new currencyuration entry
*
* @param CurrencyCreateEvent $event
* @param \Thelia\Core\Event\Currency\CurrencyCreateEvent $event
*/
public function create(CurrencyCreateEvent $event)
{
@@ -65,7 +65,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
/**
* Change a currency
*
* @param CurrencyUpdateEvent $event
* @param \Thelia\Core\Event\Currency\CurrencyUpdateEvent $event
*/
public function update(CurrencyUpdateEvent $event)
{
@@ -118,7 +118,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
/**
* Delete a currencyuration entry
*
* @param CurrencyDeleteEvent $event
* @param \Thelia\Core\Event\Currency\CurrencyDeleteEvent $event
*/
public function delete(CurrencyDeleteEvent $event)
{

View File

@@ -25,11 +25,12 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\Customer\CustomerAddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Customer as CustomerModel;
use Thelia\Core\Event\CustomerLoginEvent;
use Thelia\Core\Event\Customer\CustomerLoginEvent;
/**
*
@@ -148,11 +149,11 @@ class Customer extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
TheliaEvents::CUSTOMER_CREATEACCOUNT => array("create", 128),
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array("modify", 128),
TheliaEvents::CUSTOMER_LOGOUT => array("logout", 128),
TheliaEvents::CUSTOMER_LOGIN => array("login" , 128),
TheliaEvents::CUSTOMER_DELETEACCOUNT => array("delete", 128),
TheliaEvents::CUSTOMER_CREATEACCOUNT => array('create', 128),
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array('modify', 128),
TheliaEvents::CUSTOMER_LOGOUT => array('logout', 128),
TheliaEvents::CUSTOMER_LOGIN => array('login', 128),
TheliaEvents::CUSTOMER_DELETEACCOUNT => array('delete', 128),
);
}
}

View File

@@ -25,19 +25,15 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\DocumentDeleteEvent;
use Thelia\Core\Event\DocumentEvent;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent;
use Thelia\Core\Event\Document\DocumentEvent;
use Thelia\Exception\ImageException;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\FileManager;
use Thelia\Tools\URL;
use Imagine\Document\ImagineInterface;
use Imagine\Document\DocumentInterface;
use Imagine\Document\Box;
use Imagine\Document\Color;
use Imagine\Document\Point;
use Thelia\Exception\DocumentException;
use Thelia\Core\Event\TheliaEvents;
@@ -80,7 +76,8 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
/**
* @return string root of the document cache directory in web space
*/
protected function getCacheDirFromWebRoot() {
protected function getCacheDirFromWebRoot()
{
return ConfigQuery::read('document_cache_dir_from_web_root', 'cache');
}
@@ -95,7 +92,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
* @param DocumentEvent $event Event
*
* @throws \Thelia\Exception\DocumentException
* @throws \InvalidArgumentException , DocumentException
* @throws \InvalidArgumentException , DocumentException
*/
public function processDocument(DocumentEvent $event)
{
@@ -139,7 +136,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
/**
* Take care of saving document in the database and file storage
*
* @param DocumentCreateOrUpdateEvent $event Document event
* @param \Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent $event Document event
*
* @throws \Thelia\Exception\ImageException
* @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action
@@ -183,7 +180,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
/**
* Take care of updating document in the database and file storage
*
* @param DocumentCreateOrUpdateEvent $event Document event
* @param \Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent $event Document event
*
* @throws \Thelia\Exception\ImageException
* @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action
@@ -225,7 +222,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
/**
* Take care of deleting document in the database and file storage
*
* @param DocumentDeleteEvent $event Image event
* @param \Thelia\Core\Event\Document\DocumentDeleteEvent $event Image event
*
* @throws \Exception
* @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action
@@ -247,7 +244,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
'document'
)
);
} catch(\Exception $e) {
} catch (\Exception $e) {
$this->adminLogAppend(
$this->container->get('thelia.translator')->trans(
'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)',

View File

@@ -30,15 +30,11 @@ 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\Feature\FeatureUpdateEvent;
use Thelia\Core\Event\Feature\FeatureCreateEvent;
use Thelia\Core\Event\Feature\FeatureDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryEvent;
use Thelia\Core\Event\FeatureEvent;
use Thelia\Core\Event\Feature\FeatureEvent;
use Thelia\Model\FeatureTemplate;
use Thelia\Model\FeatureTemplateQuery;
use Thelia\Model\TemplateQuery;
@@ -48,7 +44,7 @@ class Feature extends BaseAction implements EventSubscriberInterface
/**
* Create a new feature entry
*
* @param FeatureCreateEvent $event
* @param \Thelia\Core\Event\Feature\FeatureCreateEvent $event
*/
public function create(FeatureCreateEvent $event)
{
@@ -74,7 +70,7 @@ class Feature extends BaseAction implements EventSubscriberInterface
/**
* Change a product feature
*
* @param FeatureUpdateEvent $event
* @param \Thelia\Core\Event\Feature\FeatureUpdateEvent $event
*/
public function update(FeatureUpdateEvent $event)
{
@@ -130,7 +126,7 @@ class Feature extends BaseAction implements EventSubscriberInterface
{
$templates = TemplateQuery::create()->find();
foreach($templates as $template) {
foreach ($templates as $template) {
$feature_template = new FeatureTemplate();
@@ -171,4 +167,4 @@ class Feature extends BaseAction implements EventSubscriberInterface
);
}
}
}

View File

@@ -30,10 +30,9 @@ 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\Feature\FeatureAvUpdateEvent;
use Thelia\Core\Event\Feature\FeatureAvCreateEvent;
use Thelia\Core\Event\Feature\FeatureAvDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
class FeatureAv extends BaseAction implements EventSubscriberInterface
@@ -115,7 +114,6 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(FeatureAvQuery::create(), $event);
}
/**
* {@inheritDoc}
*/
@@ -128,4 +126,4 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface
TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128),
);
}
}
}

View File

@@ -23,24 +23,22 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\FolderCreateEvent;
use Thelia\Core\Event\FolderDeleteEvent;
use Thelia\Core\Event\FolderToggleVisibilityEvent;
use Thelia\Core\Event\FolderUpdateEvent;
use Thelia\Core\Event\Folder\FolderCreateEvent;
use Thelia\Core\Event\Folder\FolderDeleteEvent;
use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent;
use Thelia\Core\Event\Folder\FolderUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\FolderQuery;
use Thelia\Model\Folder as FolderModel;
/**
* Class Folder
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Folder extends BaseAction implements EventSubscriberInterface {
class Folder extends BaseAction implements EventSubscriberInterface
{
public function update(FolderUpdateEvent $event)
{
@@ -99,15 +97,16 @@ class Folder extends BaseAction implements EventSubscriberInterface {
->setVisible(!$folder->getVisible())
->save();
$event->setFolder($folder);
}
public function updatePosition(UpdatePositionEvent $event)
{
if(null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) {
if (null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) {
$folder->setDispatcher($this->getDispatcher());
switch($event->getMode())
{
switch ($event->getMode()) {
case UpdatePositionEvent::POSITION_ABSOLUTE:
$folder->changeAbsolutePosition($event->getPosition());
break;
@@ -152,4 +151,4 @@ class Folder extends BaseAction implements EventSubscriberInterface {
TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128),
);
}
}
}

View File

@@ -45,7 +45,7 @@ class HttpException extends BaseAction implements EventSubscriberInterface
$this->display404($event);
}
if($event->getException() instanceof AccessDeniedHttpException) {
if ($event->getException() instanceof AccessDeniedHttpException) {
$this->display403($event);
}
}

View File

@@ -23,19 +23,12 @@
namespace Thelia\Action;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\ImagesCreateOrUpdateEvent;
use Thelia\Core\Event\ImageDeleteEvent;
use Thelia\Core\Event\ImageEvent;
use Thelia\Model\CategoryImage;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageDeleteEvent;
use Thelia\Core\Event\Image\ImageEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\ContentImage;
use Thelia\Model\FolderImage;
use Thelia\Model\ProductImage;
use Thelia\Tools\FileManager;
use Thelia\Tools\URL;
@@ -88,12 +81,11 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
const EXACT_RATIO_WITH_CROP = 2;
const KEEP_IMAGE_RATIO = 3;
/**
* @return string root of the image cache directory in web space
*/
protected function getCacheDirFromWebRoot() {
protected function getCacheDirFromWebRoot()
{
return ConfigQuery::read('image_cache_dir_from_web_root', 'cache');
}
@@ -106,8 +98,8 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
*
* This method updates the cache_file_path and file_url attributes of the event
*
* @param ImageEvent $event
* @throws \InvalidArgumentException, ImageException
* @param \Thelia\Core\Event\Image\ImageEvent $event
* @throws \InvalidArgumentException, ImageException
*/
public function processImage(ImageEvent $event)
{
@@ -255,7 +247,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
/**
* Take care of saving image in the database and file storage
*
* @param ImageCreateOrUpdateEvent $event Image event
* @param \Thelia\Core\Event\Image\ImageCreateOrUpdateEvent $event Image event
*
* @throws \Thelia\Exception\ImageException
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
@@ -358,7 +350,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
'image'
)
);
} catch(\Exception $e){
} catch (\Exception $e) {
$this->adminLogAppend(
$this->container->get('thelia.translator')->trans(
'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)',

View File

@@ -30,16 +30,16 @@ use Thelia\Model\Message as MessageModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\MessageCreateEvent;
use Thelia\Core\Event\MessageDeleteEvent;
use Thelia\Core\Event\Message\MessageUpdateEvent;
use Thelia\Core\Event\Message\MessageCreateEvent;
use Thelia\Core\Event\Message\MessageDeleteEvent;
class Message extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new messageuration entry
*
* @param MessageCreateEvent $event
* @param \Thelia\Core\Event\Message\MessageCreateEvent $event
*/
public function create(MessageCreateEvent $event)
{
@@ -64,7 +64,7 @@ class Message extends BaseAction implements EventSubscriberInterface
/**
* Change a message
*
* @param MessageUpdateEvent $event
* @param \Thelia\Core\Event\Message\MessageUpdateEvent $event
*/
public function modify(MessageUpdateEvent $event)
{
@@ -94,7 +94,7 @@ class Message extends BaseAction implements EventSubscriberInterface
/**
* Delete a messageuration entry
*
* @param MessageDeleteEvent $event
* @param \Thelia\Core\Event\Message\MessageDeleteEvent $event
*/
public function delete(MessageDeleteEvent $event)
{

View File

@@ -23,12 +23,11 @@
namespace Thelia\Action;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\OrderEvent;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\OrderException;
use Thelia\Exception\TheliaProcessException;
use Thelia\Model\AddressQuery;
use Thelia\Model\OrderProductAttributeCombination;
@@ -38,7 +37,6 @@ use Thelia\Model\OrderStatus;
use Thelia\Model\Map\OrderTableMap;
use Thelia\Model\OrderAddress;
use Thelia\Model\OrderStatusQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\I18n;
/**
@@ -50,7 +48,7 @@ use Thelia\Tools\I18n;
class Order extends BaseAction implements EventSubscriberInterface
{
/**
* @param \Thelia\Core\Event\OrderEvent $event
* @param \Thelia\Core\Event\Order\OrderEvent $event
*/
public function setDeliveryAddress(OrderEvent $event)
{
@@ -62,7 +60,7 @@ class Order extends BaseAction implements EventSubscriberInterface
}
/**
* @param \Thelia\Core\Event\OrderEvent $event
* @param \Thelia\Core\Event\Order\OrderEvent $event
*/
public function setDeliveryModule(OrderEvent $event)
{
@@ -75,7 +73,7 @@ class Order extends BaseAction implements EventSubscriberInterface
}
/**
* @param \Thelia\Core\Event\OrderEvent $event
* @param \Thelia\Core\Event\Order\OrderEvent $event
*/
public function setInvoiceAddress(OrderEvent $event)
{
@@ -87,7 +85,7 @@ class Order extends BaseAction implements EventSubscriberInterface
}
/**
* @param \Thelia\Core\Event\OrderEvent $event
* @param \Thelia\Core\Event\Order\OrderEvent $event
*/
public function setPaymentModule(OrderEvent $event)
{
@@ -99,7 +97,7 @@ class Order extends BaseAction implements EventSubscriberInterface
}
/**
* @param \Thelia\Core\Event\OrderEvent $event
* @param \Thelia\Core\Event\Order\OrderEvent $event
*/
public function create(OrderEvent $event)
{
@@ -176,7 +174,7 @@ class Order extends BaseAction implements EventSubscriberInterface
/* fulfill order_products and decrease stock */
foreach($cartItems as $cartItem) {
foreach ($cartItems as $cartItem) {
$product = $cartItem->getProduct();
/* get translation */
@@ -185,7 +183,7 @@ class Order extends BaseAction implements EventSubscriberInterface
$pse = $cartItem->getProductSaleElements();
/* check still in stock */
if($cartItem->getQuantity() > $pse->getQuantity()) {
if ($cartItem->getQuantity() > $pse->getQuantity()) {
throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem);
}
@@ -200,7 +198,8 @@ class Order extends BaseAction implements EventSubscriberInterface
$taxDetail = $product->getTaxRule()->getTaxDetail(
$taxCountry,
$cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(),
$cartItem->getPrice(),
$cartItem->getPromoPrice(),
$this->getSession()->getLang()->getLocale()
);
@@ -226,13 +225,13 @@ class Order extends BaseAction implements EventSubscriberInterface
$orderProduct->save($con);
/* fulfill order_product_tax */
foreach($taxDetail as $tax) {
foreach ($taxDetail as $tax) {
$tax->setOrderProductId($orderProduct->getId());
$tax->save($con);
}
/* fulfill order_attribute_combination and decrease stock */
foreach($pse->getAttributeCombinations() as $attributeCombination) {
foreach ($pse->getAttributeCombinations() as $attributeCombination) {
$attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId());
$attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId());
@@ -242,7 +241,7 @@ class Order extends BaseAction implements EventSubscriberInterface
->setAttributeTitle($attribute->getTitle())
->setAttributeChapo($attribute->getChapo())
->setAttributeDescription($attribute->getDescription())
->setAttributePostscriptumn($attribute->getPostscriptum())
->setAttributePostscriptum($attribute->getPostscriptum())
->setAttributeAvTitle($attributeAv->getTitle())
->setAttributeAvChapo($attributeAv->getChapo())
->setAttributeAvDescription($attributeAv->getDescription())
@@ -279,13 +278,64 @@ class Order extends BaseAction implements EventSubscriberInterface
}
/**
* @param \Thelia\Core\Event\OrderEvent $event
* @param \Thelia\Core\Event\Order\OrderEvent $event
*/
public function sendOrderEmail(OrderEvent $event)
{
/* @todo */
}
/**
* @param OrderEvent $event
*/
public function updateStatus(OrderEvent $event)
{
$order = $event->getOrder();
$order->setStatusId($event->getStatus());
$order->save();
$event->setOrder($order);
}
/**
* @param OrderEvent $event
*/
public function updateDeliveryRef(OrderEvent $event)
{
$order = $event->getOrder();
$order->setDeliveryRef($event->getDeliveryRef());
$order->save();
$event->setOrder($order);
}
/**
* @param OrderAddressEvent $event
*/
public function updateAddress(OrderAddressEvent $event)
{
$orderAddress = $event->getOrderAddress();
$orderAddress
->setCustomerTitleId($event->getTitle())
->setCompany($event->getCompany())
->setFirstname($event->getFirstname())
->setLastname($event->getLastname())
->setAddress1($event->getAddress1())
->setAddress2($event->getAddress2())
->setAddress3($event->getAddress3())
->setZipcode($event->getZipcode())
->setCity($event->getCity())
->setCountryId($event->getCountry())
->setPhone($event->getPhone())
;
$orderAddress->save();
$event->setOrderAddress($orderAddress);
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
@@ -315,6 +365,9 @@ class Order extends BaseAction implements EventSubscriberInterface
TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128),
TheliaEvents::ORDER_PAY => array("create", 128),
TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128),
TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128),
TheliaEvents::ORDER_UPDATE_DELIVERY_REF => array("updateDeliveryRef", 128),
TheliaEvents::ORDER_UPDATE_ADDRESS => array("updateAddress", 128),
);
}

View File

@@ -0,0 +1,75 @@
<?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\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
/**
* Class Pdf
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Pdf extends BaseAction implements EventSubscriberInterface
{
public function generatePdf(PdfEvent $event)
{
$html2pdf = new \HTML2PDF($event->getOrientation(), $event->getFormat(), $event->getLang(), $event->getUnicode(), $event->getEncoding(), $event->getMarges());
$html2pdf->pdf->SetDisplayMode('real');
$html2pdf->writeHTML($event->getContent());
$event->setPdf($html2pdf->output(null, 'S'));
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::GENERATE_PDF => array("generatePdf", 128)
);
}
}

View File

@@ -30,51 +30,45 @@ use Thelia\Model\Product as ProductModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\ProductUpdateEvent;
use Thelia\Core\Event\ProductCreateEvent;
use Thelia\Core\Event\ProductDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\Product\ProductUpdateEvent;
use Thelia\Core\Event\Product\ProductCreateEvent;
use Thelia\Core\Event\Product\ProductDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ProductToggleVisibilityEvent;
use Thelia\Core\Event\ProductAddContentEvent;
use Thelia\Core\Event\ProductDeleteContentEvent;
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
use Thelia\Core\Event\Product\ProductAddContentEvent;
use Thelia\Core\Event\Product\ProductDeleteContentEvent;
use Thelia\Model\ProductAssociatedContent;
use Thelia\Model\ProductAssociatedContentQuery;
use Thelia\Model\ProductCategory;
use Thelia\Model\TaxRule;
use Thelia\Model\TaxRuleQuery;
use Thelia\Model\TaxQuery;
use Thelia\Model\AccessoryQuery;
use Thelia\Model\Accessory;
use Thelia\Core\Event\ProductAddAccessoryEvent;
use Thelia\Core\Event\ProductDeleteAccessoryEvent;
use Thelia\Core\Event\FeatureProductUpdateEvent;
use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent;
use Thelia\Model\FeatureProduct;
use Thelia\Model\FeatureQuery;
use Thelia\Core\Event\FeatureProductDeleteEvent;
use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent;
use Thelia\Model\FeatureProductQuery;
use Thelia\Model\ProductCategoryQuery;
use Thelia\Core\Event\ProductSetTemplateEvent;
use Thelia\Model\AttributeCombinationQuery;
use Thelia\Core\Event\Product\ProductSetTemplateEvent;
use Thelia\Model\ProductSaleElementsQuery;
use Propel\Runtime\ActiveQuery\PropelQuery;
use Thelia\Core\Event\ProductDeleteCategoryEvent;
use Thelia\Core\Event\ProductAddCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
use Thelia\Core\Event\Product\ProductAddCategoryEvent;
use Thelia\Model\AttributeAvQuery;
use Thelia\Model\AttributeCombination;
use Thelia\Core\Event\ProductCreateCombinationEvent;
use Thelia\Core\Event\Product\ProductCreateCombinationEvent;
use Propel\Runtime\Propel;
use Thelia\Model\Map\ProductTableMap;
use Thelia\Core\Event\ProductDeleteCombinationEvent;
use Thelia\Core\Event\Product\ProductDeleteCombinationEvent;
use Thelia\Model\ProductPrice;
use Thelia\Model\ProductSaleElements;
use Thelia\Core\Event\Product\ProductAddAccessoryEvent;
use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent;
class Product extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new product entry
*
* @param ProductCreateEvent $event
* @param \Thelia\Core\Event\Product\ProductCreateEvent $event
*/
public function create(ProductCreateEvent $event)
{
@@ -108,7 +102,7 @@ class Product extends BaseAction implements EventSubscriberInterface
/**
* Change a product
*
* @param ProductUpdateEvent $event
* @param \Thelia\Core\Event\Product\ProductUpdateEvent $event
*/
public function update(ProductUpdateEvent $event)
{
@@ -140,7 +134,7 @@ class Product extends BaseAction implements EventSubscriberInterface
/**
* Delete a product entry
*
* @param ProductDeleteEvent $event
* @param \Thelia\Core\Event\Product\ProductDeleteEvent $event
*/
public function delete(ProductDeleteEvent $event)
{
@@ -181,8 +175,8 @@ class Product extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(ProductQuery::create(), $event);
}
public function addContent(ProductAddContentEvent $event) {
public function addContent(ProductAddContentEvent $event)
{
if (ProductAssociatedContentQuery::create()
->filterByContentId($event->getContentId())
->filterByProduct($event->getProduct())->count() <= 0) {
@@ -198,8 +192,8 @@ class Product extends BaseAction implements EventSubscriberInterface
}
}
public function removeContent(ProductDeleteContentEvent $event) {
public function removeContent(ProductDeleteContentEvent $event)
{
$content = ProductAssociatedContentQuery::create()
->filterByContentId($event->getContentId())
->filterByProduct($event->getProduct())->findOne()
@@ -212,8 +206,8 @@ class Product extends BaseAction implements EventSubscriberInterface
;
}
public function addCategory(ProductAddCategoryEvent $event) {
public function addCategory(ProductAddCategoryEvent $event)
{
if (ProductCategoryQuery::create()
->filterByProduct($event->getProduct())
->filterByCategoryId($event->getCategoryId())
@@ -230,8 +224,8 @@ class Product extends BaseAction implements EventSubscriberInterface
}
}
public function removeCategory(ProductDeleteCategoryEvent $event) {
public function removeCategory(ProductDeleteCategoryEvent $event)
{
$productCategory = ProductCategoryQuery::create()
->filterByProduct($event->getProduct())
->filterByCategoryId($event->getCategoryId())
@@ -240,8 +234,8 @@ class Product extends BaseAction implements EventSubscriberInterface
if ($productCategory != null) $productCategory->delete();
}
public function addAccessory(ProductAddAccessoryEvent $event) {
public function addAccessory(ProductAddAccessoryEvent $event)
{
if (AccessoryQuery::create()
->filterByAccessory($event->getAccessoryId())
->filterByProductId($event->getProduct()->getId())->count() <= 0) {
@@ -257,8 +251,8 @@ class Product extends BaseAction implements EventSubscriberInterface
}
}
public function removeAccessory(ProductDeleteAccessoryEvent $event) {
public function removeAccessory(ProductDeleteAccessoryEvent $event)
{
$accessory = AccessoryQuery::create()
->filterByAccessory($event->getAccessoryId())
->filterByProductId($event->getProduct()->getId())->findOne()
@@ -271,8 +265,8 @@ class Product extends BaseAction implements EventSubscriberInterface
;
}
public function setProductTemplate(ProductSetTemplateEvent $event) {
public function setProductTemplate(ProductSetTemplateEvent $event)
{
$product = $event->getProduct();
// Delete all product feature relations
@@ -310,8 +304,8 @@ class Product extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event);
}
public function updateFeatureProductValue(FeatureProductUpdateEvent $event) {
public function updateFeatureProductValue(FeatureProductUpdateEvent $event)
{
// If the feature is not free text, it may have one ore more values.
// If the value exists, we do not change it
// If the value does not exists, we create it.
@@ -343,8 +337,7 @@ class Product extends BaseAction implements EventSubscriberInterface
if ($event->getIsTextValue() == true) {
$featureProduct->setFreeTextValue($event->getFeatureValue());
}
else {
} else {
$featureProduct->setFeatureAvId($event->getFeatureValue());
}
@@ -353,8 +346,8 @@ class Product extends BaseAction implements EventSubscriberInterface
$event->setFeatureProduct($featureProduct);
}
public function deleteFeatureProductValue(FeatureProductDeleteEvent $event) {
public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
{
$featureProduct = FeatureProductQuery::create()
->filterByProductId($event->getProductId())
->filterByFeatureId($event->getFeatureId())
@@ -362,8 +355,8 @@ class Product extends BaseAction implements EventSubscriberInterface
;
}
public function createProductCombination(ProductCreateCombinationEvent $event) {
public function createProductCombination(ProductCreateCombinationEvent $event)
{
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
@@ -399,7 +392,7 @@ class Product extends BaseAction implements EventSubscriberInterface
if (count($combinationAttributes) > 0) {
foreach($combinationAttributes as $attributeAvId) {
foreach ($combinationAttributes as $attributeAvId) {
$attributeAv = AttributeAvQuery::create()->findPk($attributeAvId);
@@ -417,8 +410,7 @@ class Product extends BaseAction implements EventSubscriberInterface
// Store all the stuff !
$con->commit();
}
catch(\Exception $ex) {
} catch (\Exception $ex) {
$con->rollback();
@@ -426,8 +418,8 @@ class Product extends BaseAction implements EventSubscriberInterface
}
}
public function deleteProductCombination(ProductDeleteCombinationEvent $event) {
public function deleteProductCombination(ProductDeleteCombinationEvent $event)
{
if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) {
$pse->delete();
}

View File

@@ -30,24 +30,17 @@ use Thelia\Model\Template as TemplateModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\TemplateUpdateEvent;
use Thelia\Core\Event\TemplateCreateEvent;
use Thelia\Core\Event\TemplateDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\TemplateAv;
use Thelia\Model\TemplateAvQuery;
use Thelia\Core\Event\Template\TemplateUpdateEvent;
use Thelia\Core\Event\Template\TemplateCreateEvent;
use Thelia\Core\Event\Template\TemplateDeleteEvent;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryEvent;
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\Core\Event\Template\TemplateAddAttributeEvent;
use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent;
use Thelia\Model\AttributeTemplateQuery;
use Thelia\Model\AttributeTemplate;
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
use Thelia\Core\Event\TemplateAddFeatureEvent;
use Thelia\Core\Event\Template\TemplateDeleteFeatureEvent;
use Thelia\Core\Event\Template\TemplateAddFeatureEvent;
use Thelia\Model\FeatureTemplateQuery;
use Thelia\Model\FeatureTemplate;
@@ -56,7 +49,7 @@ class Template extends BaseAction implements EventSubscriberInterface
/**
* Create a new template entry
*
* @param TemplateCreateEvent $event
* @param \Thelia\Core\Event\Template\TemplateCreateEvent $event
*/
public function create(TemplateCreateEvent $event)
{
@@ -77,7 +70,7 @@ class Template extends BaseAction implements EventSubscriberInterface
/**
* Change a product template
*
* @param TemplateUpdateEvent $event
* @param \Thelia\Core\Event\Template\TemplateUpdateEvent $event
*/
public function update(TemplateUpdateEvent $event)
{
@@ -99,7 +92,7 @@ class Template extends BaseAction implements EventSubscriberInterface
/**
* Delete a product template entry
*
* @param TemplateDeleteEvent $event
* @param \Thelia\Core\Event\Template\TemplateDeleteEvent $event
*/
public function delete(TemplateDeleteEvent $event)
{
@@ -121,8 +114,8 @@ class Template extends BaseAction implements EventSubscriberInterface
}
}
public function addAttribute(TemplateAddAttributeEvent $event) {
public function addAttribute(TemplateAddAttributeEvent $event)
{
if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) {
$attribute_template = new AttributeTemplate();
@@ -155,8 +148,8 @@ class Template extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(FeatureTemplateQuery::create(), $event);
}
public function deleteAttribute(TemplateDeleteAttributeEvent $event) {
public function deleteAttribute(TemplateDeleteAttributeEvent $event)
{
$attribute_template = AttributeTemplateQuery::create()
->filterByAttributeId($event->getAttributeId())
->filterByTemplate($event->getTemplate())->findOne()
@@ -165,8 +158,8 @@ class Template extends BaseAction implements EventSubscriberInterface
if ($attribute_template !== null) $attribute_template->delete();
}
public function addFeature(TemplateAddFeatureEvent $event) {
public function addFeature(TemplateAddFeatureEvent $event)
{
if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) {
$feature_template = new FeatureTemplate();
@@ -179,8 +172,8 @@ class Template extends BaseAction implements EventSubscriberInterface
}
}
public function deleteFeature(TemplateDeleteFeatureEvent $event) {
public function deleteFeature(TemplateDeleteFeatureEvent $event)
{
$feature_template = FeatureTemplateQuery::create()
->filterByFeatureId($event->getFeatureId())
->filterByTemplate($event->getTemplate())->findOne()
@@ -210,4 +203,4 @@ class Template extends BaseAction implements EventSubscriberInterface
);
}
}
}

View File

@@ -29,7 +29,7 @@ use Thelia\Model\Customer;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CartEvent;
use Thelia\Core\Event\Cart\CartEvent;
/**
* managed cart

View File

@@ -73,10 +73,11 @@ class CacheClear extends ContainerAwareCommand
try {
$directoryBrowser = new \DirectoryIterator($dir);
} catch(\UnexpectedValueException $e) {
} catch (\UnexpectedValueException $e) {
// throws same exception code for does not exist and permission denied ...
if(!file_exists($dir)) {
if (!file_exists($dir)) {
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
return;
}

View File

@@ -27,7 +27,7 @@ use Thelia\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Core\Event\ImageEvent;
use Thelia\Core\Event\Image\ImageEvent;
use Thelia\Core\HttpFoundation\Request;
use Symfony\Component\Console\Input\InputArgument;
use Thelia\Core\Event\TheliaEvents;

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Install\CheckPermission;
use Thelia\Install\Database;
/**
@@ -82,6 +83,9 @@ class Install extends ContainerAwareCommand
'',
'Welcome to Thelia install process',
'You need information about your database configuration (host, username, password, database name, etc)',
'',
'<info>Caution : You are installing Thelia in cli mode, we verify some information, but this information are only available for the cli php sapi</info>',
'<info>This informations can be different in your apache or cgi php.ini files</info>',
''
));
@@ -136,40 +140,35 @@ class Install extends ContainerAwareCommand
"Checking some permissions"
));
$confDir = THELIA_ROOT . "local/config";
$cacheDir = THELIA_ROOT . "cache";
$logDir = THELIA_ROOT . "log";
$permissions = new CheckPermission(false, $this->getContainer()->get('thelia.translator'));
$isValid = $permissions->exec();
$conf = is_writable($confDir);
$cache = is_writable($cacheDir);
$log = is_writable($logDir);
foreach($permissions->getValidationMessages() as $item => $data) {
if($data['status']) {
$output->writeln(array(
sprintf("<info>%s ...</info> %s",
$data['text'],
"<info>Ok</info>")
)
);
} else {
$output->writeln(array(
sprintf("<error>%s </error>%s",
$data['text'],
sprintf("<error>%s</error>", $data["hint"])
)
));
}
$output->writeln(array(
sprintf(
"<info>config directory(%s)...</info> %s",
$confDir,
$conf ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>cache directory(%s)...</info> %s"
,$cacheDir,
$cache ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>log directory(%s)...</info> %s",
$logDir,
$log ? "<info>Ok</info>" : "<error>Fail</error>"
),
));
if ($conf === false || $cache === false || $log === false) {
$output->writeln(array(
"",
"<error>Please put correct permission and reload install process</error>"
));
exit;
}
if(false === $isValid) {
$output->writeln(array(
"",
"<error>Please put correct permissions and reload install process</error>"
));
exit;
}
}
/**

View File

@@ -25,12 +25,9 @@ namespace Thelia\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Model\ModuleQuery;
/**
@@ -62,7 +59,7 @@ class ModuleActivateCommand extends BaseModuleGenerate
$module = ModuleQuery::create()->findOneByCode($moduleCode);
if(null === $module) {
if (null === $module) {
throw new \RuntimeException(sprintf("module %s not found", $moduleCode));
}
@@ -74,7 +71,7 @@ class ModuleActivateCommand extends BaseModuleGenerate
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance->activate();
} catch(\Exception $e) {
} catch (\Exception $e) {
throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()));
}

View File

@@ -56,7 +56,7 @@ class ReloadDatabaseCommand extends BaseModuleGenerate
$tables = $connection->query("SHOW TABLES");
$connection->query("SET FOREIGN_KEY_CHECKS = 0");
foreach($tables as $table) {
foreach ($tables as $table) {
$connection->query(sprintf("DROP TABLE `%s`", $table[0]));
}
$connection->query("SET FOREIGN_KEY_CHECKS = 1");

View File

@@ -25,7 +25,7 @@ namespace %%NAMESPACE%%;
use Thelia\Module\BaseModule;
class Class extends BaseModule
class %%CLASSNAME%% extends BaseModule
{
/**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class

View File

@@ -60,7 +60,7 @@ class DatabaseConfiguration implements ConfigurationInterface
->cannotBeEmpty()
->end()
->scalarNode("classname")
->defaultValue("\Propel\Runtime\Connection\PropelPDO")
->defaultValue("\Propel\Runtime\Connection\ConnectionWrapper")
->end()
->end()
->end()

View File

@@ -111,6 +111,16 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pdf" class="Thelia\Action\Pdf">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.country" class="Thelia\Action\Country">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -21,8 +21,12 @@
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature-availability"/>
<loop class="Thelia\Core\Template\Loop\FeatureValue" name="feature_value"/>
<loop class="Thelia\Core\Template\Loop\Folder" name="folder"/>
<loop class="Thelia\Core\Template\Loop\FolderPath" name="folder-path"/>
<loop class="Thelia\Core\Template\Loop\Module" name="module"/>
<loop class="Thelia\Core\Template\Loop\Order" name="order"/>
<loop class="Thelia\Core\Template\Loop\OrderAddress" name="order_address"/>
<loop class="Thelia\Core\Template\Loop\OrderProduct" name="order_product"/>
<loop class="Thelia\Core\Template\Loop\OrderProductAttributeCombination" name="order_product_attribute_combination"/>
<loop class="Thelia\Core\Template\Loop\OrderStatus" name="order-status"/>
<loop class="Thelia\Core\Template\Loop\CategoryPath" name="category-path"/>
<loop class="Thelia\Core\Template\Loop\Payment" name="payment"/>
@@ -84,6 +88,7 @@
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
<form name="thelia.order.update.address" class="Thelia\Form\OrderUpdateAddress"/>
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
<form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/>
@@ -204,6 +209,10 @@
</call>
</service>
<service id="smarty.plugin.type" class="Thelia\Core\Template\Smarty\Plugins\Type" scope="request">
<tag name="thelia.parser.register_plugin"/>
</service>
<service id="smart.plugin.form" class="Thelia\Core\Template\Smarty\Plugins\Form" scope="request">
<tag name="thelia.parser.register_plugin"/>

View File

@@ -64,7 +64,7 @@
<argument key="debug">%kernel.debug%</argument>
</argument>
<argument type="service" id="request.context"/>
<tag name="router.register" priority="254"/>
<tag name="router.register" priority="128"/>
</service>
<service id="router.rewrite" class="Thelia\Core\Routing\RewritingRouter">

View File

@@ -123,9 +123,35 @@
<!-- end Customer rule management -->
<!-- Order rule management -->
<!-- address management -->
<route id="admin.order" path="/admin/order">
<route id="admin.address.delete" path="/admin/address/delete" methods="post">
<default key="_controller">Thelia\Controller\Admin\AddressController::deleteAction</default>
</route>
<route id="admin.address.makeItDefault" path="/admin/address/use" methods="post">
<default key="_controller">Thelia\Controller\Admin\AddressController::useAddressAction</default>
</route>
<route id="admin.address.create" path="/admin/address/create" methods="post">
<default key="_controller">Thelia\Controller\Admin\AddressController::createAction</default>
</route>
<route id="admin.address.update.view" path="/admin/address/update/{address_id}">
<default key="_controller">Thelia\Controller\Admin\AddressController::updateAction</default>
<requirement key="address_id">\d+</requirement>
</route>
<route id="admin.address.save" path="/admin/address/save/{address_id}">
<default key="_controller">Thelia\Controller\Admin\AddressController::processUpdateAction</default>
<requirement key="address_id">\d+</requirement>
</route>
<!-- end address management -->
<!-- order management -->
<route id="admin.order.list" path="/admin/orders">
<default key="_controller">Thelia\Controller\Admin\OrderController::indexAction</default>
</route>
@@ -134,7 +160,33 @@
<requirement key="order_id">\d+</requirement>
</route>
<!-- end Customer rule management -->
<route id="admin.order.list.update.status" path="/admin/order/update/status">
<default key="_controller">Thelia\Controller\Admin\OrderController::updateStatus</default>
</route>
<route id="admin.order.update.status" path="/admin/order/update/{order_id}/status">
<default key="_controller">Thelia\Controller\Admin\OrderController::updateStatus</default>
</route>
<route id="admin.order.update.deliveryRef" path="/admin/order/update/{order_id}/delivery-ref">
<default key="_controller">Thelia\Controller\Admin\OrderController::updateDeliveryRef</default>
</route>
<route id="admin.order.update.address" path="/admin/order/update/{order_id}/address">
<default key="_controller">Thelia\Controller\Admin\OrderController::updateAddress</default>
</route>
<route id="admin.order.pdf.invoice" path="/admin/order/pdf/invoice/{order_id}">
<default key="_controller">Thelia\Controller\Admin\OrderController::generateInvoicePdf</default>
<requirement key="order_id">\d+</requirement>
</route>
<route id="admin.order.pdf.invoice" path="/admin/order/pdf/delivery/{order_id}">
<default key="_controller">Thelia\Controller\Admin\OrderController::generateDeliveryPdf</default>
<requirement key="order_id">\d+</requirement>
</route>
<!-- end order management -->
<!-- Categories management -->
@@ -353,8 +405,31 @@
<default key="_controller">Thelia\Controller\Admin\FolderController::updatePositionAction</default>
</route>
<!-- Countries routes management -->
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
<default key="_controller">Thelia\Controller\Admin\CountryController::defaultAction</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" path="/admin/configuration/country/update/{country_id}">
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
<requirement key="country_id">\d+</requirement>
</route>
<route id="admin.configuration.countries.delete" path="/admin/configuration/countries/delete">
<default key="_controller">Thelia\Controller\Admin\CountryController::deleteAction</default>
</route>
<route id="admin.configuration.toggle-default" path="/admin/configuration/country/toggleDefault">
<default key="_controller">Thelia\Controller\Admin\CountryController::toggleDefaultAction</default>
</route>
<!-- content routes management -->
<route id="admin.folders.create" path="/admin/content/create">
<route id="admin.content.create" path="/admin/content/create">
<default key="_controller">Thelia\Controller\Admin\ContentController::createAction</default>
</route>
@@ -379,6 +454,14 @@
<default key="_controller">Thelia\Controller\Admin\ContentController::deleteAction</default>
</route>
<route id="admin.content.additional-folder.add" path="/admin/content/folder/add">
<default key="_controller">Thelia\Controller\Admin\ContentController::addAdditionalFolderAction</default>
</route>
<route id="admin.content.additional-folder.delete" path="/admin/content/folder/delete">
<default key="_controller">Thelia\Controller\Admin\ContentController::removeAdditionalFolderAction</default>
</route>
<!-- Route to the Coupon controller (process Coupon browsing) -->
@@ -608,20 +691,7 @@
<!-- 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 -->

View File

@@ -117,22 +117,22 @@
<!-- order management process -->
<route id="order.delivery.process" path="/order/delivery" methods="post">
<default key="_controller">Thelia\Controller\Front\OrderController::deliver</default>
<default key="_view">order_delivery</default>
<default key="_view">order-delivery</default>
</route>
<route id="order.delivery" path="/order/delivery">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">order_delivery</default>
<default key="_view">order-delivery</default>
</route>
<route id="order.invoice.process" path="/order/invoice" methods="post">
<default key="_controller">Thelia\Controller\Front\OrderController::invoice</default>
<default key="_view">order_invoice</default>
<default key="_view">order-invoice</default>
</route>
<route id="order.invoice" path="/order/invoice">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">order_invoice</default>
<default key="_view">order-invoice</default>
</route>
<route id="order.payment.process" path="/order/pay">
@@ -141,7 +141,7 @@
<route id="order.placed" path="/order/placed/{order_id}">
<default key="_controller">Thelia\Controller\Front\OrderController::orderPlaced</default>
<default key="_view">order_placed</default>
<default key="_view">order-placed</default>
</route>
<!-- end order management process -->

View File

@@ -25,7 +25,6 @@ namespace Thelia\Controller\Admin;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ToggleVisibilityEvent;
/**
* An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object.
@@ -53,14 +52,13 @@ abstract class AbstractCrudController extends BaseAdminController
protected $visibilityToggleEventIdentifier;
protected $changePositionEventIdentifier;
/**
* @param string $objectName the lower case object name. Example. "message"
*
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable)
*
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
@@ -70,7 +68,7 @@ abstract class AbstractCrudController extends BaseAdminController
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
*
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/
public function __construct(
$objectName,
@@ -109,94 +107,93 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Return the creation form for this object
*/
protected abstract function getCreationForm();
abstract protected function getCreationForm();
/**
* Return the update form for this object
*/
protected abstract function getUpdateForm();
abstract protected function getUpdateForm();
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param unknown $object
*/
protected abstract function hydrateObjectForm($object);
abstract protected function hydrateObjectForm($object);
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected abstract function getCreationEvent($formData);
abstract protected function getCreationEvent($formData);
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected abstract function getUpdateEvent($formData);
abstract protected function getUpdateEvent($formData);
/**
* Creates the delete event with the provided form data
*/
protected abstract function getDeleteEvent();
abstract protected function getDeleteEvent();
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected abstract function eventContainsObject($event);
abstract protected function eventContainsObject($event);
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected abstract function getObjectFromEvent($event);
abstract protected function getObjectFromEvent($event);
/**
* Load an existing object from the database
*/
protected abstract function getExistingObject();
abstract protected function getExistingObject();
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param unknown $object
*/
protected abstract function getObjectLabel($object);
abstract protected function getObjectLabel($object);
/**
* Returns the object ID from the object
*
* @param unknown $object
*/
protected abstract function getObjectId($object);
abstract protected function getObjectId($object);
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected abstract function renderListTemplate($currentOrder);
abstract protected function renderListTemplate($currentOrder);
/**
* Render the edition template
*/
protected abstract function renderEditionTemplate();
abstract protected function renderEditionTemplate();
/**
* Redirect to the edition template
*/
protected abstract function redirectToEditionTemplate();
abstract protected function redirectToEditionTemplate();
/**
* Redirect to the list template
*/
protected abstract function redirectToListTemplate();
abstract protected function redirectToListTemplate();
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
@@ -211,7 +208,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object creation processing if required.
*
* @param unknown $createEvent the create event
* @param unknown $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
@@ -222,7 +219,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object update processing if required.
*
* @param unknown $updateEvent the update event
* @param unknown $updateEvent the update event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalUpdateAction($updateEvent)
@@ -233,7 +230,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object delete processing if required.
*
* @param unknown $deleteEvent the delete event
* @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
@@ -244,7 +241,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object position change processing if required.
*
* @param unknown $deleteEvent the delete event
* @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalUpdatePositionAction($positionChangeEvent)
@@ -282,7 +279,6 @@ abstract class AbstractCrudController extends BaseAdminController
public function defaultAction()
{
if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response;
return $this->renderList();
}
@@ -323,22 +319,19 @@ abstract class AbstractCrudController extends BaseAdminController
$response = $this->performAdditionalCreateAction($createEvent);
if ($response == null) {
if ($response == null) {
// Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
// Redirect to the success URL
$this->redirect($successUrl);
}
else {
} else {
return $response;
}
}
catch (FormValidationException $ex) {
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
@@ -423,16 +416,13 @@ abstract class AbstractCrudController extends BaseAdminController
// Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl());
}
else {
} else {
return $response;
}
}
catch (FormValidationException $ex) {
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
@@ -469,8 +459,7 @@ abstract class AbstractCrudController extends BaseAdminController
$event = $this->createUpdatePositionEvent($mode, $position);
$this->dispatch($this->changePositionEventIdentifier, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -479,14 +468,13 @@ abstract class AbstractCrudController extends BaseAdminController
if ($response == null) {
$this->redirectToListTemplate();
}
else {
} else {
return $response;
}
}
protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true) {
protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true)
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
@@ -507,8 +495,7 @@ abstract class AbstractCrudController extends BaseAdminController
$event = new UpdatePositionEvent($object->getId(), $mode, $position);
$this->dispatch($eventName, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}

View File

@@ -0,0 +1,306 @@
<?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\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\AddressCreateForm;
use Thelia\Form\AddressUpdateForm;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
/**
* Class AddressController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class AddressController extends AbstractCrudController
{
public function __construct()
{
parent::__construct(
'address',
null,
null,
'admin.customer.update.view',
'admin.address.create',
'admin.address.update',
'admin.address.delete',
TheliaEvents::ADDRESS_CREATE,
TheliaEvents::ADDRESS_UPDATE,
TheliaEvents::ADDRESS_DELETE,
null,
null
);
}
public function useAddressAction()
{
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
$address_id = $this->getRequest()->request->get('address_id');
try {
$address = AddressQuery::create()->findPk($address_id);
if (null === $address) {
throw new \InvalidArgumentException(sprintf('%d address does not exists', $address_id));
}
$addressEvent = new AddressEvent($address);
$this->dispatch(TheliaEvents::ADDRESS_DEFAULT, $addressEvent);
$this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId()));
} catch(\Exception $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage()));
}
$this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId()));
}
/**
* Return the creation form for this object
*/
protected function getCreationForm()
{
return new AddressCreateForm($this->getRequest());
}
/**
* Return the update form for this object
*/
protected function getUpdateForm()
{
return new AddressUpdateForm($this->getRequest());
}
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param \Thelia\Model\Address $object
*/
protected function hydrateObjectForm($object)
{
$data = array(
"label" => $object->getLabel(),
"title" => $object->getTitleId(),
"firstname" => $object->getFirstname(),
"lastname" => $object->getLastname(),
"address1" => $object->getAddress1(),
"address2" => $object->getAddress2(),
"address3" => $object->getAddress3(),
"zipcode" => $object->getZipcode(),
"city" => $object->getCity(),
"country" => $object->getCountryId(),
"cellphone" => $object->getCellphone(),
"phone" => $object->getPhone(),
"company" => $object->getCompany()
);
return new AddressUpdateForm($this->getRequest(), "form", $data);
}
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected function getCreationEvent($formData)
{
$event = $this->getCreateOrUpdateEvent($formData);
$customer = CustomerQuery::create()->findPk($this->getRequest()->get("customer_id"));
$event->setCustomer($customer);
return $event;
}
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected function getUpdateEvent($formData)
{
$event = $this->getCreateOrUpdateEvent($formData);
$event->setAddress($this->getExistingObject());
return $event;
}
protected function getCreateOrUpdateEvent($formData)
{
$event = new AddressCreateOrUpdateEvent(
$formData["label"],
$formData["title"],
$formData["firstname"],
$formData["lastname"],
$formData["address1"],
$formData["address2"],
$formData["address3"],
$formData["zipcode"],
$formData["city"],
$formData["country"],
$formData["cellphone"],
$formData["phone"],
$formData["company"],
$formData["is_default"]
);
return $event;
}
/**
* Creates the delete event with the provided form data
*/
protected function getDeleteEvent()
{
return new AddressEvent($this->getExistingObject());
}
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected function eventContainsObject($event)
{
return null !== $event->getAddress();
}
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected function getObjectFromEvent($event)
{
return null;
}
/**
* Load an existing object from the database
*/
protected function getExistingObject()
{
return AddressQuery::create()->findPk($this->getRequest()->get('address_id'));
}
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param unknown $object
*/
protected function getObjectLabel($object)
{
return $object->getLabel();
}
/**
* Returns the object ID from the object
*
* @param unknown $object
*/
protected function getObjectId($object)
{
return $object->getId();
}
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected function renderListTemplate($currentOrder)
{
// TODO: Implement renderListTemplate() method.
}
/**
* Render the edition template
*/
protected function renderEditionTemplate()
{
return $this->render('ajax/address-update-modal', array(
"address_id" => $this->getRequest()->get('address_id'),
"customer_id" => $this->getExistingObject()->getCustomerId()
));
}
/**
* Redirect to the edition template
*/
protected function redirectToEditionTemplate()
{
$address = $this->getExistingObject();
$this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId()));
}
/**
* Redirect to the list template
*/
protected function redirectToListTemplate()
{
// TODO: Implement redirectToListTemplate() method.
}
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
$address = $deleteEvent->getAddress();
$this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId()));
}
/**
* Put in this method post object creation processing if required.
*
* @param AddressCreateOrUpdateEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
$this->redirectToEditionTemplate();
}
protected function performAdditionalUpdateAction($event)
{
$this->redirectToEditionTemplate();
}
}

View File

@@ -23,10 +23,6 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class AdminController extends BaseAdminController
{
public function indexAction()
@@ -36,6 +32,6 @@ class AdminController extends BaseAdminController
public function updateAction()
{
return $this->render("profile-edit");
return $this->render("profile-edit");
}
}

View File

@@ -23,10 +23,10 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeAvCreateEvent;
use Thelia\Model\AttributeAvQuery;
use Thelia\Form\AttributeAvModificationForm;
use Thelia\Form\AttributeAvCreationForm;
@@ -193,4 +193,4 @@ class AttributeAvController extends AbstractCrudController
$this->getViewArguments()
);
}
}
}

View File

@@ -23,18 +23,18 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AttributeDeleteEvent;
use Thelia\Core\Event\Attribute\AttributeDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeUpdateEvent;
use Thelia\Core\Event\AttributeCreateEvent;
use Thelia\Core\Event\Attribute\AttributeUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeCreateEvent;
use Thelia\Model\AttributeQuery;
use Thelia\Form\AttributeModificationForm;
use Thelia\Form\AttributeCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeEvent;
use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeEvent;
/**
* Manages attributes
@@ -113,7 +113,7 @@ class AttributeController extends AbstractCrudController
if ($attr_values !== null) {
foreach($attr_values as $id => $value) {
foreach ($attr_values as $id => $value) {
$event = new AttributeAvUpdateEvent($id);
@@ -168,7 +168,7 @@ class AttributeController extends AbstractCrudController
$attr_array = array();
foreach($attr_av_list as $attr_av) {
foreach ($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
}
@@ -262,8 +262,7 @@ class AttributeController extends AbstractCrudController
$this->dispatch($eventType, $event);
}
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -286,4 +285,4 @@ class AttributeController extends AbstractCrudController
{
return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES);
}
}
}

View File

@@ -51,7 +51,7 @@ class BaseAdminController extends BaseController
/**
* Helper to append a message to the admin log.
*
* @param unknown $message
* @param string $message
*/
public function adminLogAppend($message)
{
@@ -187,12 +187,12 @@ class BaseAdminController extends BaseController
/**
* @return a ParserInterface instance parser
*/
protected function getParser()
protected function getParser($template = null)
{
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(ConfigQuery::read('base_admin_template', 'admin/default'));
$parser->setTemplate($template ?: ConfigQuery::read('base_admin_template', 'admin/default'));
return $parser;
}
@@ -246,9 +246,9 @@ class BaseAdminController extends BaseController
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
*/
public function redirectToRoute($routeId, $urlParameters = array())
public function redirectToRoute($routeId, $urlParameters = array(), $routeParameters = array())
{
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters));
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, $routeParameters), $urlParameters));
}
/**
@@ -293,20 +293,19 @@ class BaseAdminController extends BaseController
return $this->getCurrentEditionLang()->getLocale();
}
/**
* Return the current list order identifier for a given object name,
* updating in using the current request.
*
* @param unknown $objectName the object name (e.g. 'attribute', 'message')
* @param unknown $objectName the object name (e.g. 'attribute', 'message')
* @param unknown $requestParameterName the name of the request parameter that defines the list order
* @param unknown $defaultListOrder the default order to use, if none is defined
* @param string $updateSession if true, the session will be updated with the current order.
* @param unknown $defaultListOrder the default order to use, if none is defined
* @param string $updateSession if true, the session will be updated with the current order.
*
* @return String the current liste order.
*/
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true) {
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true)
{
$order = $defaultListOrder;
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName);
@@ -318,7 +317,6 @@ class BaseAdminController extends BaseController
);
if ($updateSession) $this->getSession()->set($orderSessionIdentifier, $order);
return $order;
}
@@ -353,8 +351,8 @@ class BaseAdminController extends BaseController
/** Clear the remember me cookie.
*
*/
protected function clearRememberMeCookie() {
protected function clearRememberMeCookie()
{
$ctp = new CookieTokenProvider();
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
@@ -380,10 +378,12 @@ class BaseAdminController extends BaseController
* Render the given template, and returns the result as a string.
*
* @param $templateName the complete template name, with extension
* @param array $args the template arguments
* @param array $args the template arguments
* @param null $templateDir
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderRaw($templateName, $args = array())
protected function renderRaw($templateName, $args = array(), $templateDir = null)
{
// Add the template standard extension
@@ -419,7 +419,7 @@ class BaseAdminController extends BaseController
// Render the template.
try {
$data = $this->getParser()->render($templateName, $args);
$data = $this->getParser($templateDir)->render($templateName, $args);
return $data;
} catch (AuthenticationException $ex) {

View File

@@ -24,19 +24,17 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Event\CategoryDeleteEvent;
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CategoryUpdateEvent;
use Thelia\Core\Event\CategoryCreateEvent;
use Thelia\Log\Tlog;
use Thelia\Core\Event\Category\CategoryUpdateEvent;
use Thelia\Core\Event\Category\CategoryCreateEvent;
use Thelia\Model\CategoryQuery;
use Thelia\Form\CategoryModificationForm;
use Thelia\Form\CategoryCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\CategoryDeleteContentEvent;
use Thelia\Core\Event\CategoryAddContentEvent;
use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\Category\CategoryDeleteContentEvent;
use Thelia\Core\Event\Category\CategoryAddContentEvent;
use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria;
@@ -49,7 +47,8 @@ use Thelia\Model\CategoryAssociatedContentQuery;
*/
class CategoryController extends AbstractCrudController
{
public function __construct() {
public function __construct()
{
parent::__construct(
'category',
'manual',
@@ -68,15 +67,18 @@ class CategoryController extends AbstractCrudController
);
}
protected function getCreationForm() {
protected function getCreationForm()
{
return new CategoryCreationForm($this->getRequest());
}
protected function getUpdateForm() {
protected function getUpdateForm()
{
return new CategoryModificationForm($this->getRequest());
}
protected function getCreationEvent($formData) {
protected function getCreationEvent($formData)
{
$createEvent = new CategoryCreateEvent();
$createEvent
@@ -89,7 +91,8 @@ class CategoryController extends AbstractCrudController
return $createEvent;
}
protected function getUpdateEvent($formData) {
protected function getUpdateEvent($formData)
{
$changeEvent = new CategoryUpdateEvent($formData['id']);
// Create and dispatch the change event
@@ -107,8 +110,8 @@ class CategoryController extends AbstractCrudController
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('category_id', null),
$positionChangeMode,
@@ -116,16 +119,18 @@ class CategoryController extends AbstractCrudController
);
}
protected function getDeleteEvent() {
protected function getDeleteEvent()
{
return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0));
}
protected function eventContainsObject($event) {
protected function eventContainsObject($event)
{
return $event->hasCategory();
}
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -143,21 +148,25 @@ class CategoryController extends AbstractCrudController
return new CategoryModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
protected function getObjectFromEvent($event)
{
return $event->hasCategory() ? $event->getCategory() : null;
}
protected function getExistingObject() {
protected function getExistingObject()
{
return CategoryQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('category_id', 0));
}
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getTitle();
}
protected function getObjectId($object) {
protected function getObjectId($object)
{
return $object->getId();
}
@@ -170,8 +179,8 @@ class CategoryController extends AbstractCrudController
);
}
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
// Get product order
$product_order = $this->getListOrderFromSession('product', 'product_order', 'manual');
@@ -183,19 +192,21 @@ class CategoryController extends AbstractCrudController
));
}
protected function redirectToListTemplate() {
protected function redirectToListTemplate()
{
$this->redirectToRoute(
'admin.categories.default',
array('category_id' => $this->getRequest()->get('category_id', 0))
);
}
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('category-edit', $this->getEditionArguments());
}
protected function redirectToEditionTemplate() {
protected function redirectToEditionTemplate()
{
$this->redirectToRoute("admin.categories.update", $this->getEditionArguments());
}
@@ -257,8 +268,8 @@ class CategoryController extends AbstractCrudController
return null;
}
public function getAvailableRelatedContentAction($categoryId, $folderId) {
public function getAvailableRelatedContentAction($categoryId, $folderId)
{
$result = array();
$folders = FolderQuery::create()->filterById($folderId)->find();
@@ -273,7 +284,7 @@ class CategoryController extends AbstractCrudController
;
if ($list !== null) {
foreach($list as $item) {
foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
}
}
@@ -282,8 +293,8 @@ class CategoryController extends AbstractCrudController
return $this->jsonResponse(json_encode($result));
}
public function addRelatedContentAction() {
public function addRelatedContentAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -298,8 +309,7 @@ class CategoryController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -341,8 +351,8 @@ class CategoryController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteRelatedContentAction() {
public function deleteRelatedContentAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -357,8 +367,7 @@ class CategoryController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}

View File

@@ -23,14 +23,13 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\ConfigDeleteEvent;
use Thelia\Core\Event\Config\ConfigDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\ConfigUpdateEvent;
use Thelia\Core\Event\ConfigCreateEvent;
use Thelia\Core\Event\Config\ConfigUpdateEvent;
use Thelia\Core\Event\Config\ConfigCreateEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Form\ConfigModificationForm;
use Thelia\Form\ConfigCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
/**
* Manages variables
@@ -39,7 +38,8 @@ use Thelia\Core\Event\UpdatePositionEvent;
*/
class ConfigController extends AbstractCrudController
{
public function __construct() {
public function __construct()
{
parent::__construct(
'variable',
'name',
@@ -58,15 +58,18 @@ class ConfigController extends AbstractCrudController
);
}
protected function getCreationForm() {
protected function getCreationForm()
{
return new ConfigCreationForm($this->getRequest());
}
protected function getUpdateForm() {
protected function getUpdateForm()
{
return new ConfigModificationForm($this->getRequest());
}
protected function getCreationEvent($data) {
protected function getCreationEvent($data)
{
$createEvent = new ConfigCreateEvent();
$createEvent
@@ -78,11 +81,11 @@ class ConfigController extends AbstractCrudController
->setSecured($data['secured'])
;
return $createEvent;
}
protected function getUpdateEvent($data) {
protected function getUpdateEvent($data)
{
$changeEvent = new ConfigUpdateEvent($data['id']);
// Create and dispatch the change event
@@ -101,16 +104,18 @@ class ConfigController extends AbstractCrudController
return $changeEvent;
}
protected function getDeleteEvent() {
protected function getDeleteEvent()
{
return new ConfigDeleteEvent($this->getRequest()->get('variable_id'));
}
protected function eventContainsObject($event) {
protected function eventContainsObject($event)
{
return $event->hasConfig();
}
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -129,40 +134,48 @@ class ConfigController extends AbstractCrudController
return new ConfigModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
protected function getObjectFromEvent($event)
{
return $event->hasConfig() ? $event->getConfig() : null;
}
protected function getExistingObject() {
protected function getExistingObject()
{
return ConfigQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('variable_id'));
}
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getName();
}
protected function getObjectId($object) {
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
return $this->render('variables', array('order' => $currentOrder));
}
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('variable-edit', array('variable_id' => $this->getRequest()->get('variable_id')));
}
protected function redirectToEditionTemplate() {
protected function redirectToEditionTemplate()
{
$this->redirectToRoute(
"admin.configuration.variables.update",
array('variable_id' => $this->getRequest()->get('variable_id'))
);
}
protected function redirectToListTemplate() {
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.variables.default');
}
@@ -188,4 +201,4 @@ class ConfigController extends AbstractCrudController
$this->redirectToRoute('admin.configuration.variables.default');
}
}
}

View File

@@ -22,8 +22,10 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Content\ContentAddFolderEvent;
use Thelia\Core\Event\Content\ContentCreateEvent;
use Thelia\Core\Event\Content\ContentDeleteEvent;
use Thelia\Core\Event\Content\ContentRemoveFolderEvent;
use Thelia\Core\Event\Content\ContentToggleVisibilityEvent;
use Thelia\Core\Event\Content\ContentUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
@@ -32,7 +34,6 @@ use Thelia\Form\ContentCreationForm;
use Thelia\Form\ContentModificationForm;
use Thelia\Model\ContentQuery;
/**
* Class ContentController
* @package Thelia\Controller\Admin
@@ -61,6 +62,62 @@ class ContentController extends AbstractCrudController
);
}
/**
* controller adding content to additional folder
*
* @return mixed|\Symfony\Component\HttpFoundation\Response
*/
public function addAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.content.update')) return $response;
$folder_id = intval($this->getRequest()->request->get('additional_folder_id'));
if ($folder_id > 0) {
$event = new ContentAddFolderEvent(
$this->getExistingObject(),
$folder_id
);
try {
$this->dispatch(TheliaEvents::CONTENT_ADD_FOLDER, $event);
} catch (\Exception $e) {
return $this->errorPage($e);
}
}
$this->redirectToEditionTemplate();
}
/**
* controller removing additional folder to a content
*
* @return mixed|\Symfony\Component\HttpFoundation\Response
*/
public function removeAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.content.update')) return $response;
$folder_id = intval($this->getRequest()->request->get('additional_folder_id'));
if ($folder_id > 0) {
$event = new ContentRemoveFolderEvent(
$this->getExistingObject(),
$folder_id
);
try {
$this->dispatch(TheliaEvents::CONTENT_REMOVE_FOLDER, $event);
} catch (\Exception $e) {
return $this->errorPage($e);
}
}
$this->redirectToEditionTemplate();
}
/**
* Return the creation form for this object
*/
@@ -212,10 +269,10 @@ class ContentController extends AbstractCrudController
{
$folderId = $this->getRequest()->get('folder_id', null);
if(null === $folderId) {
if (null === $folderId) {
$content = $this->getExistingObject();
if($content) {
if ($content) {
$folderId = $content->getDefaultFolderId();
}
}
@@ -243,7 +300,8 @@ class ContentController extends AbstractCrudController
{
return array(
'content_id' => $this->getRequest()->get('content_id', 0),
'current_tab' => $this->getRequest()->get('current_tab', 'general')
'current_tab' => $this->getRequest()->get('current_tab', 'general'),
'folder_id' => $this->getFolderId(),
);
}
@@ -275,7 +333,7 @@ class ContentController extends AbstractCrudController
}
/**
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
* @return Response|void
*/
protected function performAdditionalUpdateAction($updateEvent)
@@ -293,8 +351,8 @@ class ContentController extends AbstractCrudController
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
* @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
@@ -344,4 +402,4 @@ class ContentController extends AbstractCrudController
{
return new ContentToggleVisibilityEvent($this->getExistingObject());
}
}
}

View File

@@ -22,31 +22,249 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Country\CountryCreateEvent;
use Thelia\Core\Event\Country\CountryDeleteEvent;
use Thelia\Core\Event\Country\CountryToggleDefaultEvent;
use Thelia\Core\Event\Country\CountryUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CountryCreationForm;
use Thelia\Form\CountryModificationForm;
use Thelia\Model\CountryQuery;
/**
* Class CustomerController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryController extends BaseAdminController
class CountryController extends AbstractCrudController
{
public function indexAction()
/**
* @param string $objectName the lower case object name. Example. "message"
*
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable)
*
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
*
* @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE
* @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
*
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/
public function __construct()
{
parent::__construct(
'country',
'manual',
'country_order',
'admin.country.default',
'admin.country.create',
'admin.country.update',
'admin.country.delete',
TheliaEvents::COUNTRY_CREATE,
TheliaEvents::COUNTRY_UPDATE,
TheliaEvents::COUNTRY_DELETE
);
}
/**
* Return the creation form for this object
*/
protected function getCreationForm()
{
return new CountryCreationForm($this->getRequest());
}
/**
* Return the update form for this object
*/
protected function getUpdateForm()
{
return new CountryModificationForm($this->getRequest());
}
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param \Thelia\Model\Country $object
*/
protected function hydrateObjectForm($object)
{
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'isocode' => $object->getIsocode(),
'isoalpha2' => $object->getIsoalpha2(),
'isoalpha3' => $object->getIsoalpha3(),
);
return new CountryModificationForm($this->getRequest(), 'form', $data);
}
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected function getCreationEvent($formData)
{
$event = new CountryCreateEvent();
return $this->hydrateEvent($event, $formData);
}
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected function getUpdateEvent($formData)
{
$event = new CountryUpdateEvent();
return $this->hydrateEvent($event, $formData);
}
protected function hydrateEvent($event, $formData)
{
$event
->setLocale($formData['locale'])
->setTitle($formData['title'])
->setIsocode($formData['isocode'])
->setIsoAlpha2($formData['isoalpha2'])
->setIsoAlpha3($formData['isoalpha3'])
->setArea($formData['area'])
;
return $event;
}
/**
* Creates the delete event with the provided form data
*/
protected function getDeleteEvent()
{
return new CountryDeleteEvent($this->getRequest()->get('country_id'));
}
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected function eventContainsObject($event)
{
return $event->hasCountry();
}
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected function getObjectFromEvent($event)
{
return $event->getCountry();
}
/**
* Load an existing object from the database
*/
protected function getExistingObject()
{
return CountryQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findPk($this->getRequest()->get('country_id', 0));
}
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param \Thelia\Model\Country $object
*/
protected function getObjectLabel($object)
{
return $object->getTitle();
}
/**
* Returns the object ID from the object
*
* @param \Thelia\Model\Country $object
*/
protected function getObjectId($object)
{
return $object->getId();
}
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected function renderListTemplate($currentOrder)
{
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
* Render the edition template
*/
public function updateAction($country_id)
{
return $this->render("country-edit", array(
"country_id" => $country_id
));
protected function renderEditionTemplate()
{
return $this->render('country-edit', $this->getEditionArgument());
}
}
protected function getEditionArgument()
{
return array(
'country_id' => $this->getRequest()->get('country_id', 0)
);
}
/**
* Redirect to the edition template
*/
protected function redirectToEditionTemplate()
{
$this->redirectToRoute('admin.configuration.countries.update', array(), $this->getRequest()->get('country_id', 0));
}
/**
* Redirect to the list template
*/
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.countries.default');
}
public function toggleDefaultAction()
{
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$content = null;
if (null !== $country_id = $this->getRequest()->get('country_id')) {
$toogleDefaultEvent = new CountryToggleDefaultEvent($country_id);
try {
$this->dispatch(TheliaEvents::COUNTRY_TOGGLE_DEFAULT, $toogleDefaultEvent);
if($toogleDefaultEvent->hasCountry()) {
return $this->nullResponse();
}
} catch (\Exception $ex) {
$content = $ex->getMessage();
}
}
return $this->nullResponse($content, 500);
}
}

View File

@@ -30,7 +30,6 @@ use Thelia\Condition\ConditionManagerInterface;
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponManager;
use Thelia\Coupon\ConditionCollection;
use Thelia\Coupon\Type\CouponInterface;
@@ -295,7 +294,6 @@ class CouponController extends BaseAdminController
);
}
/**
* Manage Coupons read display
*
@@ -622,6 +620,4 @@ class CouponController extends BaseAdminController
// }
// }
}

View File

@@ -23,10 +23,10 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\CurrencyDeleteEvent;
use Thelia\Core\Event\Currency\CurrencyDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CurrencyUpdateEvent;
use Thelia\Core\Event\CurrencyCreateEvent;
use Thelia\Core\Event\Currency\CurrencyUpdateEvent;
use Thelia\Core\Event\Currency\CurrencyCreateEvent;
use Thelia\Model\CurrencyQuery;
use Thelia\Form\CurrencyModificationForm;
use Thelia\Form\CurrencyCreationForm;
@@ -39,7 +39,8 @@ use Thelia\Core\Event\UpdatePositionEvent;
*/
class CurrencyController extends AbstractCrudController
{
public function __construct() {
public function __construct()
{
parent::__construct(
'currency',
'manual',
@@ -58,15 +59,18 @@ class CurrencyController extends AbstractCrudController
);
}
protected function getCreationForm() {
protected function getCreationForm()
{
return new CurrencyCreationForm($this->getRequest());
}
protected function getUpdateForm() {
protected function getUpdateForm()
{
return new CurrencyModificationForm($this->getRequest());
}
protected function getCreationEvent($formData) {
protected function getCreationEvent($formData)
{
$createEvent = new CurrencyCreateEvent();
$createEvent
@@ -80,7 +84,8 @@ class CurrencyController extends AbstractCrudController
return $createEvent;
}
protected function getUpdateEvent($formData) {
protected function getUpdateEvent($formData)
{
$changeEvent = new CurrencyUpdateEvent($formData['id']);
// Create and dispatch the change event
@@ -95,8 +100,8 @@ class CurrencyController extends AbstractCrudController
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('currency_id', null),
$positionChangeMode,
@@ -104,16 +109,18 @@ class CurrencyController extends AbstractCrudController
);
}
protected function getDeleteEvent() {
protected function getDeleteEvent()
{
return new CurrencyDeleteEvent($this->getRequest()->get('currency_id'));
}
protected function eventContainsObject($event) {
protected function eventContainsObject($event)
{
return $event->hasCurrency();
}
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -128,44 +135,51 @@ class CurrencyController extends AbstractCrudController
return new CurrencyModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
protected function getObjectFromEvent($event)
{
return $event->hasCurrency() ? $event->getCurrency() : null;
}
protected function getExistingObject() {
protected function getExistingObject()
{
return CurrencyQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('currency_id'));
}
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getName();
}
protected function getObjectId($object) {
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
return $this->render('currencies', array('order' => $currentOrder));
}
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id')));
}
protected function redirectToEditionTemplate() {
protected function redirectToEditionTemplate()
{
$this->redirectToRoute(
"admin.configuration.currencies.update",
array('currency_id' => $this->getRequest()->get('currency_id'))
);
}
protected function redirectToListTemplate() {
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Update currencies rates
*/

View File

@@ -22,13 +22,17 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Form\Form;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\Customer\CustomerAddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
@@ -48,12 +52,13 @@ class CustomerController extends BaseAdminController
public function viewAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
/**
* update customer action
*
@@ -71,8 +76,8 @@ class CustomerController extends BaseAdminController
try {
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
throw new \InvalidArgumentException(sprintf("%d customer id does not exists", $customer_id));
if (null === $customer) {
throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id));
}
$form = $this->validateForm($customerModification);
@@ -86,7 +91,7 @@ class CustomerController extends BaseAdminController
$this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId()));
if($this->getRequest()->get("save_mode") == "close") {
if ($this->getRequest()->get("save_mode") == "close") {
$this->redirectToRoute("admin.customers");
} else {
$this->redirectSuccess($customerModification);
@@ -126,14 +131,14 @@ class CustomerController extends BaseAdminController
$customer_id = $this->getRequest()->get("customer_id");
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exists"));
if (null === $customer) {
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist"));
}
$event = new CustomerEvent($customer);
$this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event);
} catch(\Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
}
@@ -151,7 +156,7 @@ class CustomerController extends BaseAdminController
/**
* @param $data
* @return CustomerCreateOrUpdateEvent
* @return \Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent
*/
private function createEventInstance($data)
{
@@ -178,4 +183,4 @@ class CustomerController extends BaseAdminController
return $customerCreateEvent;
}
}
}

View File

@@ -23,10 +23,10 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\FeatureAvDeleteEvent;
use Thelia\Core\Event\Feature\FeatureAvDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\FeatureAvUpdateEvent;
use Thelia\Core\Event\FeatureAvCreateEvent;
use Thelia\Core\Event\Feature\FeatureAvUpdateEvent;
use Thelia\Core\Event\Feature\FeatureAvCreateEvent;
use Thelia\Model\FeatureAvQuery;
use Thelia\Form\FeatureAvModificationForm;
use Thelia\Form\FeatureAvCreationForm;
@@ -193,4 +193,4 @@ class FeatureAvController extends AbstractCrudController
$this->getViewArguments()
);
}
}
}

View File

@@ -23,18 +23,18 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\FeatureDeleteEvent;
use Thelia\Core\Event\Feature\FeatureDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\FeatureUpdateEvent;
use Thelia\Core\Event\FeatureCreateEvent;
use Thelia\Core\Event\Feature\FeatureUpdateEvent;
use Thelia\Core\Event\Feature\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;
use Thelia\Core\Event\Feature\FeatureAvUpdateEvent;
use Thelia\Core\Event\Feature\FeatureEvent;
/**
* Manages features
@@ -113,7 +113,7 @@ class FeatureController extends AbstractCrudController
if ($attr_values !== null) {
foreach($attr_values as $id => $value) {
foreach ($attr_values as $id => $value) {
$event = new FeatureAvUpdateEvent($id);
@@ -168,7 +168,7 @@ class FeatureController extends AbstractCrudController
$attr_array = array();
foreach($attr_av_list as $attr_av) {
foreach ($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
}
@@ -262,8 +262,7 @@ class FeatureController extends AbstractCrudController
$this->dispatch($eventType, $event);
}
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -286,4 +285,4 @@ class FeatureController extends AbstractCrudController
{
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES);
}
}
}

View File

@@ -25,15 +25,12 @@ namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\DocumentDeleteEvent;
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\ImageDeleteEvent;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryDocument;
@@ -62,7 +59,6 @@ use Thelia\Tools\Rest\ResponseRest;
class FileController extends BaseAdminController
{
/**
* Manage how a image collection has to be saved
*
@@ -126,14 +122,12 @@ class FileController extends BaseAdminController
$imageCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
$imageCreateOrUpdateEvent->setParentName($parentModel->getTitle());
// Dispatch Event to the Action
$this->dispatch(
TheliaEvents::IMAGE_SAVE,
$imageCreateOrUpdateEvent
);
return new ResponseRest(array('status' => true, 'message' => ''));
}
}
@@ -192,14 +186,12 @@ class FileController extends BaseAdminController
$documentCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
$documentCreateOrUpdateEvent->setParentName($parentModel->getTitle());
// Dispatch Event to the Action
$this->dispatch(
TheliaEvents::DOCUMENT_SAVE,
$documentCreateOrUpdateEvent
);
return new ResponseRest(array('status' => true, 'message' => ''));
}
}
@@ -676,5 +668,4 @@ class FileController extends BaseAdminController
return $documentCreateEvent;
}
}

View File

@@ -22,10 +22,10 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\FolderCreateEvent;
use Thelia\Core\Event\FolderDeleteEvent;
use Thelia\Core\Event\FolderToggleVisibilityEvent;
use Thelia\Core\Event\FolderUpdateEvent;
use Thelia\Core\Event\Folder\FolderCreateEvent;
use Thelia\Core\Event\Folder\FolderDeleteEvent;
use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent;
use Thelia\Core\Event\Folder\FolderUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Form\FolderCreationForm;
@@ -81,8 +81,8 @@ class FolderController extends AbstractCrudController
*
* @param \Thelia\Model\Folder $object
*/
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -150,7 +150,7 @@ class FolderController extends AbstractCrudController
}
/**
* @return FolderToggleVisibilityEvent|void
* @return \Thelia\Core\Event\Folder\FolderToggleVisibilityEvent|void
*/
protected function createToggleVisibilityEvent()
{
@@ -162,8 +162,8 @@ class FolderController extends AbstractCrudController
* @param $positionValue
* @return UpdatePositionEvent|void
*/
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('folder_id', null),
$positionChangeMode,
@@ -174,7 +174,7 @@ class FolderController extends AbstractCrudController
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param \Thelia\Core\Event\FolderEvent $event
* @param \Thelia\Core\Event\Folder\FolderEvent $event
*/
protected function eventContainsObject($event)
{
@@ -184,7 +184,7 @@ class FolderController extends AbstractCrudController
/**
* Get the created object from an event.
*
* @param $event \Thelia\Core\Event\FolderEvent $event
* @param $event \Thelia\Core\Event\Folder\FolderEvent $event
*
* @return null|\Thelia\Model\Folder
*/
@@ -196,7 +196,8 @@ class FolderController extends AbstractCrudController
/**
* Load an existing object from the database
*/
protected function getExistingObject() {
protected function getExistingObject()
{
return FolderQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('folder_id', 0));
@@ -207,7 +208,8 @@ class FolderController extends AbstractCrudController
*
* @param unknown $object
*/
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getTitle();
}
@@ -226,8 +228,8 @@ class FolderController extends AbstractCrudController
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
// Get content order
$content_order = $this->getListOrderFromSession('content', 'content_order', 'manual');
@@ -239,12 +241,11 @@ class FolderController extends AbstractCrudController
));
}
/**
* Render the edition template
*/
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('folder-edit', $this->getEditionArguments());
}
@@ -257,7 +258,7 @@ class FolderController extends AbstractCrudController
}
/**
* @param \Thelia\Core\Event\FolderUpdateEvent $updateEvent
* @param \Thelia\Core\Event\Folder\FolderUpdateEvent $updateEvent
* @return Response|void
*/
protected function performAdditionalUpdateAction($updateEvent)
@@ -275,8 +276,8 @@ class FolderController extends AbstractCrudController
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\FolderDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
* @param \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
@@ -325,4 +326,4 @@ class FolderController extends AbstractCrudController
array('parent' => $this->getRequest()->get('parent', 0))
);
}
}
}

View File

@@ -23,9 +23,9 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\MessageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\MessageCreateEvent;
use Thelia\Core\Event\Message\MessageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\Message\MessageUpdateEvent;
use Thelia\Core\Event\Message\MessageCreateEvent;
use Thelia\Model\MessageQuery;
use Thelia\Form\MessageModificationForm;
use Thelia\Form\MessageCreationForm;

View File

@@ -35,12 +35,11 @@ class ModuleController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
return $this->render("modules", array("display_module" => 20));
}
public function updateAction($module_id)
{
return $this->render("module-edit", array(
"module_id" => $module_id
));
return $this->render("module-edit", array(
"module_id" => $module_id
));
}
}
}

View File

@@ -23,6 +23,18 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\OrderUpdateAddress;
use Thelia\Model\ConfigQuery;
use Thelia\Model\Base\OrderAddressQuery;
use Thelia\Model\OrderQuery;
use Thelia\Model\OrderStatusQuery;
use Thelia\Tools\URL;
/**
* Class OrderController
* @package Thelia\Controller\Admin
@@ -38,10 +50,198 @@ class OrderController extends BaseAdminController
public function viewAction($order_id)
{
return $this->render("order-edit", array(
"order_id" => $order_id
));
return $this->render("order-edit", array(
"order_id" => $order_id
));
}
}
public function updateStatus($order_id = null)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
$message = null;
try {
if ($order_id !== null) {
$order_id = $order_id;
} else {
$order_id = $this->getRequest()->get("order_id");
}
$order = OrderQuery::create()->findPk($order_id);
$statusId = $this->getRequest()->request->get("status_id");
$status = OrderStatusQuery::create()->findPk($statusId);
if (null === $order) {
throw new \InvalidArgumentException("The order you want to update status does not exist");
}
if (null === $status) {
throw new \InvalidArgumentException("The status you want to set to the order does not exist");
}
$event = new OrderEvent($order);
$event->setStatus($statusId);
$this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
} catch (\Exception $e) {
$message = $e->getMessage();
}
$params = array();
if ($message) {
$params["update_status_error_message"] = $message;
}
$browsedPage = $this->getRequest()->get("order_page");
if ($browsedPage) {
$params["order_page"] = $browsedPage;
$this->redirectToRoute("admin.order.list", $params);
} else {
$params["order_id"] = $order_id;
$params["tab"] = $this->getRequest()->get("tab", 'cart');
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
}
}
public function updateDeliveryRef($order_id)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
$message = null;
try {
$order = OrderQuery::create()->findPk($order_id);
$deliveryRef = $this->getRequest()->get("delivery_ref");
if (null === $order) {
throw new \InvalidArgumentException("The order you want to update status does not exist");
}
$event = new OrderEvent($order);
$event->setDeliveryRef($deliveryRef);
$this->dispatch(TheliaEvents::ORDER_UPDATE_DELIVERY_REF, $event);
} catch (\Exception $e) {
$message = $e->getMessage();
}
$params = array();
if ($message) {
$params["update_status_error_message"] = $message;
}
$params["order_id"] = $order_id;
$params["tab"] = $this->getRequest()->get("tab", 'bill');
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
}
public function updateAddress($order_id)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
$message = null;
$orderUpdateAddress = new OrderUpdateAddress($this->getRequest());
try {
$order = OrderQuery::create()->findPk($order_id);
if (null === $order) {
throw new \InvalidArgumentException("The order you want to update does not exist");
}
$form = $this->validateForm($orderUpdateAddress, "post");
$orderAddress = OrderAddressQuery::create()->findPk($form->get("id")->getData());
if ($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) {
throw new \InvalidArgumentException("The order address you want to update does not belong to the current order not exist");
}
$event = new OrderAddressEvent(
$form->get("title")->getData(),
$form->get("firstname")->getData(),
$form->get("lastname")->getData(),
$form->get("address1")->getData(),
$form->get("address2")->getData(),
$form->get("address3")->getData(),
$form->get("zipcode")->getData(),
$form->get("city")->getData(),
$form->get("country")->getData(),
$form->get("phone")->getData(),
$form->get("company")->getData()
);
$event->setOrderAddress($orderAddress);
$event->setOrder($order);
$this->dispatch(TheliaEvents::ORDER_UPDATE_ADDRESS, $event);
} catch (\Exception $e) {
$message = $e->getMessage();
}
$params = array();
if ($message) {
$params["update_status_error_message"] = $message;
}
$params["order_id"] = $order_id;
$params["tab"] = $this->getRequest()->get("tab", 'bill');
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
}
public function generateInvoicePdf($order_id)
{
return $this->generatePdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice'));
}
public function generateDeliveryPdf($order_id)
{
return $this->generatePdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery'));
}
protected function generatePdf($order_id, $fileName)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
$html = $this->renderRaw(
$fileName,
array(
'order_id' => $order_id
),
ConfigQuery::read('pdf_template', 'pdf')
);
$order = OrderQuery::create()->findPk($order_id);
try {
$pdfEvent = new PdfEvent($html);
$this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent);
if($pdfEvent->hasPdf()) {
return Response::create($pdfEvent->getPdf(), 200,
array(
'Content-type' => "application/pdf",
'Content-Disposition' => sprintf('Attachment;filename=%s.pdf', $order->getRef()),
));
}
} catch (\Exception $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf('error during generating invoice pdf for order id : %d with message "%s"', $order_id, $e->getMessage()));
}
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", array(
'order_id' => $order_id
))));
}
}

View File

@@ -23,40 +23,29 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\ProductDeleteEvent;
use Thelia\Core\Event\Product\ProductAddCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\ProductUpdateEvent;
use Thelia\Core\Event\ProductCreateEvent;
use Thelia\Core\Event\Product\ProductUpdateEvent;
use Thelia\Core\Event\Product\ProductCreateEvent;
use Thelia\Model\ProductQuery;
use Thelia\Form\ProductModificationForm;
use Thelia\Form\ProductCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ProductToggleVisibilityEvent;
use Thelia\Core\Event\ProductDeleteContentEvent;
use Thelia\Core\Event\ProductAddContentEvent;
use Thelia\Model\ProductAssociatedContent;
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
use Thelia\Core\Event\Product\ProductDeleteContentEvent;
use Thelia\Core\Event\Product\ProductAddContentEvent;
use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\ProductAssociatedContentQuery;
use Thelia\Model\AccessoryQuery;
use Thelia\Model\CategoryQuery;
use Thelia\Core\Event\ProductAddAccessoryEvent;
use Thelia\Core\Event\ProductDeleteAccessoryEvent;
use Thelia\Core\Event\FeatureProductUpdateEvent;
use Thelia\Model\FeatureQuery;
use Thelia\Core\Event\FeatureProductDeleteEvent;
use Thelia\Model\FeatureTemplateQuery;
use Thelia\Core\Event\ProductSetTemplateEvent;
use Thelia\Core\Event\ProductAddCategoryEvent;
use Thelia\Core\Event\ProductDeleteCategoryEvent;
use Thelia\Model\AttributeQuery;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\Product\ProductAddAccessoryEvent;
use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent;
use Thelia\Model\ProductSaleElementsQuery;
use Thelia\Model\AttributeCombination;
use Thelia\Model\AttributeAv;
use Thelia\Core\Event\ProductCreateCombinationEvent;
use Thelia\Core\Event\ProductDeleteCombinationEvent;
/**
* Manages products
@@ -89,8 +78,8 @@ class ProductController extends AbstractCrudController
/**
* Attributes ajax tab loading
*/
public function loadAttributesAjaxTabAction() {
public function loadAttributesAjaxTabAction()
{
return $this->render(
'ajax/product-attributes-tab',
array(
@@ -102,8 +91,8 @@ class ProductController extends AbstractCrudController
/**
* Related information ajax tab loading
*/
public function loadRelatedAjaxTabAction() {
public function loadRelatedAjaxTabAction()
{
return $this->render(
'ajax/product-related-tab',
array(
@@ -242,7 +231,8 @@ class ProductController extends AbstractCrudController
);
}
protected function getCategoryId() {
protected function getCategoryId()
{
// Trouver le category_id, soit depuis la reques, souit depuis le produit courant
$category_id = $this->getRequest()->get('category_id', null);
@@ -353,7 +343,7 @@ class ProductController extends AbstractCrudController
;
if ($list !== null) {
foreach($list as $item) {
foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
}
}
@@ -379,8 +369,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -406,8 +395,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -416,7 +404,6 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
// -- Accessories management ----------------------------------------------
public function getAvailableAccessoriesAction($productId, $categoryId)
@@ -435,7 +422,7 @@ class ProductController extends AbstractCrudController
;
if ($list !== null) {
foreach($list as $item) {
foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
}
}
@@ -460,8 +447,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -486,8 +472,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -527,7 +512,8 @@ class ProductController extends AbstractCrudController
*
* @param unknown $productId
*/
public function setProductTemplateAction($productId) {
public function setProductTemplateAction($productId)
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
@@ -549,8 +535,8 @@ class ProductController extends AbstractCrudController
/**
* Update product attributes and features
*/
public function updateAttributesAndFeaturesAction($productId) {
public function updateAttributesAndFeaturesAction($productId)
{
$product = ProductQuery::create()->findPk($productId);
if ($product != null) {
@@ -569,7 +555,7 @@ class ProductController extends AbstractCrudController
// Update all features values, starting with feature av. values
$featureValues = $this->getRequest()->get('feature_value', array());
foreach($featureValues as $featureId => $featureValueList) {
foreach ($featureValues as $featureId => $featureValueList) {
// Delete all features av. for this feature.
$event = new FeatureProductDeleteEvent($productId, $featureId);
@@ -577,7 +563,7 @@ class ProductController extends AbstractCrudController
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);
// Add then all selected values
foreach($featureValueList as $featureValue) {
foreach ($featureValueList as $featureValue) {
$event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue);
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event);
@@ -589,7 +575,7 @@ class ProductController extends AbstractCrudController
// Update then features text values
$featureTextValues = $this->getRequest()->get('feature_text_value', array());
foreach($featureTextValues as $featureId => $featureValue) {
foreach ($featureTextValues as $featureId => $featureValue) {
// considere empty text as empty feature value (e.g., we will delete it)
if (empty($featureValue)) continue;
@@ -602,7 +588,7 @@ class ProductController extends AbstractCrudController
}
// Delete features which don't have any values
foreach($allFeatures as $feature) {
foreach ($allFeatures as $feature) {
if (! in_array($feature->getId(), $updatedFeatures)) {
$event = new FeatureProductDeleteEvent($productId, $feature->getId());
@@ -623,12 +609,12 @@ class ProductController extends AbstractCrudController
$this->redirectToListTemplate();
}
public function addAdditionalCategoryAction() {
public function addAdditionalCategoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
$category_id = intval($this->getRequest()->get('additional_category_id'));
$category_id = intval($this->getRequest()->request->get('additional_category_id'));
if ($category_id > 0) {
@@ -639,8 +625,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_CATEGORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -649,8 +634,8 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteAdditionalCategoryAction() {
public function deleteAdditionalCategoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -665,8 +650,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CATEGORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -677,8 +661,8 @@ class ProductController extends AbstractCrudController
// -- Product combination management ---------------------------------------
public function getAttributeValuesAction($productId, $attributeId) {
public function getAttributeValuesAction($productId, $attributeId)
{
$result = array();
// Get attribute for this product
@@ -693,7 +677,7 @@ class ProductController extends AbstractCrudController
;
if ($values !== null) {
foreach($values as $value) {
foreach ($values as $value) {
$result[] = array('id' => $value->getId(), 'title' => $value->getTitle());
}
}
@@ -702,8 +686,8 @@ class ProductController extends AbstractCrudController
return $this->jsonResponse(json_encode($result));
}
public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination) {
public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination)
{
$result = array();
// Get attribute for this product
@@ -747,8 +731,8 @@ class ProductController extends AbstractCrudController
/**
* A a new combination to a product
*/
public function addCombinationAction() {
public function addCombinationAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -760,8 +744,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_COMBINATION, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -773,8 +756,8 @@ class ProductController extends AbstractCrudController
/**
* A a new combination to a product
*/
public function deleteCombinationAction() {
public function deleteCombinationAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -785,8 +768,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_DELETE_COMBINATION, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}

View File

@@ -31,9 +31,7 @@ use Thelia\Tools\URL;
use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Core\Security\UserProvider\TokenProvider;
use Symfony\Component\HttpFoundation\Cookie;
use Thelia\Core\Security\UserProvider\CookieTokenProvider;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class SessionController extends BaseAdminController
@@ -59,8 +57,7 @@ class SessionController extends BaseAdminController
// Render the home page
return $this->render("home");
}
catch (TokenAuthenticationException $ex) {
} catch (TokenAuthenticationException $ex) {
$this->adminLogAppend("Token based authentication failed.");
// Clear the cookie

View File

@@ -35,12 +35,11 @@ class ShippingConfigurationController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
}
public function updateAction($shipping_configuration_id)
{
return $this->render("shipping-configuration-edit", array(
"shipping_configuration_id" => $shipping_configuration_id
));
}
}
}

View File

@@ -35,12 +35,11 @@ class ShippingZoneController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
return $this->render("shipping-zones", array("display_shipping_zone" => 20));
}
public function updateAction($shipping_zones_id)
{
return $this->render("shipping-zones-edit", array(
"shipping_zones_id" => $shipping_zones_id
));
return $this->render("shipping-zones-edit", array(
"shipping_zones_id" => $shipping_zones_id
));
}
}
}

View File

@@ -23,22 +23,17 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\TemplateDeleteEvent;
use Thelia\Core\Event\Template\TemplateDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\TemplateUpdateEvent;
use Thelia\Core\Event\TemplateCreateEvent;
use Thelia\Core\Event\Template\TemplateUpdateEvent;
use Thelia\Core\Event\Template\TemplateCreateEvent;
use Thelia\Model\TemplateQuery;
use Thelia\Form\TemplateModificationForm;
use Thelia\Form\TemplateCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
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;
use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent;
use Thelia\Core\Event\Template\TemplateAddAttributeEvent;
use Thelia\Core\Event\Template\TemplateAddFeatureEvent;
use Thelia\Core\Event\Template\TemplateDeleteFeatureEvent;
use Thelia\Model\FeatureTemplateQuery;
use Thelia\Model\AttributeTemplateQuery;
@@ -102,7 +97,6 @@ class TemplateController extends AbstractCrudController
;
// Add feature and attributes list
return $changeEvent;
}
@@ -199,22 +193,24 @@ class TemplateController extends AbstractCrudController
return null;
}
public function getAjaxFeaturesAction() {
public function getAjaxFeaturesAction()
{
return $this->render(
'ajax/template-feature-list',
array('template_id' => $this->getRequest()->get('template_id'))
);
}
public function getAjaxAttributesAction() {
public function getAjaxAttributesAction()
{
return $this->render(
'ajax/template-attribute-list',
array('template_id' => $this->getRequest()->get('template_id'))
);
}
public function addAttributeAction() {
public function addAttributeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
@@ -237,8 +233,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteAttributeAction() {
public function deleteAttributeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
@@ -257,8 +253,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function updateAttributePositionAction() {
public function updateAttributePositionAction()
{
// Find attribute_template
$attributeTemplate = AttributeTemplateQuery::create()
->filterByTemplateId($this->getRequest()->get('template_id', null))
@@ -272,8 +268,8 @@ class TemplateController extends AbstractCrudController
);
}
public function addFeatureAction() {
public function addFeatureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
@@ -296,8 +292,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteFeatureAction() {
public function deleteFeatureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
@@ -316,8 +312,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function updateFeaturePositionAction() {
public function updateFeaturePositionAction()
{
// Find feature_template
$featureTemplate = FeatureTemplateQuery::create()
->filterByTemplateId($this->getRequest()->get('template_id', null))
@@ -330,4 +326,4 @@ class TemplateController extends AbstractCrudController
TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION
);
}
}
}

View File

@@ -58,9 +58,9 @@ class BaseController extends ContainerAware
/**
* Return an empty response (after an ajax request, for example)
*/
protected function nullResponse()
protected function nullResponse($status = 200)
{
return new Response();
return new Response(null, $status);
}
/**
@@ -286,7 +286,7 @@ class BaseController extends ContainerAware
*/
protected function checkXmlHttpRequest()
{
if(false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) {
if (false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) {
$this->accessDenied();
}
}
@@ -300,6 +300,7 @@ class BaseController extends ContainerAware
public function getMailer()
{
$mailer = $this->container->get('mailer');
return $mailer->getSwiftMailer();
}
}

View File

@@ -22,15 +22,14 @@
/*************************************************************************************/
namespace Thelia\Controller\Front;
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\AddressCreateForm;
use Thelia\Form\AddressUpdateForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AddressQuery;
use Thelia\Model\Customer;
use Thelia\Tools\URL;
/**
* Class AddressController
@@ -51,10 +50,8 @@ class AddressController extends BaseFrontController
$this->checkAuth();
$this->checkXmlHttpRequest();
}
/**
* Create controller.
* Check if customer is logged in
@@ -103,7 +100,7 @@ class AddressController extends BaseFrontController
$customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) {
if (!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
}
@@ -117,7 +114,6 @@ class AddressController extends BaseFrontController
$addressUpdate = new AddressUpdateForm($request);
try {
$customer = $this->getSecurityContext()->getCustomerUser();
@@ -164,7 +160,7 @@ class AddressController extends BaseFrontController
$customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) {
if (!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
}

View File

@@ -55,7 +55,7 @@ class BaseFrontController extends BaseController
public function checkAuth()
{
if($this->getSecurityContext()->hasCustomerUser() === false) {
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirectToRoute("customer.login.view");
}
}
@@ -63,7 +63,7 @@ class BaseFrontController extends BaseController
protected function checkCartNotEmpty()
{
$cart = $this->getSession()->getCart();
if($cart===null || $cart->countCartItems() == 0) {
if ($cart===null || $cart->countCartItems() == 0) {
$this->redirectToRoute("cart.view");
}
}
@@ -71,7 +71,7 @@ class BaseFrontController extends BaseController
protected function checkValidDelivery()
{
$order = $this->getSession()->getOrder();
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
if (null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
$this->redirectToRoute("order.delivery");
}
}
@@ -79,7 +79,7 @@ class BaseFrontController extends BaseController
protected function checkValidInvoice()
{
$order = $this->getSession()->getOrder();
if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
if (null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
$this->redirectToRoute("order.invoice");
}
}

View File

@@ -24,7 +24,7 @@ namespace Thelia\Controller\Front;
use Propel\Runtime\Exception\PropelException;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Event\CartEvent;
use Thelia\Core\Event\Cart\CartEvent;
use Thelia\Core\Event\TheliaEvents;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Form\CartAdd;
@@ -102,7 +102,7 @@ class CartController extends BaseFrontController
/**
* use Thelia\Cart\CartTrait for searching current cart or create a new one
*
* @return CartEvent
* @return \Thelia\Core\Event\Cart\CartEvent
*/
protected function getCartEvent()
{

View File

@@ -22,8 +22,8 @@
/*************************************************************************************/
namespace Thelia\Controller\Front;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerLoginEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerLoginEvent;
use Thelia\Core\Event\LostPasswordEvent;
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
use Thelia\Core\Security\Exception\AuthenticationException;
@@ -104,7 +104,7 @@ class CustomerController extends BaseFrontController
$this->processLogin($customerCreateEvent->getCustomer());
$cart = $this->getCart($this->getRequest());
if($cart->getCartItems()->count() > 0) {
if ($cart->getCartItems()->count() > 0) {
$this->redirectToRoute("cart.view");
} else {
$this->redirectSuccess($customerCreation);
@@ -257,7 +257,7 @@ class CustomerController extends BaseFrontController
/**
* @param $data
* @return CustomerCreateOrUpdateEvent
* @return \Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent
*/
private function createEventInstance($data)
{

View File

@@ -25,7 +25,7 @@ namespace Thelia\Controller\Front;
use Propel\Runtime\Exception\PropelException;
use Thelia\Exception\TheliaProcessException;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Event\OrderEvent;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Form\OrderDelivery;
@@ -34,7 +34,6 @@ use Thelia\Log\Tlog;
use Thelia\Model\AddressQuery;
use Thelia\Model\AreaDeliveryModuleQuery;
use Thelia\Model\Base\OrderQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\ModuleQuery;
use Thelia\Model\Order;
use Thelia\Tools\URL;
@@ -69,7 +68,7 @@ class OrderController extends BaseFrontController
/* check that the delivery address belongs to the current customer */
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
if ($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
throw new \Exception("Delivery address does not belong to the current customer");
}
@@ -139,7 +138,7 @@ class OrderController extends BaseFrontController
/* check that the invoice address belongs to the current customer */
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
if ($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
throw new \Exception("Invoice address does not belong to the current customer");
}
@@ -193,7 +192,7 @@ class OrderController extends BaseFrontController
$placedOrder = $orderEvent->getPlacedOrder();
if(null !== $placedOrder && null !== $placedOrder->getId()) {
if (null !== $placedOrder && null !== $placedOrder->getId()) {
/* order has been placed */
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
} else {
@@ -209,13 +208,13 @@ class OrderController extends BaseFrontController
$this->getRequest()->attributes->get('order_id')
);
if(null === $placedOrder) {
if (null === $placedOrder) {
throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder);
}
$customer = $this->getSecurityContext()->getCustomerUser();
if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
if (null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder);
}

View File

@@ -84,7 +84,7 @@ class RegisterRouterPass implements CompilerPassInterface
$container->setDefinition("router.".$moduleCode, $definition);
$chainRouter->addMethodCall("add", array(new Reference("router.".$moduleCode), 1));
$chainRouter->addMethodCall("add", array(new Reference("router.".$moduleCode), 150));
}
}
}

View File

@@ -21,8 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Address;
use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Address;
use Thelia\Model\Customer;
@@ -243,8 +244,6 @@ class AddressCreateOrUpdateEvent extends ActionEvent
return $this->isDefault;
}
/**
* @param \Thelia\Model\Customer $customer
*/

View File

@@ -21,8 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Address;
use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Address;
/**

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\Attribute\AttributeAvEvent;
class AttributeAvCreateEvent extends AttributeAvEvent
{

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\Attribute\AttributeAvEvent;
class AttributeAvDeleteEvent extends AttributeAvEvent
{

View File

@@ -21,7 +21,8 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\AttributeAv;
class AttributeAvEvent extends ActionEvent

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\Attribute\AttributeAvCreateEvent;
class AttributeAvUpdateEvent extends AttributeAvCreateEvent
{

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\Attribute\AttributeEvent;
class AttributeCreateEvent extends AttributeEvent
{

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\Attribute\AttributeEvent;
class AttributeDeleteEvent extends AttributeEvent
{

View File

@@ -21,7 +21,8 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Attribute;
class AttributeEvent extends ActionEvent

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Attribute;
use Thelia\Core\Event\Attribute\AttributeCreateEvent;
class AttributeUpdateEvent extends AttributeCreateEvent
{

View File

@@ -21,9 +21,10 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Cart;
use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Cart;
class CartEvent extends ActionEvent

View File

@@ -21,8 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Cart;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\CartItem;
class CartItemEvent extends ActionEvent

View File

@@ -21,8 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Model\Category;
class CategoryAddContentEvent extends CategoryEvent

View File

@@ -21,7 +21,7 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Model\CategoryAssociatedContent;
use Thelia\Core\Event\ActionEvent;

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Core\Event\Category\CategoryEvent;
class CategoryCreateEvent extends CategoryEvent
{

View File

@@ -21,8 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Model\Category;
class CategoryDeleteContentEvent extends CategoryEvent

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Core\Event\Category\CategoryEvent;
class CategoryDeleteEvent extends CategoryEvent
{

View File

@@ -21,7 +21,7 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Model\Category;
use Thelia\Core\Event\ActionEvent;

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Core\Event\Category\CategoryEvent;
class CategoryToggleVisibilityEvent extends CategoryEvent
{

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Category;
use Thelia\Core\Event\Category\CategoryCreateEvent;
class CategoryUpdateEvent extends CategoryCreateEvent
{

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Config;
use Thelia\Core\Event\Config\ConfigEvent;
class ConfigCreateEvent extends ConfigEvent
{

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Config;
use Thelia\Core\Event\Config\ConfigEvent;
class ConfigDeleteEvent extends ConfigEvent
{

View File

@@ -21,7 +21,8 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Config;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Config;
class ConfigEvent extends ActionEvent

View File

@@ -21,7 +21,9 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Event\Config;
use Thelia\Core\Event\Config\ConfigCreateEvent;
class ConfigUpdateEvent extends ConfigCreateEvent
{

View 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\Core\Event\Content;
use Thelia\Model\Content;
/**
* Class ContentAddFolderEvent
* @package Thelia\Core\Event\Content
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ContentAddFolderEvent extends ContentEvent
{
/**
* @var int folder id
*/
protected $folderId;
public function __construct(Content $content, $folderId)
{
$this->folderId = $folderId;
parent::__construct($content);
}
/**
* @param int $folderId
*/
public function setFolderId($folderId)
{
$this->folderId = $folderId;
}
/**
* @return int
*/
public function getFolderId()
{
return $this->folderId;
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content;
/**
* Class ContentCreateEvent
* @package Thelia\Core\Event\Content
@@ -76,9 +75,6 @@ class ContentCreateEvent extends ContentEvent
return $this->default_folder;
}
/**
* @param mixed $visible
*
@@ -119,6 +115,4 @@ class ContentCreateEvent extends ContentEvent
return $this->title;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content;
/**
* Class ContentDeleteEvent
* @package Thelia\Core\Event\Content
@@ -35,7 +34,7 @@ class ContentDeleteEvent extends ContentEvent
protected $folder_id;
function __construct($content_id)
public function __construct($content_id)
{
$this->content_id = $content_id;
}
@@ -70,5 +69,4 @@ class ContentDeleteEvent extends ContentEvent
return $this->folder_id;
}
}
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Content;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Content;
/**
* Class ContentEvent
* @package Thelia\Core\Event\Content
@@ -38,7 +37,7 @@ class ContentEvent extends ActionEvent
*/
protected $content;
function __construct(Content $content = null)
public function __construct(Content $content = null)
{
$this->content = $content;
}
@@ -70,4 +69,4 @@ class ContentEvent extends ActionEvent
{
return null !== $this->content;
}
}
}

View File

@@ -0,0 +1,34 @@
<?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\Content;
/**
* Class ContentRemoveFolderEvent
* @package Thelia\Core\Event\Content
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ContentRemoveFolderEvent extends ContentAddFolderEvent
{
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content;
/**
* Class ContentToggleVisibilityEvent
* @package Thelia\Core\Event\Content
@@ -32,4 +31,4 @@ namespace Thelia\Core\Event\Content;
class ContentToggleVisibilityEvent extends ContentEvent
{
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content;
/**
* Class ContentUpdateEvent
* @package Thelia\Core\Event\Content
@@ -39,7 +38,7 @@ class ContentUpdateEvent extends ContentCreateEvent
protected $url;
function __construct($content_id)
public function __construct($content_id)
{
$this->content_id = $content_id;
}
@@ -144,7 +143,4 @@ class ContentUpdateEvent extends ContentCreateEvent
return $this->url;
}
}
}

View File

@@ -0,0 +1,154 @@
<?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\Country;
/**
* Class CountryCreateEvent
* @package Thelia\Core\Event\Country
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryCreateEvent extends CountryEvent
{
protected $locale;
protected $title;
protected $isocode;
protected $isoAlpha2;
protected $isoAlpha3;
/**
* @var int area zone
*/
protected $area;
/**
* @param mixed $isoAlpha2
*/
public function setIsoAlpha2($isoAlpha2)
{
$this->isoAlpha2 = $isoAlpha2;
return $this;
}
/**
* @return mixed
*/
public function getIsoAlpha2()
{
return $this->isoAlpha2;
}
/**
* @param mixed $isoAlpha3
*/
public function setIsoAlpha3($isoAlpha3)
{
$this->isoAlpha3 = $isoAlpha3;
return $this;
}
/**
* @return mixed
*/
public function getIsoAlpha3()
{
return $this->isoAlpha3;
}
/**
* @param mixed $isocode
*/
public function setIsocode($isocode)
{
$this->isocode = $isocode;
return $this;
}
/**
* @return mixed
*/
public function getIsocode()
{
return $this->isocode;
}
/**
* @param mixed $locale
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* @return mixed
*/
public function getLocale()
{
return $this->locale;
}
/**
* @param mixed $title
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param int $area
*/
public function setArea($area)
{
$this->area = $area;
return $this;
}
/**
* @return int
*/
public function getArea()
{
return $this->area;
}
}

Some files were not shown because too many files have changed in this diff Show More