Merge pull request #505 from roadster31/brands

- Brands implementation
- image + documents refactoring
- new smarty functions for form generation.
- lots of code enhancements
This commit is contained in:
Julien
2014-07-08 11:45:44 +02:00
169 changed files with 27453 additions and 3808 deletions

View File

@@ -1,5 +1,8 @@
#2.0.3
- New coupon type: Free product if selected products are in the cart.
- New feature: Product Brands / Suppliers management
- New 'brand' loop and substitution. product, image and document loop have been updated.
- Images and document processing have been refactored.
#2.0.2
- Coupon UI has been redesigned.

View File

@@ -12,6 +12,11 @@
namespace Thelia\Action;
use Thelia\Core\Event\CachedFileEvent;
use Thelia\Core\Event\File\FileCreateOrUpdateEvent;
use Thelia\Core\Event\File\FileDeleteEvent;
use Thelia\Core\Event\UpdateFilePositionEvent;
use Thelia\Exception\FileException;
use Thelia\Files\FileManager;
use Thelia\Tools\URL;
/**
@@ -32,6 +37,16 @@ use Thelia\Tools\URL;
*/
abstract class BaseCachedFile extends BaseAction
{
/**
* @var FileManager
*/
protected $fileManager;
public function __construct(FileManager $fileManager)
{
$this->fileManager = $fileManager;
}
/**
* @return string root of the file cache directory in web space
*/
@@ -60,6 +75,7 @@ abstract class BaseCachedFile extends BaseAction
{
$iterator = new \DirectoryIterator($path);
/** @var \DirectoryIterator $fileinfo */
foreach ($iterator as $fileinfo) {
if ($fileinfo->isDot()) continue;
@@ -75,8 +91,8 @@ abstract class BaseCachedFile extends BaseAction
/**
* Return the absolute URL to the cached file
*
* @param string $subdir the subdirectory related to cache base
* @param string $filename the safe filename, as returned by getCacheFilePath()
* @param string $subdir the subdirectory related to cache base
* @param string $safe_filename the safe filename, as returned by getCacheFilePath()
* @return string the absolute URL to the cached file
*/
protected function getCacheFileURL($subdir, $safe_filename)
@@ -89,10 +105,10 @@ 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 boolean $forceOriginalDocument if true, the original file path in the cache dir is returned.
* @param string $subdir the subdirectory related to cache base
* @param string $filename the filename
* @param boolean $forceOriginalFile if true, the original file path in the cache dir is returned.
* @param string $hashed_options a hash of transformation options, or null if no transformations have been applied
* @return string the cache directory path relative to Web Root
*/
protected function getCacheFilePath($subdir, $filename, $forceOriginalFile = false, $hashed_options = null)
@@ -132,9 +148,13 @@ abstract class BaseCachedFile extends BaseAction
/**
* Return the absolute cache directory path
*
* @param string $subdir the subdirectory related to cache base, or null to get the cache base directory.
* @throws \RuntimeException if cache directory cannot be created
* @return string the absolute cache directory path
* @param string $subdir the subdirectory related to cache base, or null to get the cache base directory.
* @param bool $create_if_not_exists create the directory if it is not found
*
* @throws \RuntimeException if cache directory cannot be created
* @throws \InvalidArgumentException ii path is invalid, e.g. not in the cache dir
*
* @return string the absolute cache directory path
*/
protected function getCachePath($subdir = null, $create_if_not_exists = true)
{
@@ -160,4 +180,76 @@ abstract class BaseCachedFile extends BaseAction
return $path;
}
/**
* Take care of saving a file in the database and file storage
*
* @param FileCreateOrUpdateEvent $event Image event
*
* @throws \Thelia\Exception\FileException
*
*/
public function saveFile(FileCreateOrUpdateEvent $event)
{
$model = $event->getModel();
$nbModifiedLines = $model->save();
$event->setModel($model);
if (!$nbModifiedLines) {
throw new FileException(
sprintf(
'File "%s" (type %s) with parent id %s failed to be saved',
$event->getParentName(),
get_class($model),
$event->getParentId()
)
);
}
$newUploadedFile = $this->fileManager->copyUploadedFile($event->getModel(), $event->getUploadedFile());
$event->setUploadedFile($newUploadedFile);
}
/**
* Take care of updating file in the database and file storage
*
* @param FileCreateOrUpdateEvent $event Image event
*
* @throws \Thelia\Exception\FileException
*/
public function updateFile(FileCreateOrUpdateEvent $event)
{
// Copy and save file
if ($event->getUploadedFile()) {
// Remove old picture file from file storage
$url = $event->getModel()->getUploadDir() . '/' . $event->getOldModel()->getFile();
unlink(str_replace('..', '', $url));
$newUploadedFile = $this->fileManager->copyUploadedFile($event->getModel(), $event->getUploadedFile());
$event->setUploadedFile($newUploadedFile);
}
// Update image modifications
$event->getModel()->save();
$event->setModel($event->getModel());
}
/**
* Deleting file in the database and in storage
*
* @param FileDeleteEvent $event Image event
*/
public function deleteFile(FileDeleteEvent $event)
{
$this->fileManager->deleteFile($event->getFileToDelete());
}
public function updatePosition(UpdateFilePositionEvent $event)
{
$this->genericUpdatePosition($event->getQuery(), $event);
}
}

View File

@@ -0,0 +1,133 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Brand\BrandCreateEvent;
use Thelia\Core\Event\Brand\BrandDeleteEvent;
use Thelia\Core\Event\Brand\BrandToggleVisibilityEvent;
use Thelia\Core\Event\Brand\BrandUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\UpdateSeoEvent;
use Thelia\Model\Brand as BrandModel;
use Thelia\Model\BrandQuery;
/**
* Class Brand
*
* @package Thelia\Action
* @author Franck Allimant <franck@cqfdev.fr>
*/
class Brand extends BaseAction implements EventSubscriberInterface
{
public function create(BrandCreateEvent $event)
{
$brand = new BrandModel();
$brand
->setVisible($event->getVisible())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->save()
;
$event->setBrand($brand);
}
/**
* process update brand
*
* @param BrandUpdateEvent $event
*/
public function update(BrandUpdateEvent $event)
{
if (null !== $brand = BrandQuery::create()->findPk($event->getBrandId())) {
$brand->setDispatcher($event->getDispatcher());
$brand
->setVisible($event->getVisible())
->setLogoImageId(intval($event->getLogoImageId()) == 0 ? null : $event->getLogoImageId())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save()
;
$event->setBrand($brand);
}
}
/**
* Toggle Brand visibility
*
* @param BrandToggleVisibilityEvent $event
*/
public function toggleVisibility(BrandToggleVisibilityEvent $event)
{
$brand = $event->getBrand();
$brand
->setDispatcher($event->getDispatcher())
->setVisible(!$brand->getVisible())
->save();
$event->setBrand($brand);
}
/**
* Change Brand SEO
*
* @param \Thelia\Core\Event\UpdateSeoEvent $event
*
* @return mixed
*/
public function updateSeo(UpdateSeoEvent $event)
{
return $this->genericUpdateSeo(BrandQuery::create(), $event);
}
public function delete(BrandDeleteEvent $event)
{
if (null !== $brand = BrandQuery::create()->findPk($event->getBrandId())) {
$brand->setDispatcher($event->getDispatcher())->delete();
$event->setBrand($brand);
}
}
public function updatePosition(UpdatePositionEvent $event)
{
$this->genericUpdatePosition(BrandQuery::create(), $event);
}
/**
* @inheritdoc
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::BRAND_CREATE => array('create', 128),
TheliaEvents::BRAND_UPDATE => array('update', 128),
TheliaEvents::BRAND_DELETE => array('delete', 128),
TheliaEvents::BRAND_UPDATE_SEO => array('updateSeo', 128),
TheliaEvents::BRAND_UPDATE_POSITION => array('updatePosition', 128),
TheliaEvents::BRAND_TOGGLE_VISIBILITY => array('toggleVisibility', 128),
);
}
}

View File

@@ -12,18 +12,11 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent;
use Thelia\Core\Event\Document\DocumentEvent;
use Thelia\Core\Event\UpdateFilePositionEvent;
use Thelia\Exception\ImageException;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\FileManager;
use Thelia\Tools\URL;
use Thelia\Exception\DocumentException;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\DocumentException;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL;
/**
*
@@ -71,7 +64,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
*/
public function processDocument(DocumentEvent $event)
{
$subdir = $event->getCacheSubdirectory();
$subdir = $event->getCacheSubdirectory();
$sourceFile = $event->getSourceFilepath();
if (null == $subdir || null == $sourceFile) {
@@ -108,96 +101,16 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
$event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE));
}
/**
* Take care of saving document in the database and file storage
*
* @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
*/
public function saveDocument(DocumentCreateOrUpdateEvent $event)
{
$fileManager = new FileManager();
$model = $event->getModelDocument();
$nbModifiedLines = $model->save();
$event->setModelDocument($model);
if (!$nbModifiedLines) {
throw new ImageException(
sprintf(
'Document "%s" with parent id %s (%s) failed to be saved',
$event->getParentName(),
$event->getParentId(),
$event->getDocumentType()
)
);
}
$newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getDocumentType(), $event->getModelDocument(), $event->getUploadedFile(), FileManager::FILE_TYPE_DOCUMENTS);
$event->setUploadedFile($newUploadedFile);
}
/**
* Take care of updating document in the database and file storage
*
* @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
*/
public function updateDocument(DocumentCreateOrUpdateEvent $event)
{
if (null !== $event->getUploadedFile()) {
$event->getModelDocument()->setTitle($event->getUploadedFile()->getClientOriginalName());
}
$fileManager = new FileManager();
// Copy and save file
if ($event->getUploadedFile()) {
// Remove old picture file from file storage
$url = $fileManager->getUploadDir($event->getDocumentType(), FileManager::FILE_TYPE_DOCUMENTS) . '/' . $event->getOldModelDocument()->getFile();
unlink(str_replace('..', '', $url));
$newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getDocumentType(), $event->getModelDocument(), $event->getUploadedFile(), FileManager::FILE_TYPE_DOCUMENTS);
$event->setUploadedFile($newUploadedFile);
}
// Update document modifications
$event->getModelDocument()->save();
$event->setModelDocument($event->getModelDocument());
}
public function updatePosition(UpdateFilePositionEvent $event)
{
$this->genericUpdatePosition($event->getQuery(), $event);
}
/**
* Take care of deleting document in the database and file storage
*
* @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
*/
public function deleteDocument(DocumentDeleteEvent $event)
{
$fileManager = new FileManager();
$fileManager->deleteFile($event->getDocumentToDelete(), $event->getDocumentType(), FileManager::FILE_TYPE_DOCUMENTS);
}
public static function getSubscribedEvents()
{
return array(
TheliaEvents::DOCUMENT_PROCESS => array("processDocument", 128),
// Implemented in parent class BaseCachedFile
TheliaEvents::DOCUMENT_CLEAR_CACHE => array("clearCache", 128),
TheliaEvents::DOCUMENT_DELETE => array("deleteDocument", 128),
TheliaEvents::DOCUMENT_SAVE => array("saveDocument", 128),
TheliaEvents::DOCUMENT_UPDATE => array("updateDocument", 128),
TheliaEvents::DOCUMENT_DELETE => array("deleteFile", 128),
TheliaEvents::DOCUMENT_SAVE => array("saveFile", 128),
TheliaEvents::DOCUMENT_UPDATE => array("updateFile", 128),
TheliaEvents::DOCUMENT_UPDATE_POSITION => array("updatePosition", 128),
);
}

View File

@@ -12,23 +12,17 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageDeleteEvent;
use Thelia\Core\Event\Image\ImageEvent;
use Thelia\Core\Event\UpdateFilePositionEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\FileManager;
use Thelia\Tools\URL;
use Imagine\Image\ImagineInterface;
use Imagine\Image\ImageInterface;
use Imagine\Image\Box;
use Imagine\Image\Color;
use Imagine\Image\ImageInterface;
use Imagine\Image\ImagineInterface;
use Imagine\Image\Point;
use Thelia\Exception\ImageException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Image\ImageEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\ImageException;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL;
/**
*
@@ -88,8 +82,10 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
*
* This method updates the cache_file_path and file_url attributes of the event
*
* @param \Thelia\Core\Event\Image\ImageEvent $event
* @throws \InvalidArgumentException, ImageException
* @param ImageEvent $event
*
* @throws \Thelia\Exception\ImageException
* @throws \InvalidArgumentException
*/
public function processImage(ImageEvent $event)
{
@@ -139,6 +135,11 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
if ($image) {
// Allow image pre-processing (watermarging, or other stuff...)
$event->setImageObject($image);
$event->getDispatcher()->dispatch(TheliaEvents::IMAGE_PREPROCESSING, $event);
$image = $event->getImageObject();
$background_color = $event->getBackgroundColor();
if ($background_color != null) {
@@ -208,6 +209,11 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
if (is_null($quality)) $quality = ConfigQuery::read('default_image_quality_percent', 75);
// Allow image post-processing (watermarging, or other stuff...)
$event->setImageObject($image);
$event->getDispatcher()->dispatch(TheliaEvents::IMAGE_POSTPROCESSING, $event);
$image = $event->getImageObject();
$image->save(
$cacheFilePath,
array('quality' => $quality)
@@ -232,83 +238,6 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
$event->setOriginalFileUrl(URL::getInstance()->absoluteUrl($original_image_url, null, URL::PATH_TO_FILE));
}
/**
* Take care of saving image in the database and file storage
*
* @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
*/
public function saveImage(ImageCreateOrUpdateEvent $event)
{
$fileManager = new FileManager();
$model = $event->getModelImage();
$nbModifiedLines = $model->save();
$event->setModelImage($model);
if (!$nbModifiedLines) {
throw new ImageException(
sprintf(
'Image "%s" with parent id %s (%s) failed to be saved',
$event->getParentName(),
$event->getParentId(),
$event->getImageType()
)
);
}
$newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getImageType(), $event->getModelImage(), $event->getUploadedFile(), FileManager::FILE_TYPE_IMAGES);
$event->setUploadedFile($newUploadedFile);
}
/**
* Take care of updating image in the database and file storage
*
* @param 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
*/
public function updateImage(ImageCreateOrUpdateEvent $event)
{
$fileManager = new FileManager();
// Copy and save file
if ($event->getUploadedFile()) {
// Remove old picture file from file storage
$url = $fileManager->getUploadDir($event->getImageType(), FileManager::FILE_TYPE_IMAGES) . '/' . $event->getOldModelImage()->getFile();
unlink(str_replace('..', '', $url));
$newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getImageType(), $event->getModelImage(), $event->getUploadedFile(), FileManager::FILE_TYPE_IMAGES);
$event->setUploadedFile($newUploadedFile);
}
// Update image modifications
$event->getModelImage()->save();
$event->setModelImage($event->getModelImage());
}
public function updatePosition(UpdateFilePositionEvent $event)
{
$this->genericUpdatePosition($event->getQuery(), $event);
}
/**
* Take care of deleting image in the database and file storage
*
* @param ImageDeleteEvent $event Image event
*
* @throws \Exception
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
*/
public function deleteImage(ImageDeleteEvent $event)
{
$fileManager = new FileManager();
$fileManager->deleteFile($event->getImageToDelete(), $event->getImageType(), FileManager::FILE_TYPE_IMAGES);
}
/**
* Process image resizing, with borders or cropping. If $dest_width and $dest_height
* are both null, no resize is performed.
@@ -428,10 +357,12 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
{
return array(
TheliaEvents::IMAGE_PROCESS => array("processImage", 128),
// Implemented in parent class BaseCachedFile
TheliaEvents::IMAGE_CLEAR_CACHE => array("clearCache", 128),
TheliaEvents::IMAGE_DELETE => array("deleteImage", 128),
TheliaEvents::IMAGE_SAVE => array("saveImage", 128),
TheliaEvents::IMAGE_UPDATE => array("updateImage", 128),
TheliaEvents::IMAGE_DELETE => array("deleteFile", 128),
TheliaEvents::IMAGE_SAVE => array("saveFile", 128),
TheliaEvents::IMAGE_UPDATE => array("updateFile", 128),
TheliaEvents::IMAGE_UPDATE_POSITION => array("updatePosition", 128),
);
}

View File

@@ -99,6 +99,7 @@ class Product extends BaseAction implements EventSubscriberInterface
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->setVisible($event->getVisible() ? 1 : 0)
->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())
->save()
;

View File

@@ -6,11 +6,16 @@ return array(
'%obj SEO modification' => '%obj SEO modification',
'%obj creation' => '%obj creation',
'%obj modification' => '%obj modification',
'%obj%s deleted successfully' => '%obj%s deleted successfully',
'%type% position updated' => '%type% position updated',
'\'%type\' loop class should extends Thelia\Core\Template\Element\BaseLoop' => '\'%type\' loop class should extends Thelia\Core\Template\Element\BaseLoop',
'A currency with code "%name" already exists.' => 'A currency with code "%name" already exists.',
'A descriptive title' => 'A descriptive title',
'A loop named \'%name\' already exists in the current scope.' => 'A loop named \'%name\' already exists in the current scope.',
'A message with name "%name" already exists.' => 'A message with name "%name" already exists.',
'A product with reference %ref already exists. Please choose another reference.' => 'A product with reference %ref already exists. Please choose another reference.',
'A short description, used when a summary or an introduction is required' => 'A short description, used when a summary or an introduction is required',
'A short text, used when an additional or supplemental information is required.' => 'A short text, used when an additional or supplemental information is required.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.',
'A value for attribute "%name" is already present in the combination' => 'A value for attribute "%name" is already present in the combination',
'A variable with name "%name" already exists.' => 'A variable with name "%name" already exists.',
@@ -39,6 +44,9 @@ return array(
'Bad tax list JSON' => 'Bad tax list JSON',
'Billing country' => 'Billing country',
'Billing coutry is' => 'Le pays de facturation est',
'Brand' => 'Brand',
'Brand / Supplier' => 'Brand / Supplier',
'Brand name' => 'Brand name',
'Business ID' => 'Business ID',
'Cannot find a default country. Please define one.' => 'Cannot find a default country. Please define one.',
'Cannot find the shop country. Please select a shop country.' => 'Cannot find the shop country. Please select a shop country.',
@@ -78,37 +86,34 @@ return array(
'Default folder *' => 'Default folder *',
'Default product category *' => 'Default product category *',
'Default product sale element' => 'Default product sale element',
'Deleting document for %id% with parent id %parentId%' => 'Deleting document for %id% with parent id %parentId%',
'Deleting image for %id% with parent id %parentId%' => 'Deleting image for %id% with parent id %parentId%',
'Deleting %obj% for %id% with parent id %parentId%' => 'Deleting %obj% for %id% with parent id %parentId%',
'Delivery country' => 'Delivery country',
'Delivery coutry is' => 'Le pays de livraison est',
'Delivery module ID not found' => 'Delivery module ID not found',
'Description' => 'Description',
'Detailed description' => 'Detailed description',
'Disabled' => 'Disabled',
'Document deleted successfully' => 'Document deleted successfully',
'Document position updated' => 'Document position updated',
'Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.' => 'Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.',
'EAN Code' => 'EAN Code',
'Email Address' => 'Email Address',
'Email address' => 'Email address',
'Emergency' => 'Emergency',
'Enable remote SMTP use' => 'Enable remote SMTP use',
'Encryption' => 'Encryption',
'Enter here the brand name in the default language (%title%)' => 'Enter here the brand name in the default language (%title%)',
'Equal to' => 'Egal à',
'Error during %action process : %error. Exception was %exc' => 'Error during %action process : %error. Exception was %exc',
'Error occured while processing order ref. %ref, ID %id: %err' => 'Error occured while processing order ref. %ref, ID %id: %err',
'Errors' => 'Errors',
'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)' => 'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)',
'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)' => 'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)',
'Fail to update document position' => 'Fail to update document position',
'Fail to update image position' => 'Fail to update image position',
'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)' => 'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)',
'Fail to update %type% position: %err%' => 'Fail to update %type% position: %err%',
'Failed to create instance of module "%name%" when trying to delete module. Module directory has probably been deleted' => 'Failed to create instance of module "%name%" when trying to delete module. Module directory has probably been deleted',
'Failed to find a payment Module with ID=%mid for order ID=%oid' => 'Failed to find a payment Module with ID=%mid for order ID=%oid',
'Failed to open translation file %file. Please be sure that this file is writable by your Web server' => 'Failed to open translation file %file. Please be sure that this file is writable by your Web server',
'Failed to update language definition: %ex' => 'Failed to update language definition: %ex',
'Fax' => 'Fax',
'Feature value does not match FLOAT format' => 'Feature value does not match FLOAT format',
'File is too heavy, please retry with a file having a size less than %size%.' => 'File is too Large, please retry with a file having a size less than %size%.',
'File is too large, please retry with a file having a size less than %size%.' => 'File is too large, please retry with a file having a size less than %size%.',
'First Name' => 'First Name',
'Firstname' => 'Firstname',
'Fixed Amount Discount' => 'Fixed Amount Discount',
@@ -132,8 +137,6 @@ return array(
'If a translation is missing or incomplete :' => 'If a translation is missing or incomplete :',
'If cart item count is <strong>%operator%</strong> %quantity%' => 'If cart item count is <strong>%operator%</strong> %quantity%',
'If cart total amount is <strong>%operator%</strong> %amount% %currency%' => 'If cart total amount is <strong>%operator%</strong> %amount% %currency%',
'Image position updated' => 'Image position updated',
'Images deleted successfully' => 'Images deleted successfully',
'Impossible to delete a customer who already have orders' => 'Impossible to delete a customer who already have orders',
'In' => 'In',
'Information' => 'Information',
@@ -141,6 +144,7 @@ return array(
'Invalid value "%value" for "%param" parameter in loop type: %type, name: %name' => 'Invalid value "%value" for "%param" parameter in loop type: %type, name: %name',
'Invalid value for walkMode parameter: %value' => 'Invalid value for walkMode parameter: %value',
'Is it the default product sale element ?' => 'Is it the default product sale element ?',
'Keep the most important part of your description in the first 150-160 characters.' => 'Keep the most important part of your description in the first 150-160 characters.',
'Language name' => 'Language name',
'Last Name' => 'Last Name',
'Lastname' => 'Lastname',
@@ -155,6 +159,8 @@ return array(
'Loop must implements \'PropelSearchLoopInterface\' to be versionable' => 'Loop must implements \'PropelSearchLoopInterface\' to be versionable',
'Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`' => 'Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`',
'Loop type \'%type\' is not defined.' => 'Loop type \'%type\' is not defined.',
'Make sure it uses keywords found within the page itself.' => 'Make sure it uses keywords found within the page itself.',
'Make sure that your title is clear, and contains many of the keywords within the page itself.' => 'Make sure that your title is clear, and contains many of the keywords within the page itself.',
'Make this address as my primary address' => 'Make this address as my primary address',
'Maximum usage count reached for coupon %code' => 'Maximum usage count reached for coupon %code',
'Message subject' => 'Message subject',
@@ -182,6 +188,7 @@ return array(
'Not found' => 'Not found',
'Not in' => 'Not in',
'Notices' => 'Notices',
'Only files having the following mime type are allowed: %types%' => 'Only files having the following mime type are allowed: %types%',
'Only if order billing country is %op% <strong>%countries_list%</strong>' => 'Le pays de facturation de la commande est %op% <strong>%countries_list%</strong> ',
'Only if order shipping country is %op% <strong>%countries_list%</strong>' => 'Le pays de livraison de la commande est %op% <strong>%countries_list%</strong> ',
'Order address ID not found' => 'Order address ID not found',
@@ -255,9 +262,13 @@ return array(
'Rotated Text File' => 'Rotated Text File',
'Sale price excluding taxes' => 'Sale price excluding taxes',
'Sale price including taxes' => 'Sale price including taxes',
'Saving documents for %parentName% parent id %parentId% (%parentType%)' => 'Saving documents for %parentName% parent id %parentId% (%parentType%)',
'Saving images for %parentName% parent id %parentId% (%parentType%)' => 'Saving images for %parentName% parent id %parentId% (%parentType%)',
'Saving %obj% for %parentName% parent id %parentId%' => 'Saving %obj% for %parentName% parent id %parentId%',
'Select the brand logo' => 'Select the brand logo',
'Select the brand logo amongst the brand images' => 'Select the brand logo amongst the brand images',
'Select the product brand, or supplier.' => 'Select the product brand, or supplier.',
'Shipping zone name' => 'Shipping zone name',
'Short additional text' => 'Short additional text',
'Short description text' => 'Short description text',
'Show redirections *' => 'Show redirections *',
'Sorry, an error occured: %msg' => 'Sorry, an error occured: %msg',
'Sorry, an error occurred: %err' => 'Sorry, an error occurred: %err',
@@ -286,15 +297,19 @@ return array(
'Template file %file cannot be found.' => 'Template file %file cannot be found.',
'Text File' => 'Text File',
'Text Message' => 'Text Message',
'The HTML TITLE element is the most important element on your web page.' => 'The HTML TITLE element is the most important element on your web page.',
'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.',
'The brand name or title' => 'The brand name or title',
'The cart item count should match the condition' => 'The cart item count should match the condition',
'The coupon applies if the cart contains at least one product of the selected categories' => 'The coupon applies if the cart contains at least one product of the selected categories',
'The coupon applies if the cart contains at least one product of the specified product list' => 'The coupon applies if the cart contains at least one product of the specified product list',
'The coupon applies to some customers only' => 'The coupon applies to some customers only',
'The coupon applies to the selected delivery countries' => 'Ce code promo s\'applique seulement aux pays de facturation sélectionnés',
'The coupon is valid after a given date' => 'Le code promo est valide seulement à partir d\'une certaine date',
'The detailed description.' => 'The detailed description.',
'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.' => 'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.',
'The loop name \'%name\' is already defined in %className class' => 'The loop name \'%name\' is already defined in %className class',
'This brand is online' => 'This brand is online',
'This category is online.' => 'This category is online.',
'This condition is always true' => 'This condition is always true',
'This content is online.' => 'This content is online.',
@@ -329,9 +344,9 @@ return array(
'Unconditionnal usage' => 'Unconditionnal usage',
'Undefined loop argument "%name"' => 'Undefined loop argument "%name"',
'Undefined search mode \'%mode\'' => 'Undefined search mode \'%mode\'',
'Undefined translation type: %item' => 'Undefined translation type: %item',
'Unknown order ID: %id' => 'Unknown order ID: %id',
'Unsupported magic method %name. only getArgname() is supported.' => 'Unsupported magic method %name. only getArgname() is supported.',
'Use the keyword phrase in your URL.' => 'Use the keyword phrase in your URL.',
'Username' => 'Username',
'Username *' => 'Username *',
'Valid only from %date% to the coupon expiration date' => 'Valide à partir du %date% jusqu\'à la date d\'expiration',
@@ -343,7 +358,7 @@ return array(
'Weight' => 'Weight',
'Yes, I have a password :' => 'Yes, I have a password :',
'You are already registered!' => 'You are already registered!',
'You can only upload images (.png, .jpg, .jpeg, .gif)' => 'You can only upload images (.png, .jpg, .jpeg, .gif)',
'You don\'t need to use commas or other punctuations.' => 'You don\'t need to use commas or other punctuations.',
'Your Email Address' => 'Your Email Address',
'Your Message' => 'Your Message',
'Your current password does not match.' => 'Your current password does not match.',

View File

@@ -6,11 +6,16 @@ return array(
'%obj SEO modification' => 'Modification SEO de %obj',
'%obj creation' => 'Création de %obj',
'%obj modification' => 'Modification de %obj',
'%obj%s deleted successfully' => '%obj%s ont été supprimé(e)s',
'%type% position updated' => 'Mise à jour de la position de %type%',
'\'%type\' loop class should extends Thelia\Core\Template\Element\BaseLoop' => 'La classe de boucle \'%type\' doit hériter de Thelia\Core\Template\Element\BaseLoop ',
'A currency with code "%name" already exists.' => 'Une devise avec la code "%name" existe déjà',
'A descriptive title' => 'Un titre descriptif',
'A loop named \'%name\' already exists in the current scope.' => 'Une boucle nommée \'%name\' existe déjà dans le scope courant',
'A message with name "%name" already exists.' => 'Un message avec le nom "%name" existe déjà.',
'A product with reference %ref already exists. Please choose another reference.' => 'Un produit portant la référfence %ref existe déja. Merci de choisir une autre référence.',
'A short description, used when a summary or an introduction is required' => 'Un texte court, utilisée quand un résumé ou une introduction est nécessaire.',
'A short text, used when an additional or supplemental information is required.' => 'Un texte court, utilisé quand une conclusion ou une information complémentaire est nécessaire.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.',
'A value for attribute "%name" is already present in the combination' => 'Une valeur pour la déclinaison "%name" est déjà présente dans la combinaison',
'A variable with name "%name" already exists.' => 'Une variable avec le nom "%name" existe déjà.',
@@ -39,6 +44,9 @@ return array(
'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes',
'Billing country' => 'Pays de livraison',
'Billing coutry is' => 'Pays de facturation',
'Brand' => 'Marque',
'Brand / Supplier' => 'Marque / Fournisseur',
'Brand name' => 'Nom de la marque',
'Business ID' => 'ID du business',
'Cannot find a default country. Please define one.' => 'Impossible de trouver un pays par défaut. Veuillez en définir un.',
'Cannot find the shop country. Please select a shop country.' => 'Impossible de trouver le pays du magasin. Veuillez en sélectionner un.',
@@ -78,37 +86,34 @@ return array(
'Default folder *' => 'Dossier par défaut *',
'Default product category *' => 'Catégorie du produit par défaut *',
'Default product sale element' => 'Product Sale Element par défaut',
'Deleting document for %id% with parent id %parentId%' => 'Suppression du document %id% avec l\'ID parent %parentId%',
'Deleting image for %id% with parent id %parentId%' => 'Suppression de l\'image %id% avec l\'ID parent %parentId%',
'Deleting %obj% for %id% with parent id %parentId%' => 'Suppresion de %obj%, ID %id%, ID parent %parentId%',
'Delivery country' => 'Pays de livraison',
'Delivery coutry is' => 'Le pays de livraison est',
'Delivery module ID not found' => 'Id du module de livraison non trouvé',
'Description' => 'Description',
'Detailed description' => 'Description détaillée',
'Disabled' => 'Désactivé',
'Document deleted successfully' => 'Le document a été supprimé.',
'Document position updated' => 'La position du document a été modfiée',
'Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.' => 'Ne répétez pas sans cesse les même mots-clés dans une ligne. Préférez utiliser des expressions de mots-clés',
'EAN Code' => 'Code EAN',
'Email Address' => 'Adresse mail',
'Email address' => 'Adresse e-mail',
'Emergency' => 'Urgence',
'Enable remote SMTP use' => 'Activer l\'utilisation d\'un serveur SMTP distant.',
'Encryption' => 'Chiffrement',
'Enter here the brand name in the default language (%title%)' => 'Indiquez le nom de la marque dans la langue par défaut (%title%)',
'Equal to' => 'Egal à',
'Error during %action process : %error. Exception was %exc' => 'Erreur lors de %action: %error. Exception: %exc ',
'Error occured while processing order ref. %ref, ID %id: %err' => 'Un erreur est survenue paedant le traitement de la commande ref. %ref, ID %id; %err',
'Errors' => 'Erreurs',
'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)' => 'Echec lors de la suppression du document %id% avec l\'ID parent %parentId% (Exception : %e%)',
'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)' => 'Echec lors de la suppression de l\'image %id% avec l\'ID parent %parentId% (Exception : %e%)',
'Fail to update document position' => 'La position du document e n\'a pas pu être modfiée',
'Fail to update image position' => 'La position de l\'image n\'a pas pu être modfiée',
'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)' => 'Ne peut supprimer %obj% ID %id% ID parent %parentId% (Exception : %e%)',
'Fail to update %type% position: %err%' => 'Erreur lors de la mise àç jour de la position de %type%: %err%',
'Failed to create instance of module "%name%" when trying to delete module. Module directory has probably been deleted' => 'Ne peut créer une instance du module "%name%" lors de la suppression du module. Le répertoire du module à sans doute été supprimé manuellement.',
'Failed to find a payment Module with ID=%mid for order ID=%oid' => 'Ne peut trouver le module de paiement ID=%mid pour la commande ID=%oid ',
'Failed to open translation file %file. Please be sure that this file is writable by your Web server' => 'L\'ouverture du fichier %file a échoué. Merci de vérifier que ce fichier est accessible en écriture pour votre serveur Web.',
'Failed to update language definition: %ex' => 'Erreur lors de la mise à jour de la définition de la langue : %ex',
'Fax' => 'Fax',
'Feature value does not match FLOAT format' => 'valeur de caractéristique n\'est pas un FLOAT',
'File is too heavy, please retry with a file having a size less than %size%.' => 'La taille du fichier est trop importante, et doit être inféreiure à %size%.',
'File is too large, please retry with a file having a size less than %size%.' => 'La taille de ce fichier est trop importante. Merci d\'envoyer des fichier dont la taille est inférieure à %size%.',
'First Name' => 'Prénom',
'Firstname' => 'Prénom',
'Fixed Amount Discount' => 'Remise d\'un montant fixe',
@@ -132,8 +137,6 @@ return array(
'If a translation is missing or incomplete :' => 'Si une traduction est manquante ou incomplète :',
'If cart item count is <strong>%operator%</strong> %quantity%' => 'Le nombre d\'articles dans le panier est <strong>%operator%</strong> %quantity% ',
'If cart total amount is <strong>%operator%</strong> %amount% %currency%' => 'Si le total du panier est <strong>%operator%</strong> %amount% %currency% ',
'Image position updated' => 'La position de l\'image a été modfiée',
'Images deleted successfully' => 'L\'image a été supprimée.',
'Impossible to delete a customer who already have orders' => 'Impossible de supprimer un client si celui-ci a déjà une commande',
'In' => 'Compris dans',
'Information' => 'Information',
@@ -141,6 +144,7 @@ return array(
'Invalid value "%value" for "%param" parameter in loop type: %type, name: %name' => 'La valeur "%value" est invalide pour le paramètre "%param" dans la boucle type: %type, nom: %name ',
'Invalid value for walkMode parameter: %value' => 'Valeur incorrecte pour le paramètre walkMode : %value',
'Is it the default product sale element ?' => 'Product Sale Element par défaut ?',
'Keep the most important part of your description in the first 150-160 characters.' => 'Votre description ne devrait pas dépasser 150 à 160 caractères',
'Language name' => 'Nom de la langue',
'Last Name' => 'Nom',
'Lastname' => 'Nom',
@@ -155,6 +159,8 @@ return array(
'Loop must implements \'PropelSearchLoopInterface\' to be versionable' => 'Les classes \'boucle\' doivent implémenter \'PropelSearchLoopInterface\' pour être versonnables',
'Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`' => 'Une boucle doit implémenter au moins une de ces interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`',
'Loop type \'%type\' is not defined.' => 'La boucle de type \'%type\' n\'existe pas.',
'Make sure it uses keywords found within the page itself.' => 'Assurez vous d\'utiliser des mots-clés présents dans la page courante',
'Make sure that your title is clear, and contains many of the keywords within the page itself.' => 'Assurez-vous d\'avoir un titre clair et qui contient les mots-clés correspondant à la page en cours',
'Make this address as my primary address' => 'Choisir cette adresse comme adresse par défaut',
'Maximum usage count reached for coupon %code' => 'Le nombre maximum d\'utilisation pour le coupon %code est dépassé.',
'Message subject' => 'Sujet',
@@ -182,6 +188,7 @@ return array(
'Not found' => 'Non trouvé.',
'Not in' => 'Non compris dans',
'Notices' => 'Notices',
'Only files having the following mime type are allowed: %types%' => 'Seuls les types MIME autorisés sont les suivants: %types%',
'Only if order billing country is %op% <strong>%countries_list%</strong>' => 'Si le pays de facturation %op% <strong>%countries_list%</strong> ',
'Only if order shipping country is %op% <strong>%countries_list%</strong>' => 'Si le pays de livraison %op% <strong>%countries_list%</strong> ',
'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé',
@@ -255,9 +262,13 @@ return array(
'Rotated Text File' => 'Rotation du fichier texte',
'Sale price excluding taxes' => 'Prix de vente Hors Taxes',
'Sale price including taxes' => 'Prix de vente Toutes Taxes Comprises',
'Saving documents for %parentName% parent id %parentId% (%parentType%)' => 'Enregistrement des documents pour %parentName% ID parent %parentId% (%parentType%)',
'Saving images for %parentName% parent id %parentId% (%parentType%)' => 'Enregistrement des images pour %parentName% ID parent %parentId% (%parentType%)',
'Saving %obj% for %parentName% parent id %parentId%' => 'Enregistrement de %obj% pour %parentName% ID parent %parentId%',
'Select the brand logo' => 'Logo de la marque',
'Select the brand logo amongst the brand images' => 'Choisissez le logo de la marque parmis les images associées à cette marque',
'Select the product brand, or supplier.' => 'Choisissez la marque ou le fournisseur du produit.',
'Shipping zone name' => 'Nom de la zone de livraison',
'Short additional text' => 'Un court texte supplémentaire',
'Short description text' => 'Un court texte de description',
'Show redirections *' => 'Montrer les redirections *',
'Sorry, an error occured: %msg' => 'Désolé, une erreur est survenue : %msg',
'Sorry, an error occurred: %err' => 'Désolé, une erreur est survenue: %err',
@@ -286,15 +297,19 @@ return array(
'Template file %file cannot be found.' => 'Le fichier %file n\'a pas été trouvé dans le template. ',
'Text File' => 'Fichier texte',
'Text Message' => 'Message au format texte',
'The HTML TITLE element is the most important element on your web page.' => 'L\'élément HTML TITLE est le plus important dans votre page',
'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.',
'The brand name or title' => 'Le nom ou le titre de la marque',
'The cart item count should match the condition' => 'Le nombre d\'articles dans le panier doit vérifier la condition',
'The coupon applies if the cart contains at least one product of the selected categories' => 'Le code promo est valable si le panier contient/ne contient pas des produits appartenant aux catégories sélectionnées',
'The coupon applies if the cart contains at least one product of the specified product list' => 'Le code promo est valable si le panier contient/ne contient pas au moins un des produits selectionnés',
'The coupon applies to some customers only' => 'Ce code promo est valable pour les clients sélectionnés',
'The coupon applies to the selected delivery countries' => 'Ce code promo s\'applique pour les pays de livraison sélectionnés',
'The coupon is valid after a given date' => 'Le code promo est valide à partir de cette date',
'The detailed description.' => 'La description détaillée',
'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.' => 'L\'image qui remplace un drapeau de pays manquant (%file) n\'a pas été trouvée. Merci de vérifier la variable de configuration unknown-flag-path.',
'The loop name \'%name\' is already defined in %className class' => 'La boucle \'%name\' est déjà définir dans la classe %className',
'This brand is online' => 'Cette marque est en ligne',
'This category is online.' => 'Cette catégorie est en ligne.',
'This condition is always true' => 'Cette condition est troujours vérifiée',
'This content is online.' => 'Ce contenu est en ligne.',
@@ -329,9 +344,9 @@ return array(
'Unconditionnal usage' => 'Utilisable sans conditions',
'Undefined loop argument "%name"' => 'Argument de boucle invalide: "%name" ',
'Undefined search mode \'%mode\'' => 'Mode de recherche \'%mode\' invalide',
'Undefined translation type: %item' => 'Type de traduction inconnu:%item ',
'Unknown order ID: %id' => 'La commande ID %id est inconnue.',
'Unsupported magic method %name. only getArgname() is supported.' => 'La méthode magique %name n\'est pas supportée. Seule get<argname>() est supporté..',
'Use the keyword phrase in your URL.' => 'Utilisez des mots clés dans votre URL',
'Username' => 'Nom d\'utilisateur',
'Username *' => 'Nom d\'utilisateur *',
'Valid only from %date% to the coupon expiration date' => 'Valide à partir de %date% jusqu\'à la date d\'expoiration',
@@ -343,7 +358,7 @@ return array(
'Weight' => 'Poids',
'Yes, I have a password :' => 'Oui, j\'ai un mot de passe :',
'You are already registered!' => 'Vous êtes déjà enregistré !',
'You can only upload images (.png, .jpg, .jpeg, .gif)' => 'Seules les images sont autorisées (.png, .jpg, .jpeg, .gif)',
'You don\'t need to use commas or other punctuations.' => 'Vous n\'avez pas besoin d\'utiliser de virgules ou d\'autres signes de ponctuation',
'Your Email Address' => 'Votre adresse mail',
'Your Message' => 'Votre message',
'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas',

View File

@@ -55,9 +55,11 @@
</service>
<service id="thelia.action.image" class="Thelia\Action\Image">
<argument type="service" id="thelia.file_manager"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.document" class="Thelia\Action\Document">
<argument type="service" id="thelia.file_manager"/>
<tag name="kernel.event_subscriber"/>
</service>
@@ -121,6 +123,10 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.brand" class="Thelia\Action\Brand">
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pdf" class="Thelia\Action\Pdf">
<tag name="kernel.event_subscriber"/>

View File

@@ -9,8 +9,34 @@
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\EventListener\EsiListener</parameter>
<parameter key="fragment.renderer.esi.class">Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer</parameter>
<parameter key="fragment.renderer.inline.class">Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer</parameter>
<!--
The list of Model classes which suppoorts image or document management.
The key should have form type.parent, where type is the file type (document or image)
and parent is the parent object of the file, form example product, brand, folder, etc.
-->
<parameter key="file_model.classes" type="collection">
<parameter key="document.product">Thelia\Model\ProductDocument</parameter>
<parameter key="image.product">Thelia\Model\ProductImage</parameter>
<parameter key="document.category">Thelia\Model\CategoryDocument</parameter>
<parameter key="image.category">Thelia\Model\CategoryImage</parameter>
<parameter key="document.content">Thelia\Model\ContentDocument</parameter>
<parameter key="image.content">Thelia\Model\ContentImage</parameter>
<parameter key="document.folder">Thelia\Model\FolderDocument</parameter>
<parameter key="image.folder">Thelia\Model\FolderImage</parameter>
<parameter key="document.brand">Thelia\Model\BrandDocument</parameter>
<parameter key="image.brand">Thelia\Model\BrandImage</parameter>
</parameter>
</parameters>
<services>
<!-- URL maganement -->
@@ -80,6 +106,11 @@
<argument >%kernel.debug%</argument>
</service>
<!-- The file manager -->
<service id="thelia.file_manager" class="Thelia\Files\FileManager">
<argument>%file_model.classes%</argument>
</service>
<service id="http_kernel" class="Thelia\Core\TheliaHttpKernel">
<argument type="service" id="event_dispatcher" />
<argument type="service" id="service_container" />

View File

@@ -52,6 +52,12 @@
<form name="thelia.admin.content.image.modification" class="Thelia\Form\ContentImageModification"/>
<form name="thelia.admin.content.document.modification" class="Thelia\Form\ContentDocumentModification"/>
<form name="thelia.admin.brand.creation" class="Thelia\Form\Brand\BrandCreationForm"/>
<form name="thelia.admin.brand.modification" class="Thelia\Form\Brand\BrandModificationForm"/>
<form name="thelia.admin.brand.image.modification" class="Thelia\Form\Brand\BrandImageModification"/>
<form name="thelia.admin.brand.document.modification" class="Thelia\Form\Brand\BrandDocumentModification"/>
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>

View File

@@ -14,6 +14,7 @@
<loop class="Thelia\Core\Template\Loop\AttributeAvailability" name="attribute_availability"/>
<loop class="Thelia\Core\Template\Loop\AttributeCombination" name="attribute_combination"/>
<loop class="Thelia\Core\Template\Loop\Auth" name="auth"/>
<loop class="Thelia\Core\Template\Loop\Brand" name="brand"/>
<loop class="Thelia\Core\Template\Loop\Category" name="category"/>
<loop class="Thelia\Core\Template\Loop\Content" name="content"/>
<loop class="Thelia\Core\Template\Loop\Country" name="country"/>

View File

@@ -1168,6 +1168,43 @@
<default key="_controller">Thelia\Controller\Admin\CustomerExportController::newsletterExportAction</default>
</route>
<!-- Routes to the Brands controller -->
<route id="admin.brand.default" path="/admin/brand">
<default key="_controller">Thelia\Controller\Admin\BrandController::defaultAction</default>
</route>
<route id="admin.brand.create" path="/admin/brand/create">
<default key="_controller">Thelia\Controller\Admin\BrandController::createAction</default>
</route>
<route id="admin.brand.update" path="/admin/brand/update/{brand_id}">
<default key="_controller">Thelia\Controller\Admin\BrandController::updateAction</default>
<requirement key="brand_id">\d+</requirement>
</route>
<route id="admin.brand.save" path="/admin/brand/save/{brand_id}">
<default key="_controller">Thelia\Controller\Admin\BrandController::processUpdateAction</default>
<requirement key="brand_id">\d+</requirement>
</route>
<route id="admin.brand.seo.save" path="/admin/brand/seo/save">
<default key="_controller">Thelia\Controller\Admin\BrandController::processUpdateSeoAction</default>
</route>
<route id="admin.brand.toggle-online" path="/admin/brand/toggle-online">
<default key="_controller">Thelia\Controller\Admin\BrandController::setToggleVisibilityAction</default>
</route>
<route id="admin.brand.update-position" path="/admin/brand/update-position">
<default key="_controller">Thelia\Controller\Admin\BrandController::updatePositionAction</default>
</route>
<route id="admin.brand.delete" path="/admin/brand/delete">
<default key="_controller">Thelia\Controller\Admin\BrandController::deleteAction</default>
</route>
<!-- The default route, to display a template -->
<route id="admin.processTemplate" path="/admin/{template}">

View File

@@ -52,6 +52,7 @@
<argument type="service" id="request"/>
<argument type="service" id="thelia.parser.context"/>
<argument type="service" id="thelia.parser"/>
<call method="setFormDefinition">
<argument>%thelia.parser.forms%</argument>

View File

@@ -329,12 +329,12 @@ class BaseAdminController extends BaseController
* 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 $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 string $objectName the object name (e.g. 'attribute', 'message')
* @param string $requestParameterName the name of the request parameter that defines the list order
* @param string $defaultListOrder the default order to use, if none is defined
* @param bool $updateSession if true, the session will be updated with the current order.
*
* @return String the current liste order.
* @return String the current list order.
*/
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true)
{

View File

@@ -0,0 +1,281 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Brand\BrandCreateEvent;
use Thelia\Core\Event\Brand\BrandDeleteEvent;
use Thelia\Core\Event\Brand\BrandEvent;
use Thelia\Core\Event\Brand\BrandToggleVisibilityEvent;
use Thelia\Core\Event\Brand\BrandUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Form\Brand\BrandCreationForm;
use Thelia\Form\Brand\BrandModificationForm;
use Thelia\Model\Brand;
use Thelia\Model\BrandQuery;
/**
* Class BrandController
* @package Thelia\Controller\Admin
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandController extends AbstractSeoCrudController
{
public function __construct()
{
parent::__construct(
'brand',
'manual',
'order',
AdminResources::BRAND,
TheliaEvents::BRAND_CREATE,
TheliaEvents::BRAND_UPDATE,
TheliaEvents::BRAND_DELETE,
TheliaEvents::BRAND_TOGGLE_VISIBILITY,
TheliaEvents::BRAND_UPDATE_POSITION,
TheliaEvents::BRAND_UPDATE_SEO
);
}
/**
* Return the creation form for this object
*/
protected function getCreationForm()
{
return new BrandCreationForm($this->getRequest());
}
/**
* Return the update form for this object
*/
protected function getUpdateForm()
{
return new BrandModificationForm($this->getRequest());
}
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param Brand $object
* @return BrandModificationForm $object
*/
protected function hydrateObjectForm($object)
{
// Hydrate the "SEO" tab form
$this->hydrateSeoForm($object);
// Prepare the data that will hydrate the form
$data = [
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'chapo' => $object->getChapo(),
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum(),
'visible' => $object->getVisible() ? true : false,
'logo_image_id' => $object->getLogoImageId()
];
// Setup the object form
return new BrandModificationForm($this->getRequest(), "form", $data);
}
/**
* Creates the creation event with the provided form data
*
* @param array $formData
* @return BrandCreateEvent
*/
protected function getCreationEvent($formData)
{
$brandCreateEvent = new BrandCreateEvent();
$brandCreateEvent
->setLocale($formData['locale'])
->setTitle($formData['title'])
->setVisible($formData['visible'])
;
return $brandCreateEvent;
}
/**
* Creates the update event with the provided form data
*
* @param array $formData
* @return BrandUpdateEvent
*/
protected function getUpdateEvent($formData)
{
$brandUpdateEvent = new BrandUpdateEvent($formData['id']);
$brandUpdateEvent
->setLogoImageId($formData['logo_image_id'])
->setVisible($formData['visible'])
->setLocale($formData['locale'])
->setTitle($formData['title'])
->setChapo($formData['chapo'])
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
;
return $brandUpdateEvent;
}
/**
* Creates the delete event with the provided form data
*
* @return BrandDeleteEvent
*/
protected function getDeleteEvent()
{
return new BrandDeleteEvent($this->getRequest()->get('brand_id'));
}
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param BrandEvent $event
* @return bool
*/
protected function eventContainsObject($event)
{
return $event->hasBrand();
}
/**
* Get the created object from an event.
*
* @param $event \Thelia\Core\Event\Brand\BrandEvent
*
* @return null|\Thelia\Model\Brand
*/
protected function getObjectFromEvent($event)
{
return $event->getBrand();
}
/**
* Load an existing object from the database
*
* @return \Thelia\Model\Brand
*/
protected function getExistingObject()
{
$brand = BrandQuery::create()
->findOneById($this->getRequest()->get('brand_id', 0));
if (null !== $brand) {
$brand->setLocale($this->getCurrentEditionLocale());
}
return $brand;
}
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param $object \Thelia\Model\Brand
*
* @return string brand title
*/
protected function getObjectLabel($object)
{
return $object->getTitle();
}
/**
* Returns the object ID from the object
*
* @param $object \Thelia\Model\Brand
*
* @return int brand id
*/
protected function getObjectId($object)
{
return $object->getId();
}
/**
* Render the main list template
*
* @param string $currentOrder, if any, null otherwise.
*
* @return Response
*/
protected function renderListTemplate($currentOrder)
{
$this->getListOrderFromSession('brand', 'order', 'manual');
return $this->render('brands', [
'order' => $currentOrder,
]);
}
protected function getEditionArguments()
{
return [
'brand_id' => $this->getRequest()->get('brand_id', 0),
'current_tab' => $this->getRequest()->get('current_tab', 'general')
];
}
/**
* Render the edition template
*/
protected function renderEditionTemplate()
{
return $this->render('brand-edit', $this->getEditionArguments());
}
/**
* Redirect to the edition template
*/
protected function redirectToEditionTemplate()
{
$this->redirect($this->getRoute('admin.brand.update', $this->getEditionArguments()));
}
/**
* Redirect to the list template
*/
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.brand.default');
}
/**
* @return BrandToggleVisibilityEvent|void
*/
protected function createToggleVisibilityEvent()
{
return new BrandToggleVisibilityEvent($this->getExistingObject());
}
/**
* @inheritdoc
*/
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('brand_id', null),
$positionChangeMode,
$positionValue
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -164,6 +164,7 @@ class ProductController extends AbstractSeoCrudController
->setPostscriptum($formData['postscriptum'])
->setVisible($formData['visible'])
->setDefaultCategory($formData['default_category'])
->setBrandId($formData['brand_id'])
;
// Create and dispatch the change event
@@ -213,6 +214,10 @@ class ProductController extends AbstractSeoCrudController
$array[$key][] = $value;
}
/**
* @param Product $object
* @return ProductModificationForm
*/
protected function hydrateObjectForm($object)
{
// Find product's sale elements
@@ -320,7 +325,8 @@ class ProductController extends AbstractSeoCrudController
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum(),
'visible' => $object->getVisible(),
'default_category' => $object->getDefaultCategoryId()
'default_category' => $object->getDefaultCategoryId(),
'brand_id' => $object->getBrandId()
);
// Setup the object form

View File

@@ -15,6 +15,7 @@ namespace Thelia\Controller\Front;
use Symfony\Component\Routing\Router;
use Thelia\Controller\BaseController;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\TemplateDefinition;
use Thelia\Core\Template\TemplateHelper;
use Thelia\Model\AddressQuery;
@@ -30,17 +31,30 @@ class BaseFrontController extends BaseController
*
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
*/
/**
* Return the route path defined for the givent route ID
*
* @param string $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param array $parameters the Route parameters, as a var/value pair array
* @param bool $referenceType Router::ABSOLUTE_PATH or Router::ABSOLUTE_URL
*
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
*
* @return string the route path
*/
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType);
}
/**
* Redirect to à route ID related URL
* Redirect to a specific route.
*
* @param string $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param array $urlParameters the URL parametrs, as a var/value pair array
* @param bool $referenceType
* @param string $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param array $urlParameters the URL parameters, as a var/value pair array
* @param array $routeParameters the Route parameters, as a var/value pair array
* @param bool $referenceType Router::ABSOLUTE_PATH or Router::ABSOLUTE_URL
*/
public function redirectToRoute($routeId, array $urlParameters = [], array $routeParameters = [], $referenceType = Router::ABSOLUTE_PATH)
{
@@ -95,7 +109,9 @@ class BaseFrontController extends BaseController
}
/**
* @return TemplateDefinition the template
* @param TemplateDefinition $template the template to process, or null for using the front template
*
* @return ParserInterface the Thelia parser²
*/
protected function getParser($template = null)
{
@@ -123,9 +139,9 @@ class BaseFrontController 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 null $templateDir
* @param string $templateName the complete template name, with extension
* @param array $args the template arguments
* @param string$templateDir
*
* @return string
*/

View File

@@ -0,0 +1,85 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\Brand;
/**
* Class BrandCreateEvent
* @package Thelia\Core\Event\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandCreateEvent extends BrandEvent
{
protected $title;
protected $locale;
protected $visible;
/**
* @param string $locale
*
* @return BrandCreateEvent $this
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* @return string
*/
public function getLocale()
{
return $this->locale;
}
/**
* @param string $title
*
* @return BrandCreateEvent $this
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param bool $visible
*
* @return BrandCreateEvent $this
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* @return bool
*/
public function getVisible()
{
return $this->visible;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\Brand;
/**
* Class BrandDeleteEvent
* @package Thelia\Core\Event\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandDeleteEvent extends BrandEvent
{
protected $brand_id;
public function __construct($brand_id)
{
$this->brand_id = $brand_id;
}
/**
* @param int $brand_id
*
* @return BrandDeleteEvent $this
*/
public function setBrandId($brand_id)
{
$this->brand_id = $brand_id;
return $this;
}
/**
* @return int
*/
public function getBrandId()
{
return $this->brand_id;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\Brand;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Brand;
/**
* Class BrandEvent
* @package Thelia\Core\Event\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandEvent extends ActionEvent
{
/**
* @var \Thelia\Model\Brand
*/
protected $brand;
public function __construct(Brand $brand = null)
{
$this->brand = $brand;
}
/**
* @param \Thelia\Model\Brand $brand
* @return BrandEvent
*/
public function setBrand(Brand $brand)
{
$this->brand = $brand;
return $this;
}
/**
* @return \Thelia\Model\Brand
*/
public function getBrand()
{
return $this->brand;
}
/**
* check if brand exists
*
* @return bool
*/
public function hasBrand()
{
return null !== $this->brand;
}
}

View File

@@ -0,0 +1,22 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\Brand;
/**
* Class BrandToggleVisibilityEvent
* @package Thelia\Core\Event\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandToggleVisibilityEvent extends BrandEvent
{
}

View File

@@ -0,0 +1,135 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\Brand;
/**
* Class BrandUpdateEvent
* @package Thelia\Core\Event\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandUpdateEvent extends BrandCreateEvent
{
protected $brandId;
protected $chapo;
protected $description;
protected $postscriptum;
protected $logo_image_id;
/**
* @param int $brandId
*/
public function __construct($brandId)
{
$this->brandId = $brandId;
}
/**
* @param string $chapo
*
* @return BrandUpdateEvent $this
*/
public function setChapo($chapo)
{
$this->chapo = $chapo;
return $this;
}
/**
* @return string
*/
public function getChapo()
{
return $this->chapo;
}
/**
* @param int $brandId
*
* @return BrandUpdateEvent $this
*/
public function setBrandId($brandId)
{
$this->brandId = $brandId;
return $this;
}
/**
* @return int
*/
public function getBrandId()
{
return $this->brandId;
}
/**
* @param string $description
*
* @return BrandUpdateEvent $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $postscriptum
*
* @return BrandUpdateEvent $this
*/
public function setPostscriptum($postscriptum)
{
$this->postscriptum = $postscriptum;
return $this;
}
/**
* @return string
*/
public function getPostscriptum()
{
return $this->postscriptum;
}
/**
* @param int $logo_image_id
* @return $this
*/
public function setLogoImageId($logo_image_id)
{
$this->logo_image_id = $logo_image_id;
return $this;
}
/**
* @return int
*/
public function getLogoImageId()
{
return $this->logo_image_id;
}
}

View File

@@ -11,196 +11,121 @@
/*************************************************************************************/
namespace Thelia\Core\Event\Document;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\CategoryDocument;
use Thelia\Model\ContentDocument;
use Thelia\Model\FolderDocument;
use Thelia\Model\ProductDocument;
use Thelia\Core\Event\File\FileCreateOrUpdateEvent;
use Thelia\Files\FileModelInterface;
/**
* Created by JetBrains PhpStorm.
* Date: 9/18/13
* Time: 3:56 PM
*
* Occurring when a Document is saved
* Occurring when an Document is saved
*
* @package Document
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
class DocumentCreateOrUpdateEvent extends ActionEvent
class DocumentCreateOrUpdateEvent extends FileCreateOrUpdateEvent
{
/** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument model to save */
protected $modelDocument = array();
/** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument model to save */
protected $oldModelDocument = array();
/** @var UploadedFile Document file to save */
protected $uploadedFile = null;
/** @var int Document parent id */
protected $parentId = null;
/** @var string Document type */
protected $documentType = null;
/** @var string Parent name */
protected $parentName = null;
/**
* Constructor
*
* @param string $documentType Document type
* ex : FileManager::TYPE_CATEGORY
* @param int $parentId Document parent id
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function __construct($documentType, $parentId)
{
$this->documentType = $documentType;
$this->parentId = $parentId;
parent::__construct($parentId);
}
/**
* @param mixed $locale
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setLocale($locale)
{
return $this;
}
/**
* @return mixed
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getLocale()
{
throw new \RuntimeException("getLocale() is deprecated and no longer supported");
}
/**
* Set Document to save
*
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $document Document to save
* @param $document FileModelInterface
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setModelDocument($document)
{
$this->modelDocument = $document;
return $this;
parent::setModel($document);
}
/**
* Get Document being saved
*
* @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument
* @return FileModelInterface
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getModelDocument()
{
return $this->modelDocument;
return parent::getModel();
}
/**
* Set document type
* Set picture type
*
* @param string $documentType Document type
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setDocumentType($documentType)
{
$this->documentType = $documentType;
return $this;
}
/**
* Get document type
* Get picture type
*
* @return string
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getDocumentType()
{
return $this->documentType;
}
/**
* Set Document parent id
*
* @param int $parentId Document parent id
*
* @return $this
*/
public function setParentId($parentId)
{
$this->parentId = $parentId;
return $this;
}
/**
* Get Document parent id
*
* @return int
*/
public function getParentId()
{
return $this->parentId;
}
/**
* Set uploaded file
*
* @param UploadedFile $uploadedFile File being uploaded
*
* @return $this
*/
public function setUploadedFile($uploadedFile)
{
$this->uploadedFile = $uploadedFile;
return $this;
}
/**
* Get uploaded file
*
* @return UploadedFile
*/
public function getUploadedFile()
{
return $this->uploadedFile;
}
/**
* Set parent name
*
* @param string $parentName Parent name
*
* @return $this
*/
public function setParentName($parentName)
{
$this->parentName = $parentName;
return $this;
}
/**
* Get parent name
*
* @return string
*/
public function getParentName()
{
return $this->parentName;
throw new \RuntimeException("getDocumentType() is deprecated and no longer supported");
}
/**
* Set old model value
*
* @param CategoryDocument|ContentDocument|FolderDocument|ProductDocument $oldModelDocument
* @param FileModelInterface $oldModelDocument
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setOldModelDocument($oldModelDocument)
{
$this->oldModelDocument = $oldModelDocument;
parent::setOldModel($oldModelDocument);
}
/**
* Get old model value
*
* @return CategoryDocument|ContentDocument|FolderDocument|ProductDocument
* @return FileModelInterface
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getOldModelDocument()
{
return $this->oldModelDocument;
return parent::getOldModel();
}
}

View File

@@ -12,7 +12,7 @@
namespace Thelia\Core\Event\Document;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\File\FileDeleteEvent;
use Thelia\Model\CategoryDocument;
use Thelia\Model\ContentDocument;
use Thelia\Model\FolderDocument;
@@ -27,27 +27,21 @@ use Thelia\Model\ProductDocument;
*
* @package Document
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
class DocumentDeleteEvent extends ActionEvent
class DocumentDeleteEvent extends FileDeleteEvent
{
/** @var string Document type */
protected $documentType = null;
/** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument Document about to be deleted */
protected $documentToDelete = null;
/**
* Constructor
*
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted
* @param string $documentType Document type
* ex : FileManager::TYPE_CATEGORY
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function __construct($documentToDelete, $documentType)
{
$this->documentToDelete = $documentToDelete;
$this->documentType = $documentType;
parent::__construct($documentToDelete);
}
/**
@@ -56,11 +50,10 @@ class DocumentDeleteEvent extends ActionEvent
* @param string $documentType Document type
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function setDocumentType($documentType)
{
$this->documentType = $documentType;
return $this;
}
@@ -68,10 +61,11 @@ class DocumentDeleteEvent extends ActionEvent
* Get picture type
*
* @return string
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function getDocumentType()
{
return $this->documentType;
throw new \RuntimeException("getDocumentType() is deprecated and no longer supported");
}
/**
@@ -80,10 +74,11 @@ class DocumentDeleteEvent extends ActionEvent
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function setDocumentToDelete($documentToDelete)
{
$this->documentToDelete = $documentToDelete;
parent::setFileToDelete($documentToDelete);
return $this;
}
@@ -92,10 +87,11 @@ class DocumentDeleteEvent extends ActionEvent
* Get Document about to be deleted
*
* @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function getDocumentToDelete()
{
return $this->documentToDelete;
return parent::getFileToDelete();
}
}

View File

@@ -0,0 +1,168 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Core\Event\ActionEvent;
use Thelia\Files\FileModelInterface;
/**
* Event fired when a file is created or updated.
*
* @package Thelia\Core\Event\Document
* @author Franck Allimant <franck@cqfdev.fr>
*
*/
class FileCreateOrUpdateEvent extends ActionEvent
{
/** @var FileModelInterface model to save */
protected $model = array();
/** @var FileModelInterface model to save */
protected $oldModel = array();
/** @var UploadedFile Document file to save */
protected $uploadedFile = null;
/** @var int Document parent id */
protected $parentId = null;
/** @var string Parent name */
protected $parentName = null;
/**
* Constructor
*
* @param int $parentId file parent id
*/
public function __construct($parentId)
{
$this->parentId = $parentId;
}
/**
* Set file to save
*
* @param FileModelInterface $model Document to save
*
* @return $this
*/
public function setModel($model)
{
$this->model = $model;
return $this;
}
/**
* Get file being saved
*
* @return FileModelInterface
*/
public function getModel()
{
return $this->model;
}
/**
* Set Document parent id
*
* @param int $parentId Document parent id
*
* @return $this
*/
public function setParentId($parentId)
{
$this->parentId = $parentId;
return $this;
}
/**
* Get Document parent id
*
* @return int
*/
public function getParentId()
{
return $this->parentId;
}
/**
* Set uploaded file
*
* @param UploadedFile $uploadedFile File being uploaded
*
* @return $this
*/
public function setUploadedFile($uploadedFile)
{
$this->uploadedFile = $uploadedFile;
return $this;
}
/**
* Get uploaded file
*
* @return UploadedFile
*/
public function getUploadedFile()
{
return $this->uploadedFile;
}
/**
* Set parent name
*
* @param string $parentName Parent name
*
* @return $this
*/
public function setParentName($parentName)
{
$this->parentName = $parentName;
return $this;
}
/**
* Get parent name
*
* @return string
*/
public function getParentName()
{
return $this->parentName;
}
/**
* Set old model value
*
* @param FileModelInterface $oldModel
*/
public function setOldModel($oldModel)
{
$this->oldModel = $oldModel;
}
/**
* Get old model value
*
* @return FileModelInterface
*/
public function getOldModel()
{
return $this->oldModel;
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\File;
use Thelia\Core\Event\ActionEvent;
use Thelia\Files\FileModelInterface;
/**
* Event fired when a file is about to be deleted
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class FileDeleteEvent extends ActionEvent
{
/** @var FileModelInterface Image about to be deleted */
protected $fileToDelete = null;
/**
* Constructor
*
* @param FileModelInterface $fileToDelete Image about to be deleted
*/
public function __construct($fileToDelete)
{
$this->fileToDelete = $fileToDelete;
}
/**
* Set Image about to be deleted
*
* @param FileModelInterface $fileToDelete Image about to be deleted
*
* @return $this
*/
public function setFileToDelete($fileToDelete)
{
$this->fileToDelete = $fileToDelete;
return $this;
}
/**
* Get Image about to be deleted
*
* @return FileModelInterface
*/
public function getFileToDelete()
{
return $this->fileToDelete;
}
}

View File

@@ -11,8 +11,9 @@
/*************************************************************************************/
namespace Thelia\Core\Event\Image;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\File\FileCreateOrUpdateEvent;
use Thelia\Files\FileModelInterface;
/**
* Created by JetBrains PhpStorm.
@@ -23,84 +24,63 @@ use Thelia\Core\Event\ActionEvent;
*
* @package Image
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
class ImageCreateOrUpdateEvent extends ActionEvent
class ImageCreateOrUpdateEvent extends FileCreateOrUpdateEvent
{
/** @var \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage model to save */
protected $modelImage = array();
/** @var \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage model to save */
protected $oldModelImage = array();
/** @var UploadedFile Image file to save */
protected $uploadedFile = null;
/** @var int Image parent id */
protected $parentId = null;
/** @var string Image type */
protected $imageType = null;
/** @var string Parent name */
protected $parentName = null;
protected $locale;
/**
* Constructor
*
* @param string $imageType Image type
* ex : FileManager::TYPE_CATEGORY
* @param int $parentId Image parent id
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function __construct($imageType, $parentId)
{
$this->imageType = $imageType;
$this->parentId = $parentId;
parent::__construct($parentId);
}
/**
* @param mixed $locale
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* @return mixed
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getLocale()
{
return $this->locale;
throw new \RuntimeException("getLocale() is deprecated and no longer supported");
}
/**
* Set Image to save
*
* @param $image \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage
* @param $image FileModelInterface
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setModelImage($image)
{
$this->modelImage = $image;
return $this;
parent::setModel($image);
}
/**
* Get Image being saved
*
* @return \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage
* @return FileModelInterface
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getModelImage()
{
return $this->modelImage;
return parent::getModel();
}
/**
@@ -109,11 +89,10 @@ class ImageCreateOrUpdateEvent extends ActionEvent
* @param string $imageType Image type
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setImageType($imageType)
{
$this->imageType = $imageType;
return $this;
}
@@ -121,102 +100,32 @@ class ImageCreateOrUpdateEvent extends ActionEvent
* Get picture type
*
* @return string
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getImageType()
{
return $this->imageType;
}
/**
* Set Image parent id
*
* @param int $parentId Image parent id
*
* @return $this
*/
public function setParentId($parentId)
{
$this->parentId = $parentId;
return $this;
}
/**
* Get Image parent id
*
* @return int
*/
public function getParentId()
{
return $this->parentId;
}
/**
* Set uploaded file
*
* @param UploadedFile $uploadedFile File being uploaded
*
* @return $this
*/
public function setUploadedFile($uploadedFile)
{
$this->uploadedFile = $uploadedFile;
return $this;
}
/**
* Get uploaded file
*
* @return UploadedFile
*/
public function getUploadedFile()
{
return $this->uploadedFile;
}
/**
* Set parent name
*
* @param string $parentName Parent name
*
* @return $this
*/
public function setParentName($parentName)
{
$this->parentName = $parentName;
return $this;
}
/**
* Get parent name
*
* @return string
*/
public function getParentName()
{
return $this->parentName;
throw new \RuntimeException("getImageType() is deprecated and no longer supported");
}
/**
* Set old model value
*
* @param \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage $oldModelImage
* @param FileModelInterface $oldModelImage
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function setOldModelImage($oldModelImage)
{
$this->oldModelImage = $oldModelImage;
parent::setOldModel($oldModelImage);
}
/**
* Get old model value
*
* @return \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
* @return FileModelInterface
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
*/
public function getOldModelImage()
{
return $this->oldModelImage;
return parent::getOldModel();
}
}

View File

@@ -12,7 +12,6 @@
namespace Thelia\Core\Event\Image;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\CategoryImage;
use Thelia\Model\ContentImage;
use Thelia\Model\FolderImage;
@@ -27,27 +26,21 @@ use Thelia\Model\ProductImage;
*
* @package Image
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
class ImageDeleteEvent extends ActionEvent
class ImageDeleteEvent extends FileDeleteEvent
{
/** @var string Image type */
protected $imageType = null;
/** @var CategoryImage|ProductImage|ContentImage|FolderImage Image about to be deleted */
protected $imageToDelete = null;
/**
* Constructor
*
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted
* @param string $imageType Image type
* ex : FileManager::TYPE_CATEGORY
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function __construct($imageToDelete, $imageType)
{
$this->imageToDelete = $imageToDelete;
$this->imageType = $imageType;
parent::__construct($imageToDelete);
}
/**
@@ -56,11 +49,10 @@ class ImageDeleteEvent extends ActionEvent
* @param string $imageType Image type
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function setImageType($imageType)
{
$this->imageType = $imageType;
return $this;
}
@@ -68,10 +60,11 @@ class ImageDeleteEvent extends ActionEvent
* Get picture type
*
* @return string
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function getImageType()
{
return $this->imageType;
throw new \RuntimeException("getImageType() is deprecated and no longer supported");
}
/**
@@ -80,10 +73,11 @@ class ImageDeleteEvent extends ActionEvent
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted
*
* @return $this
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function setImageToDelete($imageToDelete)
{
$this->imageToDelete = $imageToDelete;
parent::setFileToDelete($imageToDelete);
return $this;
}
@@ -92,10 +86,11 @@ class ImageDeleteEvent extends ActionEvent
* Get Image about to be deleted
*
* @return CategoryImage|ProductImage|ContentImage|FolderImage
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
*/
public function getImageToDelete()
{
return $this->imageToDelete;
return parent::getFileToDelete();
}
}

View File

@@ -12,6 +12,7 @@
namespace Thelia\Core\Event\Image;
use Imagine\Image\ImageInterface;
use Thelia\Core\Event\CachedFileEvent;
class ImageEvent extends CachedFileEvent
@@ -71,6 +72,11 @@ class ImageEvent extends CachedFileEvent
*/
protected $quality = null;
/**
* @var ImageInterface
*/
protected $imageObject;
/**
* @return boolean true if the required image is the original image (resize_mode and background_color are not significant)
*/
@@ -209,4 +215,23 @@ class ImageEvent extends CachedFileEvent
return $this;
}
/**
* @param ImageInterface $imageObject
* @return $this
*/
public function setImageObject($imageObject)
{
$this->imageObject = $imageObject;
return $this;
}
/**
* @return ImageInterface
*/
public function getImageObject()
{
return $this->imageObject;
}
}

View File

@@ -19,6 +19,7 @@ class ProductUpdateEvent extends ProductCreateEvent
protected $chapo;
protected $description;
protected $postscriptum;
protected $brand_id;
public function __construct($product_id)
{
@@ -72,4 +73,23 @@ class ProductUpdateEvent extends ProductCreateEvent
return $this;
}
/**
* @param int $brand_id
* @return $this
*/
public function setBrandId($brand_id)
{
$this->brand_id = $brand_id;
return $this;
}
/**
* @return int
*/
public function getBrandId()
{
return $this->brand_id;
}
}

View File

@@ -382,6 +382,16 @@ final class TheliaEvents
*/
const IMAGE_PROCESS = "action.processImage";
/**
* Sent just after creating the image object from the image file
*/
const IMAGE_PREPROCESSING = "action.preProcessImage";
/**
* Sent just before saving the processed image object on disk
*/
const IMAGE_POSTPROCESSING = "action.postProcessImage";
/**
* Sent on document processing
*/
@@ -736,4 +746,24 @@ final class TheliaEvents
const BEFORE_DELETELANG = 'action.lang.beforeDelete';
const AFTER_DELETELANG = 'action.lang.afterDelete';
// -- Brands management -----------------------------------------------
const BRAND_CREATE = "action.createBrand";
const BRAND_UPDATE = "action.updateBrand";
const BRAND_DELETE = "action.deleteBrand";
const BRAND_UPDATE_POSITION = "action.updateBrandPosition";
const BRAND_TOGGLE_VISIBILITY = "action.toggleBrandVisibility";
const BRAND_UPDATE_SEO = "action.updateBrandSeo";
const BEFORE_CREATEBRAND = "action.before_createBrand";
const AFTER_CREATEBRAND = "action.after_createBrand";
const BEFORE_DELETEBRAND = "action.before_deleteBrand";
const AFTER_DELETEBRAND = "action.after_deleteBrand";
const BEFORE_UPDATEBRAND = "action.before_updateBrand";
const AFTER_UPDATEBRAND = "action.after_updateBrand";
}

View File

@@ -51,6 +51,8 @@ final class AdminResources
const ATTRIBUTE = "admin.configuration.attribute";
const BRAND = "admin.brand";
const CATEGORY = "admin.category";
const CONFIG = "admin.configuration";

View File

@@ -536,4 +536,4 @@ abstract class BaseLoop
*/
abstract protected function getArgDefinitions();
}
}

View File

@@ -0,0 +1,211 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Element\SearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\BrandQuery;
use Thelia\Model\ProductQuery;
use Thelia\Type\BooleanOrBothType;
use Thelia\Type;
use Thelia\Type\TypeCollection;
/**
*
* Brand loop
*
*
* Class Brand
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Brand extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoopInterface
{
protected $timestampable = true;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createIntTypeArgument('product'),
Argument::createBooleanOrBothTypeArgument('visible', 1),
Argument::createAnyTypeArgument('title'),
Argument::createBooleanTypeArgument('current'),
new Argument(
'order',
new TypeCollection(
new Type\EnumListType(
array(
'id',
'id-reverse',
'alpha',
'alpha-reverse',
'manual',
'manual-reverse',
'random',
'created',
'created-reverse',
'updated',
'updated-reverse'
)
)
),
'alpha'
),
Argument::createIntListTypeArgument('exclude')
);
}
/**
* @return array of available field to search in
*/
public function getSearchIn()
{
return [
"title"
];
}
public function doSearch(&$search, $searchTerm, $searchIn, $searchCriteria)
{
$search->_and();
$search->where("CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END ".$searchCriteria." ?", $searchTerm, \PDO::PARAM_STR);
}
public function buildModelCriteria()
{
$search = BrandQuery::create();
/* manage translations */
$this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS'));
$id = $this->getId();
if (!is_null($id)) {
$search->filterById($id, Criteria::IN);
}
$product = $this->getProduct();
if (!is_null($product) && null !== $productObj = ProductQuery::create()->findPk($product)) {
$search->filterByProduct($productObj);
}
$visible = $this->getVisible();
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
$title = $this->getTitle();
if (!is_null($title)) {
$search->where("CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END ".Criteria::LIKE." ?", "%".$title."%", \PDO::PARAM_STR);
}
$current = $this->getCurrent();
if ($current === true) {
$search->filterById($this->request->get("brand_id"));
} elseif ($current === false) {
$search->filterById($this->request->get("brand_id"), Criteria::NOT_IN);
}
$orders = $this->getOrder();
foreach ($orders as $order) {
switch ($order) {
case 'id':
$search->orderById(Criteria::ASC);
break;
case 'id-reverse':
$search->orderById(Criteria::DESC);
break;
case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE');
break;
case "alpha-reverse":
$search->addDescendingOrderByColumn('i18n_TITLE');
break;
case "manual":
$search->orderByPosition(Criteria::ASC);
break;
case "manual-reverse":
$search->orderByPosition(Criteria::DESC);
break;
case "random":
$search->clearOrderByColumns();
$search->addAscendingOrderByColumn('RAND()');
break(2);
case "created":
$search->addAscendingOrderByColumn('created_at');
break;
case "created-reverse":
$search->addDescendingOrderByColumn('created_at');
break;
case "updated":
$search->addAscendingOrderByColumn('updated_at');
break;
case "updated-reverse":
$search->addDescendingOrderByColumn('updated_at');
break;
}
}
$exclude = $this->getExclude();
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
return $search;
}
public function parseResults(LoopResult $loopResult)
{
/** @var \Thelia\Model\Brand $brand */
foreach ($loopResult->getResultDataCollection() as $brand) {
$loopResultRow = new LoopResultRow($brand);
$loopResultRow->set("ID" , $brand->getId())
->set("IS_TRANSLATED" , $brand->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $this->locale)
->set("TITLE" , $brand->getVirtualColumn('i18n_TITLE'))
->set("CHAPO" , $brand->getVirtualColumn('i18n_CHAPO'))
->set("DESCRIPTION" , $brand->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM" , $brand->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("URL" , $brand->getUrl($this->locale))
->set("META_TITLE" , $brand->getVirtualColumn('i18n_META_TITLE'))
->set("META_DESCRIPTION" , $brand->getVirtualColumn('i18n_META_DESCRIPTION'))
->set("META_KEYWORDS" , $brand->getVirtualColumn('i18n_META_KEYWORDS'))
->set("POSITION" , $brand->getPosition())
->set("VISIBLE" , $brand->getVisible())
->set("LOGO_IMAGE_ID" , $brand->getLogoImageId() ?: 0)
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -15,7 +15,6 @@ namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;

View File

@@ -23,7 +23,6 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Type\EnumType;
use Thelia\Log\Tlog;
/**
@@ -39,9 +38,9 @@ class Document extends BaseI18nLoop implements PropelSearchLoopInterface
protected $timestampable = true;
/**
* @var array Possible document sources
* @var array Possible standard document sources
*/
protected $possible_sources = array('category', 'product', 'folder', 'content');
protected $possible_sources = array('category', 'product', 'folder', 'content', 'brand');
/**
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
@@ -66,12 +65,8 @@ class Document extends BaseI18nLoop implements PropelSearchLoopInterface
Argument::createIntTypeArgument('folder'),
Argument::createIntTypeArgument('content'),
new Argument(
'source',
new TypeCollection(
new EnumType($this->possible_sources)
)
),
Argument::createAnyTypeArgument('source'),
Argument::createIntTypeArgument('source_id'),
Argument::createBooleanTypeArgument('force_return', true)
);

View File

@@ -39,9 +39,9 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface
protected $timestampable = true;
/**
* @var array Possible image sources
* @var array Possible standard image sources
*/
protected $possible_sources = array('category', 'product', 'folder', 'content', 'module');
protected $possible_sources = array('category', 'product', 'folder', 'content', 'module', 'brand');
/**
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
@@ -80,12 +80,8 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface
Argument::createIntTypeArgument('folder'),
Argument::createIntTypeArgument('content'),
new Argument(
'source',
new TypeCollection(
new EnumType($this->possible_sources)
)
),
Argument::createAnyTypeArgument('source'),
Argument::createIntTypeArgument('source_id'),
Argument::createBooleanTypeArgument('force_return', true)
);
@@ -181,9 +177,11 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface
// Check for product="id" folder="id", etc. style arguments
foreach ($this->possible_sources as $source) {
$argValue = intval($this->getArgValue($source));
$argValue = $this->getArgValue($source);
if ($argValue > 0) {
if (! empty($argValue)) {
$argValue = intval($argValue);
$search = $this->createSearchQuery($source, $argValue);

View File

@@ -64,6 +64,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
)
),
Argument::createIntListTypeArgument('category'),
Argument::createIntListTypeArgument('brand'),
Argument::createIntListTypeArgument('category_default'),
Argument::createBooleanTypeArgument('new'),
Argument::createBooleanTypeArgument('promo'),
@@ -327,6 +328,12 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
$search->filterById($this->request->get("product_id"), Criteria::NOT_IN);
}
$brand_id = $this->getBrand();
if ($brand_id !== null) {
$search->filterByBrandId($brand_id, Criteria::IN);
}
$current_category = $this->getCurrent_category();
if ($current_category === true) {
@@ -460,6 +467,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
/** @var \Thelia\Core\Security\SecurityContext $securityContext */
$securityContext = $this->container->get('thelia.securityContext');
/** @var \Thelia\Model\Product $product */
foreach ($loopResult->getResultDataCollection() as $product) {
$loopResultRow = new LoopResultRow($product);
@@ -510,7 +518,6 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
->set("TAXED_PROMO_PRICE" , $taxedPromoPrice)
->set("IS_PROMO" , $product->getVirtualColumn('is_promo'))
->set("IS_NEW" , $product->getVirtualColumn('is_new'))
;
@@ -989,6 +996,12 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
return $loopResult;
}
/**
* @param $loopResultRow
* @param \Thelia\Model\Product $product
* @param $default_category_id
* @return mixed
*/
private function associateValues($loopResultRow, $product, $default_category_id)
{
$loopResultRow
@@ -1010,7 +1023,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
->set("TEMPLATE" , $product->getTemplateId())
->set("DEFAULT_CATEGORY" , $default_category_id)
->set("TAX_RULE_ID" , $product->getTaxRuleId())
->set("BRAND_ID" , $product->getBrandId() ?: 0)
;

View File

@@ -35,22 +35,32 @@ interface ParserInterface
*/
public function setTemplateDefinition(TemplateDefinition $templateDefinition);
/**
* Get template definition
*
* @param bool $webAssetTemplate Allow to load asset from another template
* If the name of the template if provided
*
* @return TemplateDefinition
*/
public function getTemplateDefinition($webAssetTemplate = false);
/**
* Add a template directory to the current template list
*
* @param unknown $templateType the template type (
* @param int $templateType the template type (
*
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param unknown $key ???
* @param string $unshift ??? Etienne ?
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param string $key ???
* @param bool $unshift ??? Etienne ?
*/
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false);
/**
* Return the registeted template directories for a givent template type
*
* @param unknown $templateType
* @param int $templateType
* @throws \InvalidArgumentException if the templateType is not defined
* @return array: an array of defined templates directories for the given template type
*/

View File

@@ -145,13 +145,13 @@ class AdminUtilities extends AbstractSmartyPlugin
/**
* Define the various smarty plugins handled by this class
*
* @return an array of smarty plugin descriptors
* @return array of smarty plugin descriptors
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('function', 'admin_sortable_header', $this, 'generateSortableColumnHeader'),
new SmartyPluginDescriptor('function', 'admin_position_block' , $this, 'generatePositionChangeBlock'),
new SmartyPluginDescriptor('function', 'admin_sortable_header' , $this, 'generateSortableColumnHeader'),
new SmartyPluginDescriptor('function', 'admin_position_block' , $this, 'generatePositionChangeBlock'),
);
}
}

View File

@@ -137,6 +137,19 @@ class DataAccessFunctions extends AbstractSmartyPlugin
}
}
public function brandDataAccess($params, &$smarty)
{
$contentId = $this->request->get('brand_id');
if ($contentId !== null) {
$search = ContentQuery::create()
->filterById($contentId);
return $this->dataAccessWithI18n("Brand", $params, $search);
}
}
/**
* currency global data
*
@@ -462,6 +475,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'category', $this, 'categoryDataAccess'),
new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'),
new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'),
new SmartyPluginDescriptor('function', 'brand', $this, 'brandDataAccess'),
new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'),
new SmartyPluginDescriptor('function', 'country', $this, 'countryDataAccess'),
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),

View File

@@ -12,17 +12,19 @@
namespace Thelia\Core\Template\Smarty\Plugins;
use Symfony\Component\Form\FormView;
use Thelia\Core\Form\Type\TheliaType;
use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\ParserContext;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
use Symfony\Component\Form\FormConfigInterface;
use Symfony\Component\Form\FormView;
use Thelia\Core\Form\Type\TheliaType;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Form\BaseForm;
/**
*
@@ -53,15 +55,22 @@ class Form extends AbstractSmartyPlugin
private static $taggedFieldsStack = null;
private static $taggedFieldsStackPosition = null;
/** @var Request $request */
protected $request;
/** @var ParserContext $parserContext */
protected $parserContext;
/** @var ParserInterface $parser */
protected $parser;
protected $formDefinition = array();
public function __construct(Request $request, ParserContext $parserContext)
public function __construct(Request $request, ParserContext $parserContext, ParserInterface $parser)
{
$this->request = $request;
$this->parserContext = $parserContext;
$this->parser = $parser;
}
public function setFormDefinition($formDefinition)
@@ -78,7 +87,6 @@ class Form extends AbstractSmartyPlugin
public function generateForm($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
$name = $this->getParam($params, 'name');
@@ -117,6 +125,14 @@ class Form extends AbstractSmartyPlugin
}
}
/**
* @param \Smarty_Internal_Template $template
* @param string $fieldName
* @param string $fieldValue
* @param string $fieldType
* @param array $fieldVars
* @param int $total_value_count
*/
protected function assignFieldValues(
$template,
$fieldName,
@@ -135,12 +151,14 @@ class Form extends AbstractSmartyPlugin
$template->assign("checked", isset($fieldVars['checked']) ? $fieldVars['checked'] : false);
$template->assign("choices", isset($fieldVars['choices']) ? $fieldVars['choices'] : false);
$template->assign("multiple", isset($fieldVars['multiple']) ? $fieldVars['multiple'] : false);
$template->assign("disabled", isset($fieldVars['disabled']) ? $fieldVars['disabled'] : false);
$template->assign("read_only", isset($fieldVars['read_only']) ? $fieldVars['read_only'] : false);
$template->assign("max_length", isset($fieldVars['max_length']) ? $fieldVars['max_length'] : false);
$template->assign('required', isset($fieldVars['required']) ? $fieldVars['required'] : false);
$template->assign("label", $fieldVars["label"]);
$template->assign("label_attr", $fieldVars["label_attr"]);
$template->assign('required', isset($fieldVars['required']) ? $fieldVars['required'] : false);
$template->assign('total_value_count', $total_value_count);
$errors = $fieldVars["errors"];
@@ -161,6 +179,11 @@ class Form extends AbstractSmartyPlugin
$template->assign("attr_list", $fieldVars["attr"]);
}
/**
* @param \Smarty_Internal_Template $template
* @param FormConfigInterface $formFieldConfig
* @param FormView $formFieldView
*/
protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView)
{
$formFieldType = $formFieldConfig->getType()->getInnerType();
@@ -202,58 +225,133 @@ class Form extends AbstractSmartyPlugin
}
}
/**
* @param array $params
* @param \Smarty_Internal_Template $template
*/
protected function processFormField($params, $template)
{
$formFieldView = $this->getFormFieldView($params);
$formFieldConfig = $this->getFormFieldConfig($params);
$formFieldType = $formFieldConfig->getType()->getName();
$this->assignFormTypeValues($template, $formFieldConfig, $formFieldView);
$value = $formFieldView->vars["value"];
$key = $this->getParam($params, 'value_key', null);
// We (may) have a collection
if ($key !== null) {
// Force array
if (! is_array($value)) $value = array();
// If the field is not found, use an empty value
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
$val = $value[$key];
$this->assignFieldValues(
$template,
$name,
$val,
$formFieldType,
$formFieldView->vars,
count($formFieldView->children)
);
} else {
$this->assignFieldValues(
$template,
$formFieldView->vars["full_name"],
$formFieldView->vars["value"],
$formFieldType,
$formFieldView->vars
);
}
$formFieldView->setRendered();
}
public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
$formFieldView = $this->getFormFieldView($params);
$formFieldConfig = $this->getFormFieldConfig($params);
$this->processFormField($params, $template);
$formFieldType = $formFieldConfig->getType()->getName();
$this->assignFormTypeValues($template, $formFieldConfig, $formFieldView);
$value = $formFieldView->vars["value"];
$key = $this->getParam($params, 'value_key', null);
// We (may) have a collection
if ($key !== null) {
// Force array
if (! is_array($value)) $value = array();
// If the field is not found, use an empty value
$val = array_key_exists($key, $value) ? $value[$key] : '';
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
$val = $value[$key];
$this->assignFieldValues(
$template,
$name,
$val,
$formFieldType,
$formFieldView->vars,
count($formFieldView->children)
);
} else {
$this->assignFieldValues(
$template,
$formFieldView->vars["full_name"],
$formFieldView->vars["value"],
$formFieldType,
$formFieldView->vars
);
}
$formFieldView->setRendered();
} else {
} else {
return $content;
}
}
/**
* @param array $params
* @param string $content
* @param \Smarty_Internal_Template $template
* @param string $templateTypeName
* @return string
*/
protected function automaticFormFieldRendering($params, $content, $template, $templateFile)
{
$data = '';
$templateStyle = $this->getParam($params, 'template', 'standard');
$snippet_path = sprintf('%s'.DS.'forms'.DS.'%s'.DS.'%s.html',
$this->parser->getTemplateDefinition()->getAbsolutePath(),
$templateStyle,
$templateFile
);
if (false !== $snippet_content = file_get_contents($snippet_path)) {
$this->processFormField($params, $template);
$form = $this->getParam($params, 'form', false);
$field_name = $this->getParam($params, 'field', false);
$field_extra_class = $this->getParam($params, 'extra_class', '');
$field_value = $this->getParam($params, 'value', '');
$template->assign([
'content' => trim($content),
'form' => $form,
'field_name' => $field_name,
'field_extra_class' => $field_extra_class,
'field_value' => $field_value,
'field_template' => $templateStyle
]);
$data = $template->fetch(sprintf('string:%s', $snippet_content));
}
return $data;
}
/**
* @param $params
* @param $content
* @param \Smarty_Internal_Template $template
* @param $repeat
* @return mixed
*/
public function customFormFieldRendering($params, $content, $template, &$repeat)
{
if (! $repeat) {
return $this->automaticFormFieldRendering($params, $content, $template, 'form-field-renderer');
}
}
public function standardFormFieldRendering($params, \Smarty_Internal_Template $template)
{
return $this->automaticFormFieldRendering($params, '', $template, 'form-field-renderer');
}
public function standardFormFieldAttributes($params, \Smarty_Internal_Template $template)
{
return $this->automaticFormFieldRendering($params, '', $template, 'form-field-attributes-renderer');
}
public function renderTaggedFormFields($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if (null === $content) {
@@ -297,13 +395,18 @@ class Form extends AbstractSmartyPlugin
$attrFormat = '%s="%s"';
$field = '<input type="hidden" name="%s" value="%s" %s>';
$instance = $this->getInstanceFromParams($params);
$baseFormInstance = $this->getInstanceFromParams($params);
$formView = $instance->getView();
$formView = $baseFormInstance->getView();
$return = "";
/** @var FormView $row */
foreach ($formView->getIterator() as $row) {
// We have to exclude the fields for which value is defined in the template.
if ($baseFormInstance->isTemplateDefinedHiddenField($row)) continue;
if ($this->isHidden($row) && $row->isRendered() === false) {
$attributeList = array();
if (isset($row->vars["attr"])) {
@@ -358,6 +461,11 @@ class Form extends AbstractSmartyPlugin
return array_search("hidden", $formView->vars["block_prefixes"]);
}
/**
* @param $params
* @return FormView
* @throws \InvalidArgumentException
*/
protected function getFormFieldView($params)
{
$instance = $this->getInstanceFromParams($params);
@@ -395,6 +503,11 @@ class Form extends AbstractSmartyPlugin
return $viewList;
}
/**
* @param $params
* @return FormConfigInterface
* @throws \InvalidArgumentException
*/
protected function getFormFieldConfig($params)
{
$instance = $this->getInstanceFromParams($params);
@@ -414,6 +527,11 @@ class Form extends AbstractSmartyPlugin
return $fieldData->getConfig();
}
/**
* @param $params
* @return BaseForm
* @throws \InvalidArgumentException
*/
protected function getInstanceFromParams($params)
{
$instance = $this->getParam($params, 'form');
@@ -443,7 +561,11 @@ class Form extends AbstractSmartyPlugin
new SmartyPluginDescriptor("block", "form_tagged_fields", $this, "renderTaggedFormFields"),
new SmartyPluginDescriptor("function", "form_hidden_fields", $this, "renderHiddenFormField"),
new SmartyPluginDescriptor("function", "form_enctype", $this, "formEnctype"),
new SmartyPluginDescriptor("block", "form_error", $this, "formError")
new SmartyPluginDescriptor("block", "form_error", $this, "formError"),
new SmartyPluginDescriptor("function", "form_field_attributes" , $this, "standardFormFieldAttributes"),
new SmartyPluginDescriptor("function", "render_form_field" , $this, "standardFormFieldRendering"),
new SmartyPluginDescriptor("block" , "custom_render_form_field", $this, "customFormFieldRendering"),
);
}
}

View File

@@ -24,6 +24,7 @@ use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\TemplateDefinition;
use Imagine\Exception\InvalidArgumentException;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ConfigQuery;
/**
*
@@ -95,17 +96,122 @@ class SmartyParser extends Smarty implements ParserInterface
// The default HTTP status
$this->status = 200;
$this->registerFilter('output', array($this, "removeBlankLines"));
$this->registerFilter('output', array($this, "trimWhitespaces"));
$this->registerFilter('variable', array(__CLASS__, "theliaEscape"));
}
/**
* Trim whitespaces from the HTML output, preserving required ones in pre, textarea, javascript.
* This methois uses 3 levels of trimming :
*
* - 0 : whitespaces are not trimmed, code remains as is.
* - 1 : only blank lines are trimmed, code remains indented and human-readable (the default)
* - 2 or more : all unnecessary whitespace are removed. Code is very hard to read.
*
* The trim level is defined by the configuration variable html_output_trim_level
*
* @param string $source the HTML source
* @param \Smarty_Internal_Template $template
* @return string
*/
public function trimWhitespaces($source, \Smarty_Internal_Template $template)
{
$compressionMode = ConfigQuery::read('html_output_trim_level', 1);
if ($compressionMode == 0) {
return $source;
}
$store = array();
$_store = 0;
$_offset = 0;
// Unify Line-Breaks to \n
$source = preg_replace("/\015\012|\015|\012/", "\n", $source);
// capture Internet Explorer Conditional Comments
if ($compressionMode == 1) {
$expressions = array(
// remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
'/(^[\n]*|[\n]+)[\s\t]*[\n]+/' => "\n"
);
} elseif ($compressionMode >= 2) {
if (preg_match_all('#<!--\[[^\]]+\]>.*?<!\[[^\]]+\]-->#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$store[] = $match[0][0];
$_length = strlen($match[0][0]);
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace);
$_store++;
}
}
// Strip all HTML-Comments
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
$source = preg_replace( '#<!--.*?-->#ms', '', $source );
$expressions = array(
// replace multiple spaces between tags by a single space
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
'#^\s+<#Ss' => '<',
'#>\s+$#Ss' => '>',
);
} else {
$expressions = array();
}
// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all('#<(script|pre|textarea)[^>]*>.*?</\\1>#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$store[] = $match[0][0];
$_length = strlen($match[0][0]);
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace);
$_store++;
}
}
$source = preg_replace( array_keys($expressions), array_values($expressions), $source );
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
// $source = trim( $source );
// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$store[] = $match[0][0];
$_length = strlen($match[0][0]);
$replace = array_shift($store);
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
$_offset += strlen($replace) - $_length;
$_store++;
}
}
return $source;
}
/**
* Add a template directory to the current template list
*
* @param int $templateType the template type (a TemplateDefinition type constant)
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param unknown $key ???
* @param string $key ???
* @param boolean $unshift ??? Etienne ?
*/
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false)
@@ -139,11 +245,6 @@ class SmartyParser extends Smarty implements ParserInterface
return $this->templateDirectories[$templateType];
}
public function removeBlankLines($tpl_source, \Smarty_Internal_Template $template)
{
return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $tpl_source);
}
public static function theliaEscape($content, $smarty)
{
if (is_scalar($content)) {

View File

@@ -0,0 +1,25 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Exception;
use Thelia\Log\Tlog;
class FileException extends \RuntimeException
{
public function __construct($message, $code = null, $previous = null)
{
Tlog::getInstance()->addError($message);
parent::__construct($message, $code, $previous);
}
}

View File

@@ -0,0 +1,265 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Files;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Exception\FileException;
use Thelia\Exception\ImageException;
/**
* File Manager
*
* @package File
* @author Guillaume MOREL <gmorel@openstudio.fr>, Franck Allimant <franck@cqfdev.fr>
*
*/
class FileManager
{
protected $supportedFileModels = array();
/**
* Create a new FileManager instance.
*
* @param array $supportedFileModels The key should have form type.parent, where type is the file type (document or image) and parent is the parent object of the file, form example product, brand, folder, etc.
*/
public function __construct($supportedFileModels) {
$this->supportedFileModels = $supportedFileModels;
}
/**
* Create the file type identifier, to access the related class in the supportedFileModels table.
*
* @param string $fileType the file type, e.g. document or image.
* @param string $parentType the parent object type, e.g. product, folder, brand, etc.
* @return string
*/
protected function getFileTypeIdentifier($fileType, $parentType) {
return strtolower("$fileType.$parentType");
}
/**
* Create a new FileModelInterface instance, from the supportedFileModels table
*
* @param string $fileType the file type, such as document, image, etc.
* @param string $parentType the parent type, such as product, category, etc.
*
* @return FileModelInterface a file model interface instance
*
* @throws FileException if the file type is not supported, or if the class does not implements FileModelInterface
*/
public function getModelInstance($fileType, $parentType) {
if (! isset($this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)])) {
throw new FileException(
sprintf("Unsupported file type '%s' for parent type '%s'", $fileType, $parentType)
);
}
$className = $this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)];
$instance = new $className;
if (! $instance instanceof FileModelInterface) {
throw new FileException(
sprintf("Wrong class type for file type '%s', parent type '%s'. Class '%s' should implements FileModelInterface",
$fileType, $parentType, $className
)
);
}
return $instance;
}
/**
* A a new FileModelInterface class name to the supported class list.
*
* @param string $fileType the file type, such as document, image, etc.
* @param string $parentType the parent type, such as Product, Category, etc.
* @param string $fullyQualifiedClassName the fully qualified class name
*/
public function addFileModel($fileType, $parentType, $fullyQualifiedClassName) {
$this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)] = $fullyQualifiedClassName;
}
/**
* Copy UploadedFile into the server storage directory
*
* @param FileModelInterface $model Model saved
* @param UploadedFile $uploadedFile Ready to be uploaded file
*
* @throws \Thelia\Exception\ImageException
* @return UploadedFile
*/
public function copyUploadedFile($model, $uploadedFile)
{
$newUploadedFile = null;
if ($uploadedFile !== null) {
$directory = $model->getUploadDir();
$fileName = $this->renameFile($model->getId(), $uploadedFile);
$newUploadedFile = $uploadedFile->move($directory, $fileName);
$model->setFile($fileName);
if (!$model->save()) {
throw new ImageException(
sprintf(
'Failed to update model after copy of uploaded file %s to %s',
$uploadedFile,
$model->getFile()
)
);
}
}
return $newUploadedFile;
}
/**
* Save file into the database
*
* @param int $parentId the parent object ID
* @param FileModelInterface $fileModel the file model object (image or document) to save.
*
* @return int number of modified rows in database
*
* @throws \Thelia\Exception\ImageException
*/
protected function saveFile($parentId, $fileModel)
{
$nbModifiedLines = 0;
if ($fileModel->getFile() !== null) {
$fileModel->setParentId($parentId);
$nbModifiedLines = $fileModel->save();
if (!$nbModifiedLines) {
throw new ImageException(
sprintf(
'Failed to update %s file model',
$fileModel->getFile()
)
);
}
}
return $nbModifiedLines;
}
/**
* Save file into the database
*
* @param ImageCreateOrUpdateEvent $event the event
* @param FileModelInterface $imageModel the file model object (image or document) to save.
*
* @return int number of modified rows in database
*/
public function saveImage($event, $imageModel)
{
return $this->saveFile($event->getParentId(), $imageModel);
}
/**
* Save file into the database
*
* @param DocumentCreateOrUpdateEvent $event the event
* @param FileModelInterface $documentModel the file model object (image or document) to save.
*
* @return int number of modified rows in database
*/
public function saveDocument($event, $documentModel)
{
return $this->saveFile($event->getParentId(), $documentModel);
}
/**
* Sanitizes a filename replacing whitespace with dashes
*
* Removes special characters that are illegal in filenames on certain
* operating systems and special characters requiring special escaping
* to manipulate at the command line.
*
* @param string $string The filename to be sanitized
*
* @return string The sanitized filename
*/
public function sanitizeFileName($string)
{
return strtolower(preg_replace('/[^a-zA-Z0-9-_\.]/', '', $string));
}
/**
* Delete image from file storage and database
*
* @param FileModelInterface $model File being deleted
*/
public function deleteFile($model)
{
$url = $model->getUploadDir() . DS . $model->getFile();
@unlink(str_replace('..', '', $url));
$model->delete();
}
/**
* Rename file with image model id
*
* @param int $modelId Model id
* @param UploadedFile $uploadedFile File being saved
*
* @return string
*/
public function renameFile($modelId, $uploadedFile)
{
$extension = $uploadedFile->getClientOriginalExtension();
if (!empty($extension)) {
$extension = '.' . strtolower($extension);
}
$fileName = $this->sanitizeFileName(
str_replace(
$extension,
'',
$uploadedFile->getClientOriginalName()
) . '-' . $modelId . $extension
);
return $fileName;
}
/**
* Check if a file is an image
* Check based on mime type
*
* @param string $mimeType File mime type
*
* @return bool
*/
public function isImage($mimeType)
{
$isValid = false;
$allowedType = array('image/jpeg' , 'image/png' ,'image/gif');
if (in_array($mimeType, $allowedType)) {
$isValid = true;
}
return $isValid;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Files;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Form\BaseForm;
interface FileModelInterface
{
/**
* Set file parent id
*
* @param int $parentId parent id
*
* @return $this
*/
public function setParentId($parentId);
/**
* Get file parent id
*
* @return int parent id
*/
public function getParentId();
/**
* @return string the file name
*/
public function getFile();
/**
* @param string $file the file name
*/
public function setFile($file);
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel();
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId();
/**
* Get the form instance used to change this object information
*
* @param Request $request the current request
*
* @return BaseForm the form
*/
public function getUpdateFormInstance(Request $request);
/**
* @return string the path to the upload directory where files are stored, without final slash
*/
public function getUploadDir();
/**
* @param int $objectId the object ID
*
* @return string the URL to redirect to after update from the back-office
*/
public function getRedirectionUrl();
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance();
/**
* Save the model object.
*
* @return mixed
*/
public function save();
/**
* Delete the model object.
*
* @return mixed
*/
public function delete();
/**
* Get the model object ID
*
* @return int
*/
public function getId();
/**
* Set the current title
*
* @param string $title the title in the current locale
*/
public function setTitle($title);
/**
* Get the current title
*
* @param string $title the title in the current locale
* @return FileModelInterface
*/
public function getTitle();
/**
* Set the chapo
*
* @param string $chapo the chapo in the current locale
* @return FileModelInterface
*/
public function setChapo($chapo);
/**
* Set the description
*
* @param string $description the description in the current locale
* @return FileModelInterface
*/
public function setDescription($description);
/**
* Set the postscriptum
*
* @param string $postscriptum the postscriptum in the current locale
* @return FileModelInterface
*/
public function setPostscriptum($postscriptum);
/**
* Set the current locale
*
* @param string $locale the locale string
* @return FileModelInterface
*/
public function setLocale($locale);
}

View File

@@ -0,0 +1,21 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Files;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Thelia\Form\BaseForm;
interface FileModelParentInterface
{
public function getTitle();
}

View File

@@ -12,12 +12,13 @@
namespace Thelia\Form;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Forms;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Validation;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ConfigQuery;
@@ -95,17 +96,38 @@ abstract class BaseForm
$this->buildForm();
// If not already set, define the success_url field
// This field is not included in the standard form hidden fields
// This field is not included in the hidden fields generated by form_hidden_fields Smarty function
if (! $this->formBuilder->has('success_url')) {
$this->formBuilder->add("success_url", "text");
$this->formBuilder->add("success_url", "hidden");
}
// The "error_message" field defines the error message displayed if
// the form could not be validated. If it is empty, a standard error message is displayed instead.
// This field is not included in the hidden fields generated by form_hidden_fields Smarty function
if (! $this->formBuilder->has('error_message')) {
$this->formBuilder->add("error_message", "text");
$this->formBuilder->add("error_message", "hidden");
}
$this->form = $this->formBuilder->getForm();
}
/**
* Return true if the given field value is defined only in the HTML template, and its value is defined
* in the template file, not the form builder.
* Thus, it should not be included in the form hidden fields generated by form_hidden_fields
* Smarty function, to prevent it from exiting twice in the form.
*
* @param FormView $fieldView
* @return bool
*/
public function isTemplateDefinedHiddenField($fieldView)
{
$name = $fieldView->vars['name'];
return $name == 'success_url' || $name == 'error_message';
}
public function getRequest()
{
return $this->request;
@@ -146,6 +168,10 @@ abstract class BaseForm
return $this;
}
/**
* @return FormView
* @throws \LogicException
*/
public function getView()
{
if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first.");

View File

@@ -0,0 +1,83 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form\Brand;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\True;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
use Thelia\Model\Lang;
/**
* Class BrandCreationForm
* @package Thelia\Form\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandCreationForm extends BaseForm
{
protected function doBuilForm($titleFieldHelpLabel)
{
$this->formBuilder->add(
'title',
'text',
[
'constraints' => [ new NotBlank() ],
'required' => true,
'label' => Translator::getInstance()->trans('Brand name'),
'label_attr' => [
'for' => 'title',
'help' => $titleFieldHelpLabel
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
]
]
)
->add(
'locale',
'hidden',
[
'constraints' => [ new NotBlank() ],
'required' => true,
]
)
// Is this brand online ?
->add(
'visible',
'checkbox',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('This brand is online'),
'label_attr' => [
'for' => 'visible_create'
]
]
);
}
protected function buildForm()
{
$this->doBuilForm(
Translator::getInstance()->trans(
'Enter here the brand name in the default language (%title%)',
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
)
);
}
public function getName()
{
return 'thelia_brand_creation';
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form\Brand;
use Thelia\Form\Image\DocumentModification;
/**
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandDocumentModification extends DocumentModification
{
/**
* @inheritdoc
*/
public function getName()
{
return 'thelia_brand_document_modification';
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form\Brand;
use Thelia\Form\Image\ImageModification;
/**
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandImageModification extends ImageModification
{
/**
* @inheritdoc
*/
public function getName()
{
return 'thelia_brand_image_modification';
}
}

View File

@@ -0,0 +1,61 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form\Brand;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Thelia\Core\Translation\Translator;
use Thelia\Form\StandardDescriptionFieldsTrait;
/**
* Class BrandModificationForm
* @package Thelia\Form\Brand
* @author Franck Allimant <franck@cqfdev.fr>
*/
class BrandModificationForm extends BrandCreationForm
{
use StandardDescriptionFieldsTrait;
protected function buildForm()
{
$this->doBuilForm(
Translator::getInstance()->trans('The brand name or title')
);
$this->formBuilder->add(
'id',
'hidden',
[
'constraints' => [ new GreaterThan(['value' => 0]) ],
'required' => true,
]
)
->add("logo_image_id", "integer", [
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Select the brand logo'),
'label_attr' => [
'for' => 'logo_image_id',
'help' => Translator::getInstance()->trans("Select the brand logo amongst the brand images")
]
])
;
// Add standard description fields, excluding title and locale, which are already defined
$this->addStandardDescFields(array('title', 'locale'));
}
public function getName()
{
return "thelia_brand_modification";
}
}

View File

@@ -12,9 +12,9 @@
namespace Thelia\Form\Image;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
use Thelia\Form\StandardDescriptionFieldsTrait;
/**
* Created by JetBrains PhpStorm.
@@ -22,7 +22,6 @@ use Thelia\Form\BaseForm;
* Time: 3:56 PM
*
* Form allowing to process a file
* @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action
*
* @package File
* @author Guillaume MOREL <gmorel@openstudio.fr>
@@ -30,94 +29,28 @@ use Thelia\Form\BaseForm;
*/
abstract class DocumentModification extends BaseForm
{
use StandardDescriptionFieldsTrait;
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->form attribute :
*
* $this->form->add('name', 'text')
* ->add('email', 'email', array(
* 'attr' => array(
* 'class' => 'field'
* ),
* 'label' => 'email',
* 'constraints' => array(
* new NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
* @inheritdoc
*/
protected function buildForm()
{
$this->formBuilder->add(
'file',
'file',
array(
'constraints' => array(),
[
'required' => false,
'constraints' => [ ],
'label' => Translator::getInstance()->trans('Replace current document by this file'),
'label_attr' => array(
'label_attr' => [
'for' => 'file'
)
)
]
]
);
$this->formBuilder
->add(
'title',
'text',
array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('Title'),
'label_attr' => array(
'for' => 'title'
)
)
)
->add(
'description',
'text',
array(
'constraints' => array(),
'label' => Translator::getInstance()->trans('Description'),
'label_attr' => array(
'for' => 'description'
)
)
)
->add(
'chapo',
'text',
array(
'constraints' => array(),
'label' => Translator::getInstance()->trans('Chapo'),
'label_attr' => array(
'for' => 'chapo'
)
)
)
->add(
'postscriptum',
'text',
array(
'constraints' => array(),
'label' => Translator::getInstance()->trans('Post Scriptum'),
'label_attr' => array(
'for' => 'postscriptum'
)
)
)
// Add standard description fields
$this->addStandardDescFields();
->add("locale", "text", array(
"constraints" => array(
new NotBlank()
),
"label_attr" => array("for" => "locale_create")
))
;
}
}

View File

@@ -13,9 +13,9 @@
namespace Thelia\Form\Image;
use Symfony\Component\Validator\Constraints\Image;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
use Thelia\Form\StandardDescriptionFieldsTrait;
/**
* Created by JetBrains PhpStorm.
@@ -23,109 +23,41 @@ use Thelia\Form\BaseForm;
* Time: 3:56 PM
*
* Form allowing to process an image
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
*
*
* @package Image
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
abstract class ImageModification extends BaseForm
{
use StandardDescriptionFieldsTrait;
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->form attribute :
*
* $this->form->add('name', 'text')
* ->add('email', 'email', array(
* 'attr' => array(
* 'class' => 'field'
* ),
* 'label' => 'email',
* 'constraints' => array(
* new NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
* @inheritdoc
*/
protected function buildForm()
{
$this->formBuilder->add(
'file',
'file',
array(
'constraints' => array(
[
'required' => false,
'constraints' => [
new Image(
array(
[
// 'minWidth' => 200,
// 'minHeight' => 200
)
]
)
),
],
'label' => Translator::getInstance()->trans('Replace current image by this file'),
'label_attr' => array(
'label_attr' => [
'for' => 'file'
)
)
]
]
);
$this->formBuilder
->add(
'title',
'text',
array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('Title'),
'label_attr' => array(
'for' => 'title'
)
)
)
->add(
'description',
'text',
array(
'constraints' => array(),
'label' => Translator::getInstance()->trans('Description'),
'label_attr' => array(
'for' => 'description'
)
)
)
->add(
'chapo',
'text',
array(
'constraints' => array(),
'label' => Translator::getInstance()->trans('Chapo'),
'label_attr' => array(
'for' => 'chapo'
)
)
)
->add(
'postscriptum',
'text',
array(
'constraints' => array(),
'label' => Translator::getInstance()->trans('Post Scriptum'),
'label_attr' => array(
'for' => 'postscriptum'
)
)
)
->add("locale", "text", array(
"constraints" => array(
new NotBlank()
),
"label_attr" => array("for" => "locale_create")
))
;
// Add standard description fields
$this->addStandardDescFields();
}
}

View File

@@ -13,6 +13,7 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class ProductModificationForm extends ProductCreationForm
@@ -33,6 +34,15 @@ class ProductModificationForm extends ProductCreationForm
"label" => Translator::getInstance()->trans("Product template"),
"label_attr" => array("for" => "product_template_field")
))
->add("brand_id", "integer", [
'constraints' => [ new NotBlank() ],
'required' => true,
'label' => Translator::getInstance()->trans('Brand / Supplier'),
'label_attr' => [
'for' => 'mode',
'help' => Translator::getInstance()->trans("Select the product brand, or supplier."),
],
])
;
// Add standard description fields, excluding title and locale, which a re defined in parent class

View File

@@ -28,49 +28,73 @@ trait SeoFieldsTrait
*/
protected function addSeoFields($exclude = array())
{
if (! in_array('url', $exclude))
$this->formBuilder
->add('url', 'text', array(
'label' => Translator::getInstance()->trans('Rewriten URL'),
'label_attr' => array(
$this->formBuilder->add(
'url',
'text',
[
'required' => false,
'label' => Translator::getInstance()->trans('Rewriten URL'),
'label_attr' => [
'for' => 'rewriten_url_field'
),
'required' => false
)
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Use the keyword phrase in your URL.')
]
]
);
if (! in_array('meta_title', $exclude))
$this->formBuilder
->add('meta_title', 'text', array(
'label' => Translator::getInstance()->trans('Page Title'),
'label_attr' => array(
'for' => 'meta_title'
),
'required' => false
)
$this->formBuilder->add(
'meta_title',
'text',
[
'required' => false,
'label' => Translator::getInstance()->trans('Page Title'),
'label_attr' => [
'for' => 'meta_title',
'help' => Translator::getInstance()->trans('The HTML TITLE element is the most important element on your web page.')
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Make sure that your title is clear, and contains many of the keywords within the page itself.')
]
]
);
if (! in_array('meta_description', $exclude))
$this->formBuilder
->add('meta_description', 'text', array(
'label' => Translator::getInstance()->trans('Meta Description'),
'label_attr' => array(
'for' => 'meta_description'
),
'required' => false
)
$this->formBuilder->add(
'meta_description',
'textarea',
[
'required' => false,
'label' => Translator::getInstance()->trans('Meta Description'),
'label_attr' => [
'for' => 'meta_description',
'help' => Translator::getInstance()->trans('Keep the most important part of your description in the first 150-160 characters.')
],
'attr' => [
'rows' => 6,
'placeholder' => Translator::getInstance()->trans('Make sure it uses keywords found within the page itself.')
]
]
);
if (! in_array('meta_keywords', $exclude))
$this->formBuilder
->add('meta_keywords', 'text', array(
'label' => Translator::getInstance()->trans('Meta Keywords'),
'label_attr' => array(
'for' => 'meta_keywords'
),
'required' => false
)
);
$this->formBuilder->add(
'meta_keywords',
'textarea',
[
'required' => false,
'label' => Translator::getInstance()->trans('Meta Keywords'),
'label_attr' => [
'for' => 'meta_keywords',
'help' => Translator::getInstance()->trans('You don\'t need to use commas or other punctuations.')
],
'attr' => [
'rows' => 3,
'placeholder' => Translator::getInstance()->trans('Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.')
]
]
);
}
}

View File

@@ -25,35 +25,20 @@ class SeoForm extends BaseForm
use SeoFieldsTrait;
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
* @inheritdoc
*/
protected function buildForm()
{
$this->formBuilder
->add("id", "hidden", array(
'required' => true,
"constraints" => array(
new GreaterThan(array('value' => 0))
)
))
->add("locale", "hidden", array(
'required' => true,
"constraints" => array(
new NotBlank()
)

View File

@@ -31,50 +31,86 @@ trait StandardDescriptionFieldsTrait
protected function addStandardDescFields($exclude = array())
{
if (! in_array('locale', $exclude))
$this->formBuilder
->add("locale", "hidden", array(
"constraints" => array(
new NotBlank()
)
)
);
$this->formBuilder->add(
'locale',
'hidden',
[
'constraints' => [ new NotBlank() ],
'required' => true,
]
);
if (! in_array('title', $exclude))
$this->formBuilder
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array("for" => "title_field")
)
$this->formBuilder->add(
'title',
'text',
[
'constraints' => [ new NotBlank() ],
'required' => true,
'label' => Translator::getInstance()->trans('Title'),
'label_attr' => [
'for' => 'title_field'
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('A descriptive title')
]
]
);
if (! in_array('chapo', $exclude))
$this->formBuilder
->add("chapo", "text", array(
"label" => Translator::getInstance()->trans("Summary"),
"label_attr" => array(
"for" => "summary_field"
)
));
$this->formBuilder->add(
'chapo',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Summary'),
'label_attr' => [
'for' => 'summary_field',
'help' => Translator::getInstance()->trans('A short description, used when a summary or an introduction is required')
],
'attr' => [
'rows' => 3,
'placeholder' => Translator::getInstance()->trans('Short description text')
]
]
);
if (! in_array('description', $exclude))
$this->formBuilder
->add("description", "text", array(
"label" => Translator::getInstance()->trans("Detailed description"),
"label_attr" => array(
"for" => "detailed_description_field"
)
));
$this->formBuilder->add(
'description',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Detailed description'),
'label_attr' => [
'for' => 'detailed_description_field',
'help' => Translator::getInstance()->trans('The detailed description.')
],
'attr' => [
'rows' => 10
]
]
);
if (! in_array('postscriptum', $exclude))
$this->formBuilder
->add("postscriptum", "text", array(
"label" => Translator::getInstance()->trans("Conclusion"),
"label_attr" => array(
"for" => "conclusion_field"
)
));
}
$this->formBuilder->add(
'postscriptum',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Conclusion'),
'label_attr' => [
'for' => 'conclusion_field',
'help' => Translator::getInstance()->trans('A short text, used when an additional or supplemental information is required.')
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Short additional text'),
'rows' => 3,
]
]
);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,607 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\BrandDocumentI18n as ChildBrandDocumentI18n;
use Thelia\Model\BrandDocumentI18nQuery as ChildBrandDocumentI18nQuery;
use Thelia\Model\Map\BrandDocumentI18nTableMap;
/**
* Base class that represents a query for the 'brand_document_i18n' table.
*
*
*
* @method ChildBrandDocumentI18nQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildBrandDocumentI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildBrandDocumentI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildBrandDocumentI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildBrandDocumentI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
* @method ChildBrandDocumentI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
*
* @method ChildBrandDocumentI18nQuery groupById() Group by the id column
* @method ChildBrandDocumentI18nQuery groupByLocale() Group by the locale column
* @method ChildBrandDocumentI18nQuery groupByTitle() Group by the title column
* @method ChildBrandDocumentI18nQuery groupByDescription() Group by the description column
* @method ChildBrandDocumentI18nQuery groupByChapo() Group by the chapo column
* @method ChildBrandDocumentI18nQuery groupByPostscriptum() Group by the postscriptum column
*
* @method ChildBrandDocumentI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildBrandDocumentI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildBrandDocumentI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildBrandDocumentI18nQuery leftJoinBrandDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the BrandDocument relation
* @method ChildBrandDocumentI18nQuery rightJoinBrandDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BrandDocument relation
* @method ChildBrandDocumentI18nQuery innerJoinBrandDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the BrandDocument relation
*
* @method ChildBrandDocumentI18n findOne(ConnectionInterface $con = null) Return the first ChildBrandDocumentI18n matching the query
* @method ChildBrandDocumentI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBrandDocumentI18n matching the query, or a new ChildBrandDocumentI18n object populated from the query conditions when no match is found
*
* @method ChildBrandDocumentI18n findOneById(int $id) Return the first ChildBrandDocumentI18n filtered by the id column
* @method ChildBrandDocumentI18n findOneByLocale(string $locale) Return the first ChildBrandDocumentI18n filtered by the locale column
* @method ChildBrandDocumentI18n findOneByTitle(string $title) Return the first ChildBrandDocumentI18n filtered by the title column
* @method ChildBrandDocumentI18n findOneByDescription(string $description) Return the first ChildBrandDocumentI18n filtered by the description column
* @method ChildBrandDocumentI18n findOneByChapo(string $chapo) Return the first ChildBrandDocumentI18n filtered by the chapo column
* @method ChildBrandDocumentI18n findOneByPostscriptum(string $postscriptum) Return the first ChildBrandDocumentI18n filtered by the postscriptum column
*
* @method array findById(int $id) Return ChildBrandDocumentI18n objects filtered by the id column
* @method array findByLocale(string $locale) Return ChildBrandDocumentI18n objects filtered by the locale column
* @method array findByTitle(string $title) Return ChildBrandDocumentI18n objects filtered by the title column
* @method array findByDescription(string $description) Return ChildBrandDocumentI18n objects filtered by the description column
* @method array findByChapo(string $chapo) Return ChildBrandDocumentI18n objects filtered by the chapo column
* @method array findByPostscriptum(string $postscriptum) Return ChildBrandDocumentI18n objects filtered by the postscriptum column
*
*/
abstract class BrandDocumentI18nQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\BrandDocumentI18nQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\BrandDocumentI18n', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildBrandDocumentI18nQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildBrandDocumentI18nQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\BrandDocumentI18nQuery) {
return $criteria;
}
$query = new \Thelia\Model\BrandDocumentI18nQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$id, $locale] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildBrandDocumentI18n|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = BrandDocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(BrandDocumentI18nTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandDocumentI18n A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `brand_document_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildBrandDocumentI18n();
$obj->hydrate($row);
BrandDocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandDocumentI18n|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(BrandDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(BrandDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(BrandDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(BrandDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @see filterByBrandDocument()
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(BrandDocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(BrandDocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandDocumentI18nTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the locale column
*
* Example usage:
* <code>
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
* </code>
*
* @param string $locale The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandDocumentI18nTableMap::LOCALE, $locale, $comparison);
}
/**
* Filter the query on the title column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandDocumentI18nTableMap::TITLE, $title, $comparison);
}
/**
* Filter the query on the description column
*
* Example usage:
* <code>
* $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
* $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
* </code>
*
* @param string $description The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByDescription($description = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($description)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $description)) {
$description = str_replace('*', '%', $description);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandDocumentI18nTableMap::DESCRIPTION, $description, $comparison);
}
/**
* Filter the query on the chapo column
*
* Example usage:
* <code>
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
* </code>
*
* @param string $chapo The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByChapo($chapo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($chapo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $chapo)) {
$chapo = str_replace('*', '%', $chapo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandDocumentI18nTableMap::CHAPO, $chapo, $comparison);
}
/**
* Filter the query on the postscriptum column
*
* Example usage:
* <code>
* $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
* $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
* </code>
*
* @param string $postscriptum The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByPostscriptum($postscriptum = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($postscriptum)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $postscriptum)) {
$postscriptum = str_replace('*', '%', $postscriptum);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandDocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\BrandDocument object
*
* @param \Thelia\Model\BrandDocument|ObjectCollection $brandDocument The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function filterByBrandDocument($brandDocument, $comparison = null)
{
if ($brandDocument instanceof \Thelia\Model\BrandDocument) {
return $this
->addUsingAlias(BrandDocumentI18nTableMap::ID, $brandDocument->getId(), $comparison);
} elseif ($brandDocument instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(BrandDocumentI18nTableMap::ID, $brandDocument->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByBrandDocument() only accepts arguments of type \Thelia\Model\BrandDocument or Collection');
}
}
/**
* Adds a JOIN clause to the query using the BrandDocument relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function joinBrandDocument($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('BrandDocument');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'BrandDocument');
}
return $this;
}
/**
* Use the BrandDocument relation BrandDocument object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandDocumentQuery A secondary query class using the current class as primary query
*/
public function useBrandDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinBrandDocument($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandDocument', '\Thelia\Model\BrandDocumentQuery');
}
/**
* Exclude object from result
*
* @param ChildBrandDocumentI18n $brandDocumentI18n Object to remove from the list of results
*
* @return ChildBrandDocumentI18nQuery The current query, for fluid interface
*/
public function prune($brandDocumentI18n = null)
{
if ($brandDocumentI18n) {
$this->addCond('pruneCond0', $this->getAliasedColName(BrandDocumentI18nTableMap::ID), $brandDocumentI18n->getId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(BrandDocumentI18nTableMap::LOCALE), $brandDocumentI18n->getLocale(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the brand_document_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandDocumentI18nTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
BrandDocumentI18nTableMap::clearInstancePool();
BrandDocumentI18nTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildBrandDocumentI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildBrandDocumentI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandDocumentI18nTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(BrandDocumentI18nTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
BrandDocumentI18nTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
BrandDocumentI18nTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} // BrandDocumentI18nQuery

View File

@@ -0,0 +1,846 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\BrandDocument as ChildBrandDocument;
use Thelia\Model\BrandDocumentI18nQuery as ChildBrandDocumentI18nQuery;
use Thelia\Model\BrandDocumentQuery as ChildBrandDocumentQuery;
use Thelia\Model\Map\BrandDocumentTableMap;
/**
* Base class that represents a query for the 'brand_document' table.
*
*
*
* @method ChildBrandDocumentQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildBrandDocumentQuery orderByBrandId($order = Criteria::ASC) Order by the brand_id column
* @method ChildBrandDocumentQuery orderByFile($order = Criteria::ASC) Order by the file column
* @method ChildBrandDocumentQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildBrandDocumentQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildBrandDocumentQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildBrandDocumentQuery groupById() Group by the id column
* @method ChildBrandDocumentQuery groupByBrandId() Group by the brand_id column
* @method ChildBrandDocumentQuery groupByFile() Group by the file column
* @method ChildBrandDocumentQuery groupByPosition() Group by the position column
* @method ChildBrandDocumentQuery groupByCreatedAt() Group by the created_at column
* @method ChildBrandDocumentQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildBrandDocumentQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildBrandDocumentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildBrandDocumentQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildBrandDocumentQuery leftJoinBrand($relationAlias = null) Adds a LEFT JOIN clause to the query using the Brand relation
* @method ChildBrandDocumentQuery rightJoinBrand($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Brand relation
* @method ChildBrandDocumentQuery innerJoinBrand($relationAlias = null) Adds a INNER JOIN clause to the query using the Brand relation
*
* @method ChildBrandDocumentQuery leftJoinBrandDocumentI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the BrandDocumentI18n relation
* @method ChildBrandDocumentQuery rightJoinBrandDocumentI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BrandDocumentI18n relation
* @method ChildBrandDocumentQuery innerJoinBrandDocumentI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the BrandDocumentI18n relation
*
* @method ChildBrandDocument findOne(ConnectionInterface $con = null) Return the first ChildBrandDocument matching the query
* @method ChildBrandDocument findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBrandDocument matching the query, or a new ChildBrandDocument object populated from the query conditions when no match is found
*
* @method ChildBrandDocument findOneById(int $id) Return the first ChildBrandDocument filtered by the id column
* @method ChildBrandDocument findOneByBrandId(int $brand_id) Return the first ChildBrandDocument filtered by the brand_id column
* @method ChildBrandDocument findOneByFile(string $file) Return the first ChildBrandDocument filtered by the file column
* @method ChildBrandDocument findOneByPosition(int $position) Return the first ChildBrandDocument filtered by the position column
* @method ChildBrandDocument findOneByCreatedAt(string $created_at) Return the first ChildBrandDocument filtered by the created_at column
* @method ChildBrandDocument findOneByUpdatedAt(string $updated_at) Return the first ChildBrandDocument filtered by the updated_at column
*
* @method array findById(int $id) Return ChildBrandDocument objects filtered by the id column
* @method array findByBrandId(int $brand_id) Return ChildBrandDocument objects filtered by the brand_id column
* @method array findByFile(string $file) Return ChildBrandDocument objects filtered by the file column
* @method array findByPosition(int $position) Return ChildBrandDocument objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return ChildBrandDocument objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildBrandDocument objects filtered by the updated_at column
*
*/
abstract class BrandDocumentQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\BrandDocumentQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\BrandDocument', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildBrandDocumentQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildBrandDocumentQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\BrandDocumentQuery) {
return $criteria;
}
$query = new \Thelia\Model\BrandDocumentQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildBrandDocument|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = BrandDocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(BrandDocumentTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandDocument A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `BRAND_ID`, `FILE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `brand_document` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildBrandDocument();
$obj->hydrate($row);
BrandDocumentTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandDocument|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(BrandDocumentTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(BrandDocumentTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(BrandDocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(BrandDocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandDocumentTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the brand_id column
*
* Example usage:
* <code>
* $query->filterByBrandId(1234); // WHERE brand_id = 1234
* $query->filterByBrandId(array(12, 34)); // WHERE brand_id IN (12, 34)
* $query->filterByBrandId(array('min' => 12)); // WHERE brand_id > 12
* </code>
*
* @see filterByBrand()
*
* @param mixed $brandId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByBrandId($brandId = null, $comparison = null)
{
if (is_array($brandId)) {
$useMinMax = false;
if (isset($brandId['min'])) {
$this->addUsingAlias(BrandDocumentTableMap::BRAND_ID, $brandId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($brandId['max'])) {
$this->addUsingAlias(BrandDocumentTableMap::BRAND_ID, $brandId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandDocumentTableMap::BRAND_ID, $brandId, $comparison);
}
/**
* Filter the query on the file column
*
* Example usage:
* <code>
* $query->filterByFile('fooValue'); // WHERE file = 'fooValue'
* $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%'
* </code>
*
* @param string $file The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByFile($file = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($file)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $file)) {
$file = str_replace('*', '%', $file);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandDocumentTableMap::FILE, $file, $comparison);
}
/**
* Filter the query on the position column
*
* Example usage:
* <code>
* $query->filterByPosition(1234); // WHERE position = 1234
* $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
* $query->filterByPosition(array('min' => 12)); // WHERE position > 12
* </code>
*
* @param mixed $position The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByPosition($position = null, $comparison = null)
{
if (is_array($position)) {
$useMinMax = false;
if (isset($position['min'])) {
$this->addUsingAlias(BrandDocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($position['max'])) {
$this->addUsingAlias(BrandDocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandDocumentTableMap::POSITION, $position, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(BrandDocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(BrandDocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandDocumentTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(BrandDocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(BrandDocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandDocumentTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Brand object
*
* @param \Thelia\Model\Brand|ObjectCollection $brand The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByBrand($brand, $comparison = null)
{
if ($brand instanceof \Thelia\Model\Brand) {
return $this
->addUsingAlias(BrandDocumentTableMap::BRAND_ID, $brand->getId(), $comparison);
} elseif ($brand instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(BrandDocumentTableMap::BRAND_ID, $brand->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByBrand() only accepts arguments of type \Thelia\Model\Brand or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Brand relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function joinBrand($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Brand');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Brand');
}
return $this;
}
/**
* Use the Brand relation Brand object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandQuery A secondary query class using the current class as primary query
*/
public function useBrandQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinBrand($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Brand', '\Thelia\Model\BrandQuery');
}
/**
* Filter the query by a related \Thelia\Model\BrandDocumentI18n object
*
* @param \Thelia\Model\BrandDocumentI18n|ObjectCollection $brandDocumentI18n the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function filterByBrandDocumentI18n($brandDocumentI18n, $comparison = null)
{
if ($brandDocumentI18n instanceof \Thelia\Model\BrandDocumentI18n) {
return $this
->addUsingAlias(BrandDocumentTableMap::ID, $brandDocumentI18n->getId(), $comparison);
} elseif ($brandDocumentI18n instanceof ObjectCollection) {
return $this
->useBrandDocumentI18nQuery()
->filterByPrimaryKeys($brandDocumentI18n->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByBrandDocumentI18n() only accepts arguments of type \Thelia\Model\BrandDocumentI18n or Collection');
}
}
/**
* Adds a JOIN clause to the query using the BrandDocumentI18n relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function joinBrandDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('BrandDocumentI18n');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'BrandDocumentI18n');
}
return $this;
}
/**
* Use the BrandDocumentI18n relation BrandDocumentI18n object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandDocumentI18nQuery A secondary query class using the current class as primary query
*/
public function useBrandDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinBrandDocumentI18n($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandDocumentI18n', '\Thelia\Model\BrandDocumentI18nQuery');
}
/**
* Exclude object from result
*
* @param ChildBrandDocument $brandDocument Object to remove from the list of results
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function prune($brandDocument = null)
{
if ($brandDocument) {
$this->addUsingAlias(BrandDocumentTableMap::ID, $brandDocument->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the brand_document table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandDocumentTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
BrandDocumentTableMap::clearInstancePool();
BrandDocumentTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildBrandDocument or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildBrandDocument object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandDocumentTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(BrandDocumentTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
BrandDocumentTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
BrandDocumentTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(BrandDocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(BrandDocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(BrandDocumentTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(BrandDocumentTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(BrandDocumentTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(BrandDocumentTableMap::CREATED_AT);
}
// i18n behavior
/**
* Adds a JOIN clause to the query using the i18n relation
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$relationName = $relationAlias ? $relationAlias : 'BrandDocumentI18n';
return $this
->joinBrandDocumentI18n($relationAlias, $joinType)
->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
}
/**
* Adds a JOIN clause to the query and hydrates the related I18n object.
* Shortcut for $c->joinI18n($locale)->with()
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildBrandDocumentQuery The current query, for fluid interface
*/
public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
{
$this
->joinI18n($locale, null, $joinType)
->with('BrandDocumentI18n');
$this->with['BrandDocumentI18n']->setIsWithOneToMany(false);
return $this;
}
/**
* Use the I18n relation query object
*
* @see useQuery()
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildBrandDocumentI18nQuery A secondary query class using the current class as primary query
*/
public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinI18n($locale, $relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandDocumentI18n', '\Thelia\Model\BrandDocumentI18nQuery');
}
} // BrandDocumentQuery

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,706 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\BrandI18n as ChildBrandI18n;
use Thelia\Model\BrandI18nQuery as ChildBrandI18nQuery;
use Thelia\Model\Map\BrandI18nTableMap;
/**
* Base class that represents a query for the 'brand_i18n' table.
*
*
*
* @method ChildBrandI18nQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildBrandI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildBrandI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildBrandI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildBrandI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
* @method ChildBrandI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
* @method ChildBrandI18nQuery orderByMetaTitle($order = Criteria::ASC) Order by the meta_title column
* @method ChildBrandI18nQuery orderByMetaDescription($order = Criteria::ASC) Order by the meta_description column
* @method ChildBrandI18nQuery orderByMetaKeywords($order = Criteria::ASC) Order by the meta_keywords column
*
* @method ChildBrandI18nQuery groupById() Group by the id column
* @method ChildBrandI18nQuery groupByLocale() Group by the locale column
* @method ChildBrandI18nQuery groupByTitle() Group by the title column
* @method ChildBrandI18nQuery groupByDescription() Group by the description column
* @method ChildBrandI18nQuery groupByChapo() Group by the chapo column
* @method ChildBrandI18nQuery groupByPostscriptum() Group by the postscriptum column
* @method ChildBrandI18nQuery groupByMetaTitle() Group by the meta_title column
* @method ChildBrandI18nQuery groupByMetaDescription() Group by the meta_description column
* @method ChildBrandI18nQuery groupByMetaKeywords() Group by the meta_keywords column
*
* @method ChildBrandI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildBrandI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildBrandI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildBrandI18nQuery leftJoinBrand($relationAlias = null) Adds a LEFT JOIN clause to the query using the Brand relation
* @method ChildBrandI18nQuery rightJoinBrand($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Brand relation
* @method ChildBrandI18nQuery innerJoinBrand($relationAlias = null) Adds a INNER JOIN clause to the query using the Brand relation
*
* @method ChildBrandI18n findOne(ConnectionInterface $con = null) Return the first ChildBrandI18n matching the query
* @method ChildBrandI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBrandI18n matching the query, or a new ChildBrandI18n object populated from the query conditions when no match is found
*
* @method ChildBrandI18n findOneById(int $id) Return the first ChildBrandI18n filtered by the id column
* @method ChildBrandI18n findOneByLocale(string $locale) Return the first ChildBrandI18n filtered by the locale column
* @method ChildBrandI18n findOneByTitle(string $title) Return the first ChildBrandI18n filtered by the title column
* @method ChildBrandI18n findOneByDescription(string $description) Return the first ChildBrandI18n filtered by the description column
* @method ChildBrandI18n findOneByChapo(string $chapo) Return the first ChildBrandI18n filtered by the chapo column
* @method ChildBrandI18n findOneByPostscriptum(string $postscriptum) Return the first ChildBrandI18n filtered by the postscriptum column
* @method ChildBrandI18n findOneByMetaTitle(string $meta_title) Return the first ChildBrandI18n filtered by the meta_title column
* @method ChildBrandI18n findOneByMetaDescription(string $meta_description) Return the first ChildBrandI18n filtered by the meta_description column
* @method ChildBrandI18n findOneByMetaKeywords(string $meta_keywords) Return the first ChildBrandI18n filtered by the meta_keywords column
*
* @method array findById(int $id) Return ChildBrandI18n objects filtered by the id column
* @method array findByLocale(string $locale) Return ChildBrandI18n objects filtered by the locale column
* @method array findByTitle(string $title) Return ChildBrandI18n objects filtered by the title column
* @method array findByDescription(string $description) Return ChildBrandI18n objects filtered by the description column
* @method array findByChapo(string $chapo) Return ChildBrandI18n objects filtered by the chapo column
* @method array findByPostscriptum(string $postscriptum) Return ChildBrandI18n objects filtered by the postscriptum column
* @method array findByMetaTitle(string $meta_title) Return ChildBrandI18n objects filtered by the meta_title column
* @method array findByMetaDescription(string $meta_description) Return ChildBrandI18n objects filtered by the meta_description column
* @method array findByMetaKeywords(string $meta_keywords) Return ChildBrandI18n objects filtered by the meta_keywords column
*
*/
abstract class BrandI18nQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\BrandI18nQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\BrandI18n', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildBrandI18nQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildBrandI18nQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\BrandI18nQuery) {
return $criteria;
}
$query = new \Thelia\Model\BrandI18nQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$id, $locale] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildBrandI18n|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = BrandI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(BrandI18nTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandI18n A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `META_TITLE`, `META_DESCRIPTION`, `META_KEYWORDS` FROM `brand_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildBrandI18n();
$obj->hydrate($row);
BrandI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandI18n|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(BrandI18nTableMap::ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(BrandI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(BrandI18nTableMap::ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(BrandI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @see filterByBrand()
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(BrandI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(BrandI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandI18nTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the locale column
*
* Example usage:
* <code>
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
* </code>
*
* @param string $locale The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::LOCALE, $locale, $comparison);
}
/**
* Filter the query on the title column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::TITLE, $title, $comparison);
}
/**
* Filter the query on the description column
*
* Example usage:
* <code>
* $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
* $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
* </code>
*
* @param string $description The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByDescription($description = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($description)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $description)) {
$description = str_replace('*', '%', $description);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::DESCRIPTION, $description, $comparison);
}
/**
* Filter the query on the chapo column
*
* Example usage:
* <code>
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
* </code>
*
* @param string $chapo The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByChapo($chapo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($chapo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $chapo)) {
$chapo = str_replace('*', '%', $chapo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::CHAPO, $chapo, $comparison);
}
/**
* Filter the query on the postscriptum column
*
* Example usage:
* <code>
* $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
* $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
* </code>
*
* @param string $postscriptum The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByPostscriptum($postscriptum = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($postscriptum)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $postscriptum)) {
$postscriptum = str_replace('*', '%', $postscriptum);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
}
/**
* Filter the query on the meta_title column
*
* Example usage:
* <code>
* $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue'
* $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%'
* </code>
*
* @param string $metaTitle The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByMetaTitle($metaTitle = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($metaTitle)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $metaTitle)) {
$metaTitle = str_replace('*', '%', $metaTitle);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::META_TITLE, $metaTitle, $comparison);
}
/**
* Filter the query on the meta_description column
*
* Example usage:
* <code>
* $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue'
* $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%'
* </code>
*
* @param string $metaDescription The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByMetaDescription($metaDescription = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($metaDescription)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $metaDescription)) {
$metaDescription = str_replace('*', '%', $metaDescription);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison);
}
/**
* Filter the query on the meta_keywords column
*
* Example usage:
* <code>
* $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue'
* $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%'
* </code>
*
* @param string $metaKeywords The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByMetaKeywords($metaKeywords = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($metaKeywords)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $metaKeywords)) {
$metaKeywords = str_replace('*', '%', $metaKeywords);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Brand object
*
* @param \Thelia\Model\Brand|ObjectCollection $brand The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function filterByBrand($brand, $comparison = null)
{
if ($brand instanceof \Thelia\Model\Brand) {
return $this
->addUsingAlias(BrandI18nTableMap::ID, $brand->getId(), $comparison);
} elseif ($brand instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(BrandI18nTableMap::ID, $brand->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByBrand() only accepts arguments of type \Thelia\Model\Brand or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Brand relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function joinBrand($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Brand');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Brand');
}
return $this;
}
/**
* Use the Brand relation Brand object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandQuery A secondary query class using the current class as primary query
*/
public function useBrandQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinBrand($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Brand', '\Thelia\Model\BrandQuery');
}
/**
* Exclude object from result
*
* @param ChildBrandI18n $brandI18n Object to remove from the list of results
*
* @return ChildBrandI18nQuery The current query, for fluid interface
*/
public function prune($brandI18n = null)
{
if ($brandI18n) {
$this->addCond('pruneCond0', $this->getAliasedColName(BrandI18nTableMap::ID), $brandI18n->getId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(BrandI18nTableMap::LOCALE), $brandI18n->getLocale(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the brand_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandI18nTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
BrandI18nTableMap::clearInstancePool();
BrandI18nTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildBrandI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildBrandI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandI18nTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(BrandI18nTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
BrandI18nTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
BrandI18nTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} // BrandI18nQuery

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,607 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\BrandImageI18n as ChildBrandImageI18n;
use Thelia\Model\BrandImageI18nQuery as ChildBrandImageI18nQuery;
use Thelia\Model\Map\BrandImageI18nTableMap;
/**
* Base class that represents a query for the 'brand_image_i18n' table.
*
*
*
* @method ChildBrandImageI18nQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildBrandImageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildBrandImageI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildBrandImageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildBrandImageI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
* @method ChildBrandImageI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
*
* @method ChildBrandImageI18nQuery groupById() Group by the id column
* @method ChildBrandImageI18nQuery groupByLocale() Group by the locale column
* @method ChildBrandImageI18nQuery groupByTitle() Group by the title column
* @method ChildBrandImageI18nQuery groupByDescription() Group by the description column
* @method ChildBrandImageI18nQuery groupByChapo() Group by the chapo column
* @method ChildBrandImageI18nQuery groupByPostscriptum() Group by the postscriptum column
*
* @method ChildBrandImageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildBrandImageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildBrandImageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildBrandImageI18nQuery leftJoinBrandImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the BrandImage relation
* @method ChildBrandImageI18nQuery rightJoinBrandImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BrandImage relation
* @method ChildBrandImageI18nQuery innerJoinBrandImage($relationAlias = null) Adds a INNER JOIN clause to the query using the BrandImage relation
*
* @method ChildBrandImageI18n findOne(ConnectionInterface $con = null) Return the first ChildBrandImageI18n matching the query
* @method ChildBrandImageI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBrandImageI18n matching the query, or a new ChildBrandImageI18n object populated from the query conditions when no match is found
*
* @method ChildBrandImageI18n findOneById(int $id) Return the first ChildBrandImageI18n filtered by the id column
* @method ChildBrandImageI18n findOneByLocale(string $locale) Return the first ChildBrandImageI18n filtered by the locale column
* @method ChildBrandImageI18n findOneByTitle(string $title) Return the first ChildBrandImageI18n filtered by the title column
* @method ChildBrandImageI18n findOneByDescription(string $description) Return the first ChildBrandImageI18n filtered by the description column
* @method ChildBrandImageI18n findOneByChapo(string $chapo) Return the first ChildBrandImageI18n filtered by the chapo column
* @method ChildBrandImageI18n findOneByPostscriptum(string $postscriptum) Return the first ChildBrandImageI18n filtered by the postscriptum column
*
* @method array findById(int $id) Return ChildBrandImageI18n objects filtered by the id column
* @method array findByLocale(string $locale) Return ChildBrandImageI18n objects filtered by the locale column
* @method array findByTitle(string $title) Return ChildBrandImageI18n objects filtered by the title column
* @method array findByDescription(string $description) Return ChildBrandImageI18n objects filtered by the description column
* @method array findByChapo(string $chapo) Return ChildBrandImageI18n objects filtered by the chapo column
* @method array findByPostscriptum(string $postscriptum) Return ChildBrandImageI18n objects filtered by the postscriptum column
*
*/
abstract class BrandImageI18nQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\BrandImageI18nQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\BrandImageI18n', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildBrandImageI18nQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildBrandImageI18nQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\BrandImageI18nQuery) {
return $criteria;
}
$query = new \Thelia\Model\BrandImageI18nQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$id, $locale] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildBrandImageI18n|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = BrandImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(BrandImageI18nTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandImageI18n A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `brand_image_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildBrandImageI18n();
$obj->hydrate($row);
BrandImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandImageI18n|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(BrandImageI18nTableMap::ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(BrandImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(BrandImageI18nTableMap::ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(BrandImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @see filterByBrandImage()
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(BrandImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(BrandImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandImageI18nTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the locale column
*
* Example usage:
* <code>
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
* </code>
*
* @param string $locale The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandImageI18nTableMap::LOCALE, $locale, $comparison);
}
/**
* Filter the query on the title column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandImageI18nTableMap::TITLE, $title, $comparison);
}
/**
* Filter the query on the description column
*
* Example usage:
* <code>
* $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
* $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
* </code>
*
* @param string $description The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByDescription($description = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($description)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $description)) {
$description = str_replace('*', '%', $description);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandImageI18nTableMap::DESCRIPTION, $description, $comparison);
}
/**
* Filter the query on the chapo column
*
* Example usage:
* <code>
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
* </code>
*
* @param string $chapo The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByChapo($chapo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($chapo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $chapo)) {
$chapo = str_replace('*', '%', $chapo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandImageI18nTableMap::CHAPO, $chapo, $comparison);
}
/**
* Filter the query on the postscriptum column
*
* Example usage:
* <code>
* $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
* $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
* </code>
*
* @param string $postscriptum The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByPostscriptum($postscriptum = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($postscriptum)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $postscriptum)) {
$postscriptum = str_replace('*', '%', $postscriptum);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\BrandImage object
*
* @param \Thelia\Model\BrandImage|ObjectCollection $brandImage The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function filterByBrandImage($brandImage, $comparison = null)
{
if ($brandImage instanceof \Thelia\Model\BrandImage) {
return $this
->addUsingAlias(BrandImageI18nTableMap::ID, $brandImage->getId(), $comparison);
} elseif ($brandImage instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(BrandImageI18nTableMap::ID, $brandImage->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByBrandImage() only accepts arguments of type \Thelia\Model\BrandImage or Collection');
}
}
/**
* Adds a JOIN clause to the query using the BrandImage relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function joinBrandImage($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('BrandImage');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'BrandImage');
}
return $this;
}
/**
* Use the BrandImage relation BrandImage object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandImageQuery A secondary query class using the current class as primary query
*/
public function useBrandImageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinBrandImage($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandImage', '\Thelia\Model\BrandImageQuery');
}
/**
* Exclude object from result
*
* @param ChildBrandImageI18n $brandImageI18n Object to remove from the list of results
*
* @return ChildBrandImageI18nQuery The current query, for fluid interface
*/
public function prune($brandImageI18n = null)
{
if ($brandImageI18n) {
$this->addCond('pruneCond0', $this->getAliasedColName(BrandImageI18nTableMap::ID), $brandImageI18n->getId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(BrandImageI18nTableMap::LOCALE), $brandImageI18n->getLocale(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the brand_image_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandImageI18nTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
BrandImageI18nTableMap::clearInstancePool();
BrandImageI18nTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildBrandImageI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildBrandImageI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandImageI18nTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(BrandImageI18nTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
BrandImageI18nTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
BrandImageI18nTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} // BrandImageI18nQuery

View File

@@ -0,0 +1,923 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\BrandImage as ChildBrandImage;
use Thelia\Model\BrandImageI18nQuery as ChildBrandImageI18nQuery;
use Thelia\Model\BrandImageQuery as ChildBrandImageQuery;
use Thelia\Model\Map\BrandImageTableMap;
/**
* Base class that represents a query for the 'brand_image' table.
*
*
*
* @method ChildBrandImageQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildBrandImageQuery orderByBrandId($order = Criteria::ASC) Order by the brand_id column
* @method ChildBrandImageQuery orderByFile($order = Criteria::ASC) Order by the file column
* @method ChildBrandImageQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildBrandImageQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildBrandImageQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildBrandImageQuery groupById() Group by the id column
* @method ChildBrandImageQuery groupByBrandId() Group by the brand_id column
* @method ChildBrandImageQuery groupByFile() Group by the file column
* @method ChildBrandImageQuery groupByPosition() Group by the position column
* @method ChildBrandImageQuery groupByCreatedAt() Group by the created_at column
* @method ChildBrandImageQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildBrandImageQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildBrandImageQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildBrandImageQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildBrandImageQuery leftJoinBrandRelatedByBrandId($relationAlias = null) Adds a LEFT JOIN clause to the query using the BrandRelatedByBrandId relation
* @method ChildBrandImageQuery rightJoinBrandRelatedByBrandId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BrandRelatedByBrandId relation
* @method ChildBrandImageQuery innerJoinBrandRelatedByBrandId($relationAlias = null) Adds a INNER JOIN clause to the query using the BrandRelatedByBrandId relation
*
* @method ChildBrandImageQuery leftJoinBrandRelatedByLogoImageId($relationAlias = null) Adds a LEFT JOIN clause to the query using the BrandRelatedByLogoImageId relation
* @method ChildBrandImageQuery rightJoinBrandRelatedByLogoImageId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BrandRelatedByLogoImageId relation
* @method ChildBrandImageQuery innerJoinBrandRelatedByLogoImageId($relationAlias = null) Adds a INNER JOIN clause to the query using the BrandRelatedByLogoImageId relation
*
* @method ChildBrandImageQuery leftJoinBrandImageI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the BrandImageI18n relation
* @method ChildBrandImageQuery rightJoinBrandImageI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BrandImageI18n relation
* @method ChildBrandImageQuery innerJoinBrandImageI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the BrandImageI18n relation
*
* @method ChildBrandImage findOne(ConnectionInterface $con = null) Return the first ChildBrandImage matching the query
* @method ChildBrandImage findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBrandImage matching the query, or a new ChildBrandImage object populated from the query conditions when no match is found
*
* @method ChildBrandImage findOneById(int $id) Return the first ChildBrandImage filtered by the id column
* @method ChildBrandImage findOneByBrandId(int $brand_id) Return the first ChildBrandImage filtered by the brand_id column
* @method ChildBrandImage findOneByFile(string $file) Return the first ChildBrandImage filtered by the file column
* @method ChildBrandImage findOneByPosition(int $position) Return the first ChildBrandImage filtered by the position column
* @method ChildBrandImage findOneByCreatedAt(string $created_at) Return the first ChildBrandImage filtered by the created_at column
* @method ChildBrandImage findOneByUpdatedAt(string $updated_at) Return the first ChildBrandImage filtered by the updated_at column
*
* @method array findById(int $id) Return ChildBrandImage objects filtered by the id column
* @method array findByBrandId(int $brand_id) Return ChildBrandImage objects filtered by the brand_id column
* @method array findByFile(string $file) Return ChildBrandImage objects filtered by the file column
* @method array findByPosition(int $position) Return ChildBrandImage objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return ChildBrandImage objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildBrandImage objects filtered by the updated_at column
*
*/
abstract class BrandImageQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\BrandImageQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\BrandImage', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildBrandImageQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildBrandImageQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\BrandImageQuery) {
return $criteria;
}
$query = new \Thelia\Model\BrandImageQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildBrandImage|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = BrandImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(BrandImageTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandImage A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `BRAND_ID`, `FILE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `brand_image` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildBrandImage();
$obj->hydrate($row);
BrandImageTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildBrandImage|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(BrandImageTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(BrandImageTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(BrandImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(BrandImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandImageTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the brand_id column
*
* Example usage:
* <code>
* $query->filterByBrandId(1234); // WHERE brand_id = 1234
* $query->filterByBrandId(array(12, 34)); // WHERE brand_id IN (12, 34)
* $query->filterByBrandId(array('min' => 12)); // WHERE brand_id > 12
* </code>
*
* @see filterByBrandRelatedByBrandId()
*
* @param mixed $brandId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByBrandId($brandId = null, $comparison = null)
{
if (is_array($brandId)) {
$useMinMax = false;
if (isset($brandId['min'])) {
$this->addUsingAlias(BrandImageTableMap::BRAND_ID, $brandId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($brandId['max'])) {
$this->addUsingAlias(BrandImageTableMap::BRAND_ID, $brandId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandImageTableMap::BRAND_ID, $brandId, $comparison);
}
/**
* Filter the query on the file column
*
* Example usage:
* <code>
* $query->filterByFile('fooValue'); // WHERE file = 'fooValue'
* $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%'
* </code>
*
* @param string $file The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByFile($file = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($file)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $file)) {
$file = str_replace('*', '%', $file);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(BrandImageTableMap::FILE, $file, $comparison);
}
/**
* Filter the query on the position column
*
* Example usage:
* <code>
* $query->filterByPosition(1234); // WHERE position = 1234
* $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
* $query->filterByPosition(array('min' => 12)); // WHERE position > 12
* </code>
*
* @param mixed $position The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByPosition($position = null, $comparison = null)
{
if (is_array($position)) {
$useMinMax = false;
if (isset($position['min'])) {
$this->addUsingAlias(BrandImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($position['max'])) {
$this->addUsingAlias(BrandImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandImageTableMap::POSITION, $position, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(BrandImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(BrandImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandImageTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(BrandImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(BrandImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(BrandImageTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Brand object
*
* @param \Thelia\Model\Brand|ObjectCollection $brand The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByBrandRelatedByBrandId($brand, $comparison = null)
{
if ($brand instanceof \Thelia\Model\Brand) {
return $this
->addUsingAlias(BrandImageTableMap::BRAND_ID, $brand->getId(), $comparison);
} elseif ($brand instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(BrandImageTableMap::BRAND_ID, $brand->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByBrandRelatedByBrandId() only accepts arguments of type \Thelia\Model\Brand or Collection');
}
}
/**
* Adds a JOIN clause to the query using the BrandRelatedByBrandId relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function joinBrandRelatedByBrandId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('BrandRelatedByBrandId');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'BrandRelatedByBrandId');
}
return $this;
}
/**
* Use the BrandRelatedByBrandId relation Brand object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandQuery A secondary query class using the current class as primary query
*/
public function useBrandRelatedByBrandIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinBrandRelatedByBrandId($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandRelatedByBrandId', '\Thelia\Model\BrandQuery');
}
/**
* Filter the query by a related \Thelia\Model\Brand object
*
* @param \Thelia\Model\Brand|ObjectCollection $brand the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByBrandRelatedByLogoImageId($brand, $comparison = null)
{
if ($brand instanceof \Thelia\Model\Brand) {
return $this
->addUsingAlias(BrandImageTableMap::ID, $brand->getLogoImageId(), $comparison);
} elseif ($brand instanceof ObjectCollection) {
return $this
->useBrandRelatedByLogoImageIdQuery()
->filterByPrimaryKeys($brand->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByBrandRelatedByLogoImageId() only accepts arguments of type \Thelia\Model\Brand or Collection');
}
}
/**
* Adds a JOIN clause to the query using the BrandRelatedByLogoImageId relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function joinBrandRelatedByLogoImageId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('BrandRelatedByLogoImageId');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'BrandRelatedByLogoImageId');
}
return $this;
}
/**
* Use the BrandRelatedByLogoImageId relation Brand object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandQuery A secondary query class using the current class as primary query
*/
public function useBrandRelatedByLogoImageIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinBrandRelatedByLogoImageId($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandRelatedByLogoImageId', '\Thelia\Model\BrandQuery');
}
/**
* Filter the query by a related \Thelia\Model\BrandImageI18n object
*
* @param \Thelia\Model\BrandImageI18n|ObjectCollection $brandImageI18n the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function filterByBrandImageI18n($brandImageI18n, $comparison = null)
{
if ($brandImageI18n instanceof \Thelia\Model\BrandImageI18n) {
return $this
->addUsingAlias(BrandImageTableMap::ID, $brandImageI18n->getId(), $comparison);
} elseif ($brandImageI18n instanceof ObjectCollection) {
return $this
->useBrandImageI18nQuery()
->filterByPrimaryKeys($brandImageI18n->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByBrandImageI18n() only accepts arguments of type \Thelia\Model\BrandImageI18n or Collection');
}
}
/**
* Adds a JOIN clause to the query using the BrandImageI18n relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function joinBrandImageI18n($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('BrandImageI18n');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'BrandImageI18n');
}
return $this;
}
/**
* Use the BrandImageI18n relation BrandImageI18n object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandImageI18nQuery A secondary query class using the current class as primary query
*/
public function useBrandImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinBrandImageI18n($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandImageI18n', '\Thelia\Model\BrandImageI18nQuery');
}
/**
* Exclude object from result
*
* @param ChildBrandImage $brandImage Object to remove from the list of results
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function prune($brandImage = null)
{
if ($brandImage) {
$this->addUsingAlias(BrandImageTableMap::ID, $brandImage->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the brand_image table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandImageTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
BrandImageTableMap::clearInstancePool();
BrandImageTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildBrandImage or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildBrandImage object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(BrandImageTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(BrandImageTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
BrandImageTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
BrandImageTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(BrandImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(BrandImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(BrandImageTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(BrandImageTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(BrandImageTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(BrandImageTableMap::CREATED_AT);
}
// i18n behavior
/**
* Adds a JOIN clause to the query using the i18n relation
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$relationName = $relationAlias ? $relationAlias : 'BrandImageI18n';
return $this
->joinBrandImageI18n($relationAlias, $joinType)
->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
}
/**
* Adds a JOIN clause to the query and hydrates the related I18n object.
* Shortcut for $c->joinI18n($locale)->with()
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildBrandImageQuery The current query, for fluid interface
*/
public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
{
$this
->joinI18n($locale, null, $joinType)
->with('BrandImageI18n');
$this->with['BrandImageI18n']->setIsWithOneToMany(false);
return $this;
}
/**
* Use the I18n relation query object
*
* @see useQuery()
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildBrandImageI18nQuery A secondary query class using the current class as primary query
*/
public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinI18n($locale, $relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'BrandImageI18n', '\Thelia\Model\BrandImageI18nQuery');
}
} // BrandImageQuery

File diff suppressed because it is too large Load Diff

View File

@@ -169,6 +169,18 @@ abstract class Coupon implements ActiveRecordInterface
*/
protected $version;
/**
* The value for the version_created_at field.
* @var string
*/
protected $version_created_at;
/**
* The value for the version_created_by field.
* @var string
*/
protected $version_created_by;
/**
* @var ObjectCollection|ChildCouponCountry[] Collection to store aggregation of ChildCouponCountry objects.
*/
@@ -766,6 +778,37 @@ abstract class Coupon implements ActiveRecordInterface
return $this->version;
}
/**
* Get the [optionally formatted] temporal [version_created_at] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw \DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
*
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getVersionCreatedAt($format = NULL)
{
if ($format === null) {
return $this->version_created_at;
} else {
return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null;
}
}
/**
* Get the [version_created_by] column value.
*
* @return string
*/
public function getVersionCreatedBy()
{
return $this->version_created_by;
}
/**
* Set the value of [id] column.
*
@@ -1150,6 +1193,48 @@ abstract class Coupon implements ActiveRecordInterface
return $this;
} // setVersion()
/**
* Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or \DateTime value.
* Empty strings are treated as NULL.
* @return \Thelia\Model\Coupon The current object (for fluent API support)
*/
public function setVersionCreatedAt($v)
{
$dt = PropelDateTime::newInstance($v, null, '\DateTime');
if ($this->version_created_at !== null || $dt !== null) {
if ($dt !== $this->version_created_at) {
$this->version_created_at = $dt;
$this->modifiedColumns[CouponTableMap::VERSION_CREATED_AT] = true;
}
} // if either are not null
return $this;
} // setVersionCreatedAt()
/**
* Set the value of [version_created_by] column.
*
* @param string $v new value
* @return \Thelia\Model\Coupon The current object (for fluent API support)
*/
public function setVersionCreatedBy($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->version_created_by !== $v) {
$this->version_created_by = $v;
$this->modifiedColumns[CouponTableMap::VERSION_CREATED_BY] = true;
}
return $this;
} // setVersionCreatedBy()
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -1247,6 +1332,15 @@ abstract class Coupon implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$this->version = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CouponTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$this->version_created_by = (null !== $col) ? (string) $col : null;
$this->resetModified();
$this->setNew(false);
@@ -1255,7 +1349,7 @@ abstract class Coupon implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 16; // 16 = CouponTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 18; // 18 = CouponTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e);
@@ -1400,6 +1494,9 @@ abstract class Coupon implements ActiveRecordInterface
// versionable behavior
if ($this->isVersioningNecessary()) {
$this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
if (!$this->isColumnModified(CouponTableMap::VERSION_CREATED_AT)) {
$this->setVersionCreatedAt(time());
}
$createVersion = true; // for postSave hook
}
if ($isInsert) {
@@ -1711,6 +1808,12 @@ abstract class Coupon implements ActiveRecordInterface
if ($this->isColumnModified(CouponTableMap::VERSION)) {
$modifiedColumns[':p' . $index++] = '`VERSION`';
}
if ($this->isColumnModified(CouponTableMap::VERSION_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
}
if ($this->isColumnModified(CouponTableMap::VERSION_CREATED_BY)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
}
$sql = sprintf(
'INSERT INTO `coupon` (%s) VALUES (%s)',
@@ -1770,6 +1873,12 @@ abstract class Coupon implements ActiveRecordInterface
case '`VERSION`':
$stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
break;
case '`VERSION_CREATED_AT`':
$stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`VERSION_CREATED_BY`':
$stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
@@ -1880,6 +1989,12 @@ abstract class Coupon implements ActiveRecordInterface
case 15:
return $this->getVersion();
break;
case 16:
return $this->getVersionCreatedAt();
break;
case 17:
return $this->getVersionCreatedBy();
break;
default:
return null;
break;
@@ -1925,6 +2040,8 @@ abstract class Coupon implements ActiveRecordInterface
$keys[13] => $this->getCreatedAt(),
$keys[14] => $this->getUpdatedAt(),
$keys[15] => $this->getVersion(),
$keys[16] => $this->getVersionCreatedAt(),
$keys[17] => $this->getVersionCreatedBy(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -2029,6 +2146,12 @@ abstract class Coupon implements ActiveRecordInterface
case 15:
$this->setVersion($value);
break;
case 16:
$this->setVersionCreatedAt($value);
break;
case 17:
$this->setVersionCreatedBy($value);
break;
} // switch()
}
@@ -2069,6 +2192,8 @@ abstract class Coupon implements ActiveRecordInterface
if (array_key_exists($keys[13], $arr)) $this->setCreatedAt($arr[$keys[13]]);
if (array_key_exists($keys[14], $arr)) $this->setUpdatedAt($arr[$keys[14]]);
if (array_key_exists($keys[15], $arr)) $this->setVersion($arr[$keys[15]]);
if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedAt($arr[$keys[16]]);
if (array_key_exists($keys[17], $arr)) $this->setVersionCreatedBy($arr[$keys[17]]);
}
/**
@@ -2096,6 +2221,8 @@ abstract class Coupon implements ActiveRecordInterface
if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version);
if ($this->isColumnModified(CouponTableMap::VERSION_CREATED_AT)) $criteria->add(CouponTableMap::VERSION_CREATED_AT, $this->version_created_at);
if ($this->isColumnModified(CouponTableMap::VERSION_CREATED_BY)) $criteria->add(CouponTableMap::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -2174,6 +2301,8 @@ abstract class Coupon implements ActiveRecordInterface
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setVersion($this->getVersion());
$copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
$copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -4019,6 +4148,8 @@ abstract class Coupon implements ActiveRecordInterface
$this->created_at = null;
$this->updated_at = null;
$this->version = null;
$this->version_created_at = null;
$this->version_created_by = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();
@@ -4354,6 +4485,8 @@ abstract class Coupon implements ActiveRecordInterface
$version->setCreatedAt($this->getCreatedAt());
$version->setUpdatedAt($this->getUpdatedAt());
$version->setVersion($this->getVersion());
$version->setVersionCreatedAt($this->getVersionCreatedAt());
$version->setVersionCreatedBy($this->getVersionCreatedBy());
$version->setCoupon($this);
$version->save($con);
@@ -4407,6 +4540,8 @@ abstract class Coupon implements ActiveRecordInterface
$this->setCreatedAt($version->getCreatedAt());
$this->setUpdatedAt($version->getUpdatedAt());
$this->setVersion($version->getVersion());
$this->setVersionCreatedAt($version->getVersionCreatedAt());
$this->setVersionCreatedBy($version->getVersionCreatedBy());
return $this;
}
@@ -4548,6 +4683,8 @@ abstract class Coupon implements ActiveRecordInterface
$toVersionNumber = $toVersion['Version'];
$ignoredColumns = array_merge(array(
'Version',
'VersionCreatedAt',
'VersionCreatedBy',
), $ignoredColumns);
$diff = array();
foreach ($fromVersion as $key => $value) {

View File

@@ -38,6 +38,8 @@ use Thelia\Model\Map\CouponTableMap;
* @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column
* @method ChildCouponQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
* @method ChildCouponQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method ChildCouponQuery groupById() Group by the id column
* @method ChildCouponQuery groupByCode() Group by the code column
@@ -55,6 +57,8 @@ use Thelia\Model\Map\CouponTableMap;
* @method ChildCouponQuery groupByCreatedAt() Group by the created_at column
* @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column
* @method ChildCouponQuery groupByVersion() Group by the version column
* @method ChildCouponQuery groupByVersionCreatedAt() Group by the version_created_at column
* @method ChildCouponQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method ChildCouponQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCouponQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -99,6 +103,8 @@ use Thelia\Model\Map\CouponTableMap;
* @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column
* @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column
* @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column
* @method ChildCoupon findOneByVersionCreatedAt(string $version_created_at) Return the first ChildCoupon filtered by the version_created_at column
* @method ChildCoupon findOneByVersionCreatedBy(string $version_created_by) Return the first ChildCoupon filtered by the version_created_by column
*
* @method array findById(int $id) Return ChildCoupon objects filtered by the id column
* @method array findByCode(string $code) Return ChildCoupon objects filtered by the code column
@@ -116,6 +122,8 @@ use Thelia\Model\Map\CouponTableMap;
* @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column
* @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column
* @method array findByVersionCreatedAt(string $version_created_at) Return ChildCoupon objects filtered by the version_created_at column
* @method array findByVersionCreatedBy(string $version_created_by) Return ChildCoupon objects filtered by the version_created_by column
*
*/
abstract class CouponQuery extends ModelCriteria
@@ -211,7 +219,7 @@ abstract class CouponQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon` WHERE `ID` = :p0';
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `coupon` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -830,6 +838,78 @@ abstract class CouponQuery extends ModelCriteria
return $this->addUsingAlias(CouponTableMap::VERSION, $version, $comparison);
}
/**
* Filter the query on the version_created_at column
*
* Example usage:
* <code>
* $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
* $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
* $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
* </code>
*
* @param mixed $versionCreatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponQuery The current query, for fluid interface
*/
public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
{
if (is_array($versionCreatedAt)) {
$useMinMax = false;
if (isset($versionCreatedAt['min'])) {
$this->addUsingAlias(CouponTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($versionCreatedAt['max'])) {
$this->addUsingAlias(CouponTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CouponTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
}
/**
* Filter the query on the version_created_by column
*
* Example usage:
* <code>
* $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
* $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
* </code>
*
* @param string $versionCreatedBy The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponQuery The current query, for fluid interface
*/
public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($versionCreatedBy)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
$versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CouponTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\CouponCountry object
*

View File

@@ -152,6 +152,18 @@ abstract class CouponVersion implements ActiveRecordInterface
*/
protected $version;
/**
* The value for the version_created_at field.
* @var string
*/
protected $version_created_at;
/**
* The value for the version_created_by field.
* @var string
*/
protected $version_created_by;
/**
* @var Coupon
*/
@@ -639,6 +651,37 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this->version;
}
/**
* Get the [optionally formatted] temporal [version_created_at] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw \DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
*
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getVersionCreatedAt($format = NULL)
{
if ($format === null) {
return $this->version_created_at;
} else {
return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null;
}
}
/**
* Get the [version_created_by] column value.
*
* @return string
*/
public function getVersionCreatedBy()
{
return $this->version_created_by;
}
/**
* Set the value of [id] column.
*
@@ -1027,6 +1070,48 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this;
} // setVersion()
/**
* Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or \DateTime value.
* Empty strings are treated as NULL.
* @return \Thelia\Model\CouponVersion The current object (for fluent API support)
*/
public function setVersionCreatedAt($v)
{
$dt = PropelDateTime::newInstance($v, null, '\DateTime');
if ($this->version_created_at !== null || $dt !== null) {
if ($dt !== $this->version_created_at) {
$this->version_created_at = $dt;
$this->modifiedColumns[CouponVersionTableMap::VERSION_CREATED_AT] = true;
}
} // if either are not null
return $this;
} // setVersionCreatedAt()
/**
* Set the value of [version_created_by] column.
*
* @param string $v new value
* @return \Thelia\Model\CouponVersion The current object (for fluent API support)
*/
public function setVersionCreatedBy($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->version_created_by !== $v) {
$this->version_created_by = $v;
$this->modifiedColumns[CouponVersionTableMap::VERSION_CREATED_BY] = true;
}
return $this;
} // setVersionCreatedBy()
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -1124,6 +1209,15 @@ abstract class CouponVersion implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$this->version = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CouponVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CouponVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$this->version_created_by = (null !== $col) ? (string) $col : null;
$this->resetModified();
$this->setNew(false);
@@ -1132,7 +1226,7 @@ abstract class CouponVersion implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 16; // 16 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 18; // 18 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\CouponVersion object", 0, $e);
@@ -1401,6 +1495,12 @@ abstract class CouponVersion implements ActiveRecordInterface
if ($this->isColumnModified(CouponVersionTableMap::VERSION)) {
$modifiedColumns[':p' . $index++] = '`VERSION`';
}
if ($this->isColumnModified(CouponVersionTableMap::VERSION_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
}
if ($this->isColumnModified(CouponVersionTableMap::VERSION_CREATED_BY)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
}
$sql = sprintf(
'INSERT INTO `coupon_version` (%s) VALUES (%s)',
@@ -1460,6 +1560,12 @@ abstract class CouponVersion implements ActiveRecordInterface
case '`VERSION`':
$stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
break;
case '`VERSION_CREATED_AT`':
$stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`VERSION_CREATED_BY`':
$stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
@@ -1563,6 +1669,12 @@ abstract class CouponVersion implements ActiveRecordInterface
case 15:
return $this->getVersion();
break;
case 16:
return $this->getVersionCreatedAt();
break;
case 17:
return $this->getVersionCreatedBy();
break;
default:
return null;
break;
@@ -1608,6 +1720,8 @@ abstract class CouponVersion implements ActiveRecordInterface
$keys[13] => $this->getCreatedAt(),
$keys[14] => $this->getUpdatedAt(),
$keys[15] => $this->getVersion(),
$keys[16] => $this->getVersionCreatedAt(),
$keys[17] => $this->getVersionCreatedBy(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1700,6 +1814,12 @@ abstract class CouponVersion implements ActiveRecordInterface
case 15:
$this->setVersion($value);
break;
case 16:
$this->setVersionCreatedAt($value);
break;
case 17:
$this->setVersionCreatedBy($value);
break;
} // switch()
}
@@ -1740,6 +1860,8 @@ abstract class CouponVersion implements ActiveRecordInterface
if (array_key_exists($keys[13], $arr)) $this->setCreatedAt($arr[$keys[13]]);
if (array_key_exists($keys[14], $arr)) $this->setUpdatedAt($arr[$keys[14]]);
if (array_key_exists($keys[15], $arr)) $this->setVersion($arr[$keys[15]]);
if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedAt($arr[$keys[16]]);
if (array_key_exists($keys[17], $arr)) $this->setVersionCreatedBy($arr[$keys[17]]);
}
/**
@@ -1767,6 +1889,8 @@ abstract class CouponVersion implements ActiveRecordInterface
if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version);
if ($this->isColumnModified(CouponVersionTableMap::VERSION_CREATED_AT)) $criteria->add(CouponVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
if ($this->isColumnModified(CouponVersionTableMap::VERSION_CREATED_BY)) $criteria->add(CouponVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -1853,6 +1977,8 @@ abstract class CouponVersion implements ActiveRecordInterface
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setVersion($this->getVersion());
$copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
$copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($makeNew) {
$copyObj->setNew(true);
}
@@ -1952,6 +2078,8 @@ abstract class CouponVersion implements ActiveRecordInterface
$this->created_at = null;
$this->updated_at = null;
$this->version = null;
$this->version_created_at = null;
$this->version_created_by = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();

View File

@@ -37,6 +37,8 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCouponVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* @method ChildCouponVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column
* @method ChildCouponVersionQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
* @method ChildCouponVersionQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method ChildCouponVersionQuery groupById() Group by the id column
* @method ChildCouponVersionQuery groupByCode() Group by the code column
@@ -54,6 +56,8 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersionQuery groupByCreatedAt() Group by the created_at column
* @method ChildCouponVersionQuery groupByUpdatedAt() Group by the updated_at column
* @method ChildCouponVersionQuery groupByVersion() Group by the version column
* @method ChildCouponVersionQuery groupByVersionCreatedAt() Group by the version_created_at column
* @method ChildCouponVersionQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method ChildCouponVersionQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCouponVersionQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -82,6 +86,8 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersion findOneByCreatedAt(string $created_at) Return the first ChildCouponVersion filtered by the created_at column
* @method ChildCouponVersion findOneByUpdatedAt(string $updated_at) Return the first ChildCouponVersion filtered by the updated_at column
* @method ChildCouponVersion findOneByVersion(int $version) Return the first ChildCouponVersion filtered by the version column
* @method ChildCouponVersion findOneByVersionCreatedAt(string $version_created_at) Return the first ChildCouponVersion filtered by the version_created_at column
* @method ChildCouponVersion findOneByVersionCreatedBy(string $version_created_by) Return the first ChildCouponVersion filtered by the version_created_by column
*
* @method array findById(int $id) Return ChildCouponVersion objects filtered by the id column
* @method array findByCode(string $code) Return ChildCouponVersion objects filtered by the code column
@@ -99,6 +105,8 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method array findByCreatedAt(string $created_at) Return ChildCouponVersion objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCouponVersion objects filtered by the updated_at column
* @method array findByVersion(int $version) Return ChildCouponVersion objects filtered by the version column
* @method array findByVersionCreatedAt(string $version_created_at) Return ChildCouponVersion objects filtered by the version_created_at column
* @method array findByVersionCreatedBy(string $version_created_by) Return ChildCouponVersion objects filtered by the version_created_by column
*
*/
abstract class CouponVersionQuery extends ModelCriteria
@@ -187,7 +195,7 @@ abstract class CouponVersionQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `coupon_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
@@ -820,6 +828,78 @@ abstract class CouponVersionQuery extends ModelCriteria
return $this->addUsingAlias(CouponVersionTableMap::VERSION, $version, $comparison);
}
/**
* Filter the query on the version_created_at column
*
* Example usage:
* <code>
* $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
* $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
* $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
* </code>
*
* @param mixed $versionCreatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponVersionQuery The current query, for fluid interface
*/
public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
{
if (is_array($versionCreatedAt)) {
$useMinMax = false;
if (isset($versionCreatedAt['min'])) {
$this->addUsingAlias(CouponVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($versionCreatedAt['max'])) {
$this->addUsingAlias(CouponVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CouponVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
}
/**
* Filter the query on the version_created_by column
*
* Example usage:
* <code>
* $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
* $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
* </code>
*
* @param string $versionCreatedBy The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponVersionQuery The current query, for fluid interface
*/
public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($versionCreatedBy)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
$versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CouponVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Coupon object
*

View File

@@ -19,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser;
use Propel\Runtime\Util\PropelDateTime;
use Thelia\Model\Accessory as ChildAccessory;
use Thelia\Model\AccessoryQuery as ChildAccessoryQuery;
use Thelia\Model\Brand as ChildBrand;
use Thelia\Model\BrandQuery as ChildBrandQuery;
use Thelia\Model\CartItem as ChildCartItem;
use Thelia\Model\CartItemQuery as ChildCartItemQuery;
use Thelia\Model\Category as ChildCategory;
@@ -120,6 +122,12 @@ abstract class Product implements ActiveRecordInterface
*/
protected $template_id;
/**
* The value for the brand_id field.
* @var int
*/
protected $brand_id;
/**
* The value for the created_at field.
* @var string
@@ -161,6 +169,11 @@ abstract class Product implements ActiveRecordInterface
*/
protected $aTemplate;
/**
* @var Brand
*/
protected $aBrand;
/**
* @var ObjectCollection|ChildProductCategory[] Collection to store aggregation of ChildProductCategory objects.
*/
@@ -695,6 +708,17 @@ abstract class Product implements ActiveRecordInterface
return $this->template_id;
}
/**
* Get the [brand_id] column value.
*
* @return int
*/
public function getBrandId()
{
return $this->brand_id;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -911,6 +935,31 @@ abstract class Product implements ActiveRecordInterface
return $this;
} // setTemplateId()
/**
* Set the value of [brand_id] column.
*
* @param int $v new value
* @return \Thelia\Model\Product The current object (for fluent API support)
*/
public function setBrandId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->brand_id !== $v) {
$this->brand_id = $v;
$this->modifiedColumns[ProductTableMap::BRAND_ID] = true;
}
if ($this->aBrand !== null && $this->aBrand->getId() !== $v) {
$this->aBrand = null;
}
return $this;
} // setBrandId()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -1083,28 +1132,31 @@ abstract class Product implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)];
$this->template_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductTableMap::translateFieldName('BrandId', TableMap::TYPE_PHPNAME, $indexType)];
$this->brand_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$this->version = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : ProductTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$this->version_created_by = (null !== $col) ? (string) $col : null;
$this->resetModified();
@@ -1114,7 +1166,7 @@ abstract class Product implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 11; // 11 = ProductTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 12; // 12 = ProductTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Product object", 0, $e);
@@ -1142,6 +1194,9 @@ abstract class Product implements ActiveRecordInterface
if ($this->aTemplate !== null && $this->template_id !== $this->aTemplate->getId()) {
$this->aTemplate = null;
}
if ($this->aBrand !== null && $this->brand_id !== $this->aBrand->getId()) {
$this->aBrand = null;
}
} // ensureConsistency
/**
@@ -1183,6 +1238,7 @@ abstract class Product implements ActiveRecordInterface
$this->aTaxRule = null;
$this->aTemplate = null;
$this->aBrand = null;
$this->collProductCategories = null;
$this->collFeatureProducts = null;
@@ -1361,6 +1417,13 @@ abstract class Product implements ActiveRecordInterface
$this->setTemplate($this->aTemplate);
}
if ($this->aBrand !== null) {
if ($this->aBrand->isModified() || $this->aBrand->isNew()) {
$affectedRows += $this->aBrand->save($con);
}
$this->setBrand($this->aBrand);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -1684,6 +1747,9 @@ abstract class Product implements ActiveRecordInterface
if ($this->isColumnModified(ProductTableMap::TEMPLATE_ID)) {
$modifiedColumns[':p' . $index++] = '`TEMPLATE_ID`';
}
if ($this->isColumnModified(ProductTableMap::BRAND_ID)) {
$modifiedColumns[':p' . $index++] = '`BRAND_ID`';
}
if ($this->isColumnModified(ProductTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
}
@@ -1728,6 +1794,9 @@ abstract class Product implements ActiveRecordInterface
case '`TEMPLATE_ID`':
$stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT);
break;
case '`BRAND_ID`':
$stmt->bindValue($identifier, $this->brand_id, PDO::PARAM_INT);
break;
case '`CREATED_AT`':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1824,18 +1893,21 @@ abstract class Product implements ActiveRecordInterface
return $this->getTemplateId();
break;
case 6:
return $this->getCreatedAt();
return $this->getBrandId();
break;
case 7:
return $this->getUpdatedAt();
return $this->getCreatedAt();
break;
case 8:
return $this->getVersion();
return $this->getUpdatedAt();
break;
case 9:
return $this->getVersionCreatedAt();
return $this->getVersion();
break;
case 10:
return $this->getVersionCreatedAt();
break;
case 11:
return $this->getVersionCreatedBy();
break;
default:
@@ -1873,11 +1945,12 @@ abstract class Product implements ActiveRecordInterface
$keys[3] => $this->getVisible(),
$keys[4] => $this->getPosition(),
$keys[5] => $this->getTemplateId(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
$keys[8] => $this->getVersion(),
$keys[9] => $this->getVersionCreatedAt(),
$keys[10] => $this->getVersionCreatedBy(),
$keys[6] => $this->getBrandId(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
$keys[9] => $this->getVersion(),
$keys[10] => $this->getVersionCreatedAt(),
$keys[11] => $this->getVersionCreatedBy(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1891,6 +1964,9 @@ abstract class Product implements ActiveRecordInterface
if (null !== $this->aTemplate) {
$result['Template'] = $this->aTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aBrand) {
$result['Brand'] = $this->aBrand->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collProductCategories) {
$result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
@@ -1977,18 +2053,21 @@ abstract class Product implements ActiveRecordInterface
$this->setTemplateId($value);
break;
case 6:
$this->setCreatedAt($value);
$this->setBrandId($value);
break;
case 7:
$this->setUpdatedAt($value);
$this->setCreatedAt($value);
break;
case 8:
$this->setVersion($value);
$this->setUpdatedAt($value);
break;
case 9:
$this->setVersionCreatedAt($value);
$this->setVersion($value);
break;
case 10:
$this->setVersionCreatedAt($value);
break;
case 11:
$this->setVersionCreatedBy($value);
break;
} // switch()
@@ -2021,11 +2100,12 @@ abstract class Product implements ActiveRecordInterface
if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setTemplateId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setVersion($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedAt($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setVersionCreatedBy($arr[$keys[10]]);
if (array_key_exists($keys[6], $arr)) $this->setBrandId($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setVersion($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setVersionCreatedAt($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setVersionCreatedBy($arr[$keys[11]]);
}
/**
@@ -2043,6 +2123,7 @@ abstract class Product implements ActiveRecordInterface
if ($this->isColumnModified(ProductTableMap::VISIBLE)) $criteria->add(ProductTableMap::VISIBLE, $this->visible);
if ($this->isColumnModified(ProductTableMap::POSITION)) $criteria->add(ProductTableMap::POSITION, $this->position);
if ($this->isColumnModified(ProductTableMap::TEMPLATE_ID)) $criteria->add(ProductTableMap::TEMPLATE_ID, $this->template_id);
if ($this->isColumnModified(ProductTableMap::BRAND_ID)) $criteria->add(ProductTableMap::BRAND_ID, $this->brand_id);
if ($this->isColumnModified(ProductTableMap::CREATED_AT)) $criteria->add(ProductTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(ProductTableMap::UPDATED_AT)) $criteria->add(ProductTableMap::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(ProductTableMap::VERSION)) $criteria->add(ProductTableMap::VERSION, $this->version);
@@ -2116,6 +2197,7 @@ abstract class Product implements ActiveRecordInterface
$copyObj->setVisible($this->getVisible());
$copyObj->setPosition($this->getPosition());
$copyObj->setTemplateId($this->getTemplateId());
$copyObj->setBrandId($this->getBrandId());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setVersion($this->getVersion());
@@ -2325,6 +2407,57 @@ abstract class Product implements ActiveRecordInterface
return $this->aTemplate;
}
/**
* Declares an association between this object and a ChildBrand object.
*
* @param ChildBrand $v
* @return \Thelia\Model\Product The current object (for fluent API support)
* @throws PropelException
*/
public function setBrand(ChildBrand $v = null)
{
if ($v === null) {
$this->setBrandId(NULL);
} else {
$this->setBrandId($v->getId());
}
$this->aBrand = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildBrand object, it will not be re-added.
if ($v !== null) {
$v->addProduct($this);
}
return $this;
}
/**
* Get the associated ChildBrand object
*
* @param ConnectionInterface $con Optional Connection object.
* @return ChildBrand The associated ChildBrand object.
* @throws PropelException
*/
public function getBrand(ConnectionInterface $con = null)
{
if ($this->aBrand === null && ($this->brand_id !== null)) {
$this->aBrand = ChildBrandQuery::create()->findPk($this->brand_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aBrand->addProducts($this);
*/
}
return $this->aBrand;
}
/**
* Initializes a collection based on the name of a relation.
@@ -5492,6 +5625,7 @@ abstract class Product implements ActiveRecordInterface
$this->visible = null;
$this->position = null;
$this->template_id = null;
$this->brand_id = null;
$this->created_at = null;
$this->updated_at = null;
$this->version = null;
@@ -5609,6 +5743,7 @@ abstract class Product implements ActiveRecordInterface
$this->collProductsRelatedByProductId = null;
$this->aTaxRule = null;
$this->aTemplate = null;
$this->aBrand = null;
}
/**
@@ -5956,6 +6091,7 @@ abstract class Product implements ActiveRecordInterface
$version->setVisible($this->getVisible());
$version->setPosition($this->getPosition());
$version->setTemplateId($this->getTemplateId());
$version->setBrandId($this->getBrandId());
$version->setCreatedAt($this->getCreatedAt());
$version->setUpdatedAt($this->getUpdatedAt());
$version->setVersion($this->getVersion());
@@ -6004,6 +6140,7 @@ abstract class Product implements ActiveRecordInterface
$this->setVisible($version->getVisible());
$this->setPosition($version->getPosition());
$this->setTemplateId($version->getTemplateId());
$this->setBrandId($version->getBrandId());
$this->setCreatedAt($version->getCreatedAt());
$this->setUpdatedAt($version->getUpdatedAt());
$this->setVersion($version->getVersion());

View File

@@ -28,6 +28,7 @@ use Thelia\Model\Map\ProductTableMap;
* @method ChildProductQuery orderByVisible($order = Criteria::ASC) Order by the visible column
* @method ChildProductQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildProductQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column
* @method ChildProductQuery orderByBrandId($order = Criteria::ASC) Order by the brand_id column
* @method ChildProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* @method ChildProductQuery orderByVersion($order = Criteria::ASC) Order by the version column
@@ -40,6 +41,7 @@ use Thelia\Model\Map\ProductTableMap;
* @method ChildProductQuery groupByVisible() Group by the visible column
* @method ChildProductQuery groupByPosition() Group by the position column
* @method ChildProductQuery groupByTemplateId() Group by the template_id column
* @method ChildProductQuery groupByBrandId() Group by the brand_id column
* @method ChildProductQuery groupByCreatedAt() Group by the created_at column
* @method ChildProductQuery groupByUpdatedAt() Group by the updated_at column
* @method ChildProductQuery groupByVersion() Group by the version column
@@ -58,6 +60,10 @@ use Thelia\Model\Map\ProductTableMap;
* @method ChildProductQuery rightJoinTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Template relation
* @method ChildProductQuery innerJoinTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the Template relation
*
* @method ChildProductQuery leftJoinBrand($relationAlias = null) Adds a LEFT JOIN clause to the query using the Brand relation
* @method ChildProductQuery rightJoinBrand($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Brand relation
* @method ChildProductQuery innerJoinBrand($relationAlias = null) Adds a INNER JOIN clause to the query using the Brand relation
*
* @method ChildProductQuery leftJoinProductCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductCategory relation
* @method ChildProductQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation
* @method ChildProductQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation
@@ -111,6 +117,7 @@ use Thelia\Model\Map\ProductTableMap;
* @method ChildProduct findOneByVisible(int $visible) Return the first ChildProduct filtered by the visible column
* @method ChildProduct findOneByPosition(int $position) Return the first ChildProduct filtered by the position column
* @method ChildProduct findOneByTemplateId(int $template_id) Return the first ChildProduct filtered by the template_id column
* @method ChildProduct findOneByBrandId(int $brand_id) Return the first ChildProduct filtered by the brand_id column
* @method ChildProduct findOneByCreatedAt(string $created_at) Return the first ChildProduct filtered by the created_at column
* @method ChildProduct findOneByUpdatedAt(string $updated_at) Return the first ChildProduct filtered by the updated_at column
* @method ChildProduct findOneByVersion(int $version) Return the first ChildProduct filtered by the version column
@@ -123,6 +130,7 @@ use Thelia\Model\Map\ProductTableMap;
* @method array findByVisible(int $visible) Return ChildProduct objects filtered by the visible column
* @method array findByPosition(int $position) Return ChildProduct objects filtered by the position column
* @method array findByTemplateId(int $template_id) Return ChildProduct objects filtered by the template_id column
* @method array findByBrandId(int $brand_id) Return ChildProduct objects filtered by the brand_id column
* @method array findByCreatedAt(string $created_at) Return ChildProduct objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildProduct objects filtered by the updated_at column
* @method array findByVersion(int $version) Return ChildProduct objects filtered by the version column
@@ -223,7 +231,7 @@ abstract class ProductQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `VISIBLE`, `POSITION`, `TEMPLATE_ID`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product` WHERE `ID` = :p0';
$sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `VISIBLE`, `POSITION`, `TEMPLATE_ID`, `BRAND_ID`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -550,6 +558,49 @@ abstract class ProductQuery extends ModelCriteria
return $this->addUsingAlias(ProductTableMap::TEMPLATE_ID, $templateId, $comparison);
}
/**
* Filter the query on the brand_id column
*
* Example usage:
* <code>
* $query->filterByBrandId(1234); // WHERE brand_id = 1234
* $query->filterByBrandId(array(12, 34)); // WHERE brand_id IN (12, 34)
* $query->filterByBrandId(array('min' => 12)); // WHERE brand_id > 12
* </code>
*
* @see filterByBrand()
*
* @param mixed $brandId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildProductQuery The current query, for fluid interface
*/
public function filterByBrandId($brandId = null, $comparison = null)
{
if (is_array($brandId)) {
$useMinMax = false;
if (isset($brandId['min'])) {
$this->addUsingAlias(ProductTableMap::BRAND_ID, $brandId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($brandId['max'])) {
$this->addUsingAlias(ProductTableMap::BRAND_ID, $brandId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ProductTableMap::BRAND_ID, $brandId, $comparison);
}
/**
* Filter the query on the created_at column
*
@@ -899,6 +950,81 @@ abstract class ProductQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Template', '\Thelia\Model\TemplateQuery');
}
/**
* Filter the query by a related \Thelia\Model\Brand object
*
* @param \Thelia\Model\Brand|ObjectCollection $brand The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildProductQuery The current query, for fluid interface
*/
public function filterByBrand($brand, $comparison = null)
{
if ($brand instanceof \Thelia\Model\Brand) {
return $this
->addUsingAlias(ProductTableMap::BRAND_ID, $brand->getId(), $comparison);
} elseif ($brand instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(ProductTableMap::BRAND_ID, $brand->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByBrand() only accepts arguments of type \Thelia\Model\Brand or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Brand relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildProductQuery The current query, for fluid interface
*/
public function joinBrand($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Brand');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Brand');
}
return $this;
}
/**
* Use the Brand relation Brand object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\BrandQuery A secondary query class using the current class as primary query
*/
public function useBrandQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinBrand($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Brand', '\Thelia\Model\BrandQuery');
}
/**
* Filter the query by a related \Thelia\Model\ProductCategory object
*

View File

@@ -93,6 +93,12 @@ abstract class ProductVersion implements ActiveRecordInterface
*/
protected $template_id;
/**
* The value for the brand_id field.
* @var int
*/
protected $brand_id;
/**
* The value for the created_at field.
* @var string
@@ -476,6 +482,17 @@ abstract class ProductVersion implements ActiveRecordInterface
return $this->template_id;
}
/**
* Get the [brand_id] column value.
*
* @return int
*/
public function getBrandId()
{
return $this->brand_id;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -688,6 +705,27 @@ abstract class ProductVersion implements ActiveRecordInterface
return $this;
} // setTemplateId()
/**
* Set the value of [brand_id] column.
*
* @param int $v new value
* @return \Thelia\Model\ProductVersion The current object (for fluent API support)
*/
public function setBrandId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->brand_id !== $v) {
$this->brand_id = $v;
$this->modifiedColumns[ProductVersionTableMap::BRAND_ID] = true;
}
return $this;
} // setBrandId()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -860,28 +898,31 @@ abstract class ProductVersion implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductVersionTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)];
$this->template_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductVersionTableMap::translateFieldName('BrandId', TableMap::TYPE_PHPNAME, $indexType)];
$this->brand_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$this->version = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$this->version_created_by = (null !== $col) ? (string) $col : null;
$this->resetModified();
@@ -891,7 +932,7 @@ abstract class ProductVersion implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 11; // 11 = ProductVersionTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 12; // 12 = ProductVersionTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\ProductVersion object", 0, $e);
@@ -1130,6 +1171,9 @@ abstract class ProductVersion implements ActiveRecordInterface
if ($this->isColumnModified(ProductVersionTableMap::TEMPLATE_ID)) {
$modifiedColumns[':p' . $index++] = '`TEMPLATE_ID`';
}
if ($this->isColumnModified(ProductVersionTableMap::BRAND_ID)) {
$modifiedColumns[':p' . $index++] = '`BRAND_ID`';
}
if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
}
@@ -1174,6 +1218,9 @@ abstract class ProductVersion implements ActiveRecordInterface
case '`TEMPLATE_ID`':
$stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT);
break;
case '`BRAND_ID`':
$stmt->bindValue($identifier, $this->brand_id, PDO::PARAM_INT);
break;
case '`CREATED_AT`':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1263,18 +1310,21 @@ abstract class ProductVersion implements ActiveRecordInterface
return $this->getTemplateId();
break;
case 6:
return $this->getCreatedAt();
return $this->getBrandId();
break;
case 7:
return $this->getUpdatedAt();
return $this->getCreatedAt();
break;
case 8:
return $this->getVersion();
return $this->getUpdatedAt();
break;
case 9:
return $this->getVersionCreatedAt();
return $this->getVersion();
break;
case 10:
return $this->getVersionCreatedAt();
break;
case 11:
return $this->getVersionCreatedBy();
break;
default:
@@ -1312,11 +1362,12 @@ abstract class ProductVersion implements ActiveRecordInterface
$keys[3] => $this->getVisible(),
$keys[4] => $this->getPosition(),
$keys[5] => $this->getTemplateId(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
$keys[8] => $this->getVersion(),
$keys[9] => $this->getVersionCreatedAt(),
$keys[10] => $this->getVersionCreatedBy(),
$keys[6] => $this->getBrandId(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
$keys[9] => $this->getVersion(),
$keys[10] => $this->getVersionCreatedAt(),
$keys[11] => $this->getVersionCreatedBy(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1380,18 +1431,21 @@ abstract class ProductVersion implements ActiveRecordInterface
$this->setTemplateId($value);
break;
case 6:
$this->setCreatedAt($value);
$this->setBrandId($value);
break;
case 7:
$this->setUpdatedAt($value);
$this->setCreatedAt($value);
break;
case 8:
$this->setVersion($value);
$this->setUpdatedAt($value);
break;
case 9:
$this->setVersionCreatedAt($value);
$this->setVersion($value);
break;
case 10:
$this->setVersionCreatedAt($value);
break;
case 11:
$this->setVersionCreatedBy($value);
break;
} // switch()
@@ -1424,11 +1478,12 @@ abstract class ProductVersion implements ActiveRecordInterface
if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setTemplateId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setVersion($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedAt($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setVersionCreatedBy($arr[$keys[10]]);
if (array_key_exists($keys[6], $arr)) $this->setBrandId($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setVersion($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setVersionCreatedAt($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setVersionCreatedBy($arr[$keys[11]]);
}
/**
@@ -1446,6 +1501,7 @@ abstract class ProductVersion implements ActiveRecordInterface
if ($this->isColumnModified(ProductVersionTableMap::VISIBLE)) $criteria->add(ProductVersionTableMap::VISIBLE, $this->visible);
if ($this->isColumnModified(ProductVersionTableMap::POSITION)) $criteria->add(ProductVersionTableMap::POSITION, $this->position);
if ($this->isColumnModified(ProductVersionTableMap::TEMPLATE_ID)) $criteria->add(ProductVersionTableMap::TEMPLATE_ID, $this->template_id);
if ($this->isColumnModified(ProductVersionTableMap::BRAND_ID)) $criteria->add(ProductVersionTableMap::BRAND_ID, $this->brand_id);
if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) $criteria->add(ProductVersionTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(ProductVersionTableMap::UPDATED_AT)) $criteria->add(ProductVersionTableMap::UPDATED_AT, $this->updated_at);
if ($this->isColumnModified(ProductVersionTableMap::VERSION)) $criteria->add(ProductVersionTableMap::VERSION, $this->version);
@@ -1527,6 +1583,7 @@ abstract class ProductVersion implements ActiveRecordInterface
$copyObj->setVisible($this->getVisible());
$copyObj->setPosition($this->getPosition());
$copyObj->setTemplateId($this->getTemplateId());
$copyObj->setBrandId($this->getBrandId());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
$copyObj->setVersion($this->getVersion());
@@ -1621,6 +1678,7 @@ abstract class ProductVersion implements ActiveRecordInterface
$this->visible = null;
$this->position = null;
$this->template_id = null;
$this->brand_id = null;
$this->created_at = null;
$this->updated_at = null;
$this->version = null;

View File

@@ -27,6 +27,7 @@ use Thelia\Model\Map\ProductVersionTableMap;
* @method ChildProductVersionQuery orderByVisible($order = Criteria::ASC) Order by the visible column
* @method ChildProductVersionQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildProductVersionQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column
* @method ChildProductVersionQuery orderByBrandId($order = Criteria::ASC) Order by the brand_id column
* @method ChildProductVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildProductVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* @method ChildProductVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column
@@ -39,6 +40,7 @@ use Thelia\Model\Map\ProductVersionTableMap;
* @method ChildProductVersionQuery groupByVisible() Group by the visible column
* @method ChildProductVersionQuery groupByPosition() Group by the position column
* @method ChildProductVersionQuery groupByTemplateId() Group by the template_id column
* @method ChildProductVersionQuery groupByBrandId() Group by the brand_id column
* @method ChildProductVersionQuery groupByCreatedAt() Group by the created_at column
* @method ChildProductVersionQuery groupByUpdatedAt() Group by the updated_at column
* @method ChildProductVersionQuery groupByVersion() Group by the version column
@@ -62,6 +64,7 @@ use Thelia\Model\Map\ProductVersionTableMap;
* @method ChildProductVersion findOneByVisible(int $visible) Return the first ChildProductVersion filtered by the visible column
* @method ChildProductVersion findOneByPosition(int $position) Return the first ChildProductVersion filtered by the position column
* @method ChildProductVersion findOneByTemplateId(int $template_id) Return the first ChildProductVersion filtered by the template_id column
* @method ChildProductVersion findOneByBrandId(int $brand_id) Return the first ChildProductVersion filtered by the brand_id column
* @method ChildProductVersion findOneByCreatedAt(string $created_at) Return the first ChildProductVersion filtered by the created_at column
* @method ChildProductVersion findOneByUpdatedAt(string $updated_at) Return the first ChildProductVersion filtered by the updated_at column
* @method ChildProductVersion findOneByVersion(int $version) Return the first ChildProductVersion filtered by the version column
@@ -74,6 +77,7 @@ use Thelia\Model\Map\ProductVersionTableMap;
* @method array findByVisible(int $visible) Return ChildProductVersion objects filtered by the visible column
* @method array findByPosition(int $position) Return ChildProductVersion objects filtered by the position column
* @method array findByTemplateId(int $template_id) Return ChildProductVersion objects filtered by the template_id column
* @method array findByBrandId(int $brand_id) Return ChildProductVersion objects filtered by the brand_id column
* @method array findByCreatedAt(string $created_at) Return ChildProductVersion objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildProductVersion objects filtered by the updated_at column
* @method array findByVersion(int $version) Return ChildProductVersion objects filtered by the version column
@@ -167,7 +171,7 @@ abstract class ProductVersionQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `VISIBLE`, `POSITION`, `TEMPLATE_ID`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
$sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `VISIBLE`, `POSITION`, `TEMPLATE_ID`, `BRAND_ID`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
@@ -504,6 +508,47 @@ abstract class ProductVersionQuery extends ModelCriteria
return $this->addUsingAlias(ProductVersionTableMap::TEMPLATE_ID, $templateId, $comparison);
}
/**
* Filter the query on the brand_id column
*
* Example usage:
* <code>
* $query->filterByBrandId(1234); // WHERE brand_id = 1234
* $query->filterByBrandId(array(12, 34)); // WHERE brand_id IN (12, 34)
* $query->filterByBrandId(array('min' => 12)); // WHERE brand_id > 12
* </code>
*
* @param mixed $brandId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildProductVersionQuery The current query, for fluid interface
*/
public function filterByBrandId($brandId = null, $comparison = null)
{
if (is_array($brandId)) {
$useMinMax = false;
if (isset($brandId['min'])) {
$this->addUsingAlias(ProductVersionTableMap::BRAND_ID, $brandId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($brandId['max'])) {
$this->addUsingAlias(ProductVersionTableMap::BRAND_ID, $brandId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ProductVersionTableMap::BRAND_ID, $brandId, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -1545,6 +1545,31 @@ abstract class TaxRule implements ActiveRecordInterface
return $this->getProducts($query, $con);
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this TaxRule is new, it will return
* an empty collection; or if this TaxRule has previously
* been saved, it will retrieve related Products from storage.
*
* This method is protected by default in order to keep the public
* api reasonable. You can provide public methods for those you
* actually need in TaxRule.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param ConnectionInterface $con optional connection object
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
* @return Collection|ChildProduct[] List of ChildProduct objects
*/
public function getProductsJoinBrand($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildProductQuery::create(null, $criteria);
$query->joinWith('Brand', $joinBehavior);
return $this->getProducts($query, $con);
}
/**
* Clears out the collTaxRuleCountries collection
*

View File

@@ -1589,6 +1589,31 @@ abstract class Template implements ActiveRecordInterface
return $this->getProducts($query, $con);
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this Template is new, it will return
* an empty collection; or if this Template has previously
* been saved, it will retrieve related Products from storage.
*
* This method is protected by default in order to keep the public
* api reasonable. You can provide public methods for those you
* actually need in Template.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param ConnectionInterface $con optional connection object
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
* @return Collection|ChildProduct[] List of ChildProduct objects
*/
public function getProductsJoinBrand($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildProductQuery::create(null, $criteria);
$query->joinWith('Brand', $joinBehavior);
return $this->getProducts($query, $con);
}
/**
* Clears out the collFeatureTemplates collection
*

View File

@@ -0,0 +1,88 @@
<?php
namespace Thelia\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Event\Brand\BrandEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Files\FileModelParentInterface;
use Thelia\Model\Base\Brand as BaseBrand;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
use Thelia\Model\Tools\PositionManagementTrait;
use Thelia\Model\Tools\UrlRewritingTrait;
class Brand extends BaseBrand implements FileModelParentInterface
{
use ModelEventDispatcherTrait;
use PositionManagementTrait;
use UrlRewritingTrait;
/**
* {@inheritDoc}
*/
protected function getRewrittenUrlViewName()
{
return 'brand';
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEBRAND, new BrandEvent($this));
// Set the current position for the new object
$this->setPosition($this->getNextPosition());
return true;
}
/**
* {@inheritDoc}
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CREATEBRAND, new BrandEvent($this));
}
/**
* {@inheritDoc}
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEBRAND, new BrandEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEBRAND, new BrandEvent($this));
}
/**
* {@inheritDoc}
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEBRAND, new BrandEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEBRAND, new BrandEvent($this));
}
}

View File

@@ -0,0 +1,130 @@
<?php
namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Files\FileModelInterface;
use Thelia\Files\FileModelParentInterface;
use Thelia\Form\BaseForm;
use Thelia\Form\Brand\BrandDocumentModification;
use Thelia\Model\Base\BrandDocument as BaseBrandDocument;
use Thelia\Model\Breadcrumb\BrandBreadcrumbTrait;
use Thelia\Model\Breadcrumb\BreadcrumbInterface;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
use Thelia\Model\Tools\PositionManagementTrait;
class BrandDocument extends BaseBrandDocument implements BreadcrumbInterface, FileModelInterface
{
use ModelEventDispatcherTrait;
use PositionManagementTrait;
use BrandBreadcrumbTrait;
/**
* Calculate next position relative to our parent
*
* @param BrandDocumentQuery $query
*/
protected function addCriteriaToPositionQuery($query)
{
$query->filterByBrandId($this->getBrandId());
}
/**
* @inheritDoc
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setPosition($this->getNextPosition());
return true;
}
public function preDelete(ConnectionInterface $con = null)
{
$this->reorderBeforeDelete(
array(
"brand_id" => $this->getBrandId(),
)
);
return true;
}
/**
* @inheritDoc
*/
public function setParentId($parentId)
{
$this->setBrandId($parentId);
return $this;
}
/**
* @inheritDoc
*/
public function getParentId()
{
return $this->getBrandId();
}
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel()
{
return new Brand();
}
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId()
{
return 'thelia.admin.brand.document.modification';
}
/**
* Get the form instance used to change this object information
*
* @param \Thelia\Core\HttpFoundation\Request $request
*
* @return BaseForm the form
*/
public function getUpdateFormInstance(Request $request)
{
return new BrandDocumentModification($request);
}
/**
* @return string the path to the upload directory where files are stored, without final slash
*/
public function getUploadDir()
{
return THELIA_LOCAL_DIR . 'media'.DS.'documents'.DS.'brand';
}
/**
* @param int $objectId the ID of the object
*
* @return string the URL to redirect to after update from the back-office
*/
public function getRedirectionUrl()
{
return '/admin/brand/update/' . $this->getBrandId();
}
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance()
{
return BrandDocumentQuery::create();
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandDocumentI18n as BaseBrandDocumentI18n;
class BrandDocumentI18n extends BaseBrandDocumentI18n
{
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandDocumentI18nQuery as BaseBrandDocumentI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'brand_document_i18n' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class BrandDocumentI18nQuery extends BaseBrandDocumentI18nQuery
{
} // BrandDocumentI18nQuery

View File

@@ -0,0 +1,20 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandDocumentQuery as BaseBrandDocumentQuery;
/**
* Skeleton subclass for performing query and update operations on the 'brand_document' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class BrandDocumentQuery extends BaseBrandDocumentQuery
{
} // BrandDocumentQuery

View File

@@ -0,0 +1,16 @@
<?php
namespace Thelia\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Base\BrandI18n as BaseBrandI18n;
class BrandI18n extends BaseBrandI18n
{
public function postInsert(ConnectionInterface $con = null)
{
$content = $this->getBrand();
$content->generateRewrittenUrl($this->getLocale());
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandI18nQuery as BaseBrandI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'brand_i18n' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class BrandI18nQuery extends BaseBrandI18nQuery
{
} // BrandI18nQuery

View File

@@ -0,0 +1,130 @@
<?php
namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Files\FileModelParentInterface;
use Thelia\Form\BaseForm;
use Thelia\Form\Brand\BrandImageModification;
use Thelia\Model\Base\BrandImage as BaseBrandImage;
use Thelia\Model\Breadcrumb\BrandBreadcrumbTrait;
use Thelia\Model\Breadcrumb\BreadcrumbInterface;
use Thelia\Files\FileModelInterface;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
use Thelia\Model\Tools\PositionManagementTrait;
class BrandImage extends BaseBrandImage implements FileModelInterface, BreadcrumbInterface
{
use ModelEventDispatcherTrait;
use PositionManagementTrait;
use BrandBreadcrumbTrait;
/**
* Calculate next position relative to our parent
*
* @param BrandImageQuery $query
*/
protected function addCriteriaToPositionQuery($query)
{
$query->filterByBrandId($this->getBrandId());
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setPosition($this->getNextPosition());
return true;
}
public function preDelete(ConnectionInterface $con = null)
{
$this->reorderBeforeDelete(
array(
"brand_id" => $this->getBrandId(),
)
);
return true;
}
/**
* @inheritdoc
*/
public function setParentId($parentId)
{
$this->setBrandId($parentId);
return $this;
}
/**
* @inheritdoc
*/
public function getParentId()
{
return $this->getBrandId();
}
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel()
{
return new Brand();
}
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId()
{
return 'thelia.admin.brand.image.modification';
}
/**
* Get the form instance used to change this object information
*
* @param \Thelia\Core\HttpFoundation\Request $request
*
* @return BaseForm the form
*/
public function getUpdateFormInstance(Request $request)
{
return new BrandImageModification($request);
}
/**
* @return string the path to the upload directory where files are stored, without final slash
*/
public function getUploadDir()
{
return THELIA_LOCAL_DIR . 'media'.DS.'images'.DS.'brand';
}
/**
* @param int $objectId the ID of the object
*
* @return string the URL to redirect to after update from the back-office
*/
public function getRedirectionUrl()
{
return '/admin/brand/update/' . $this->getBrandId();
}
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance()
{
return BrandImageQuery::create();
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandImageI18n as BaseBrandImageI18n;
class BrandImageI18n extends BaseBrandImageI18n
{
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandImageI18nQuery as BaseBrandImageI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'brand_image_i18n' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class BrandImageI18nQuery extends BaseBrandImageI18nQuery
{
} // BrandImageI18nQuery

View File

@@ -0,0 +1,20 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandImageQuery as BaseBrandImageQuery;
/**
* Skeleton subclass for performing query and update operations on the 'brand_image' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class BrandImageQuery extends BaseBrandImageQuery
{
} // BrandImageQuery

View File

@@ -0,0 +1,20 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\BrandQuery as BaseBrandQuery;
/**
* Skeleton subclass for performing query and update operations on the 'brand' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class BrandQuery extends BaseBrandQuery
{
} // BrandQuery

View File

@@ -0,0 +1,43 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Model\Breadcrumb;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Router;
use Thelia\Core\Translation\Translator;
use Thelia\Model\BrandQuery;
trait BrandBreadcrumbTrait
{
/**
* @inheritdoc
*/
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
{
$breadcrumb = [
Translator::getInstance()->trans('Home') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL),
Translator::getInstance()->trans('Brand') => $router->generate('admin.brand.default', [], Router::ABSOLUTE_URL)
];
if (null !== $brand = BrandQuery::create()->findPk($this->getBrandId())) {
$breadcrumb[$brand->setLocale($locale)->getTitle()] = sprintf(
"%s?current_tab=%s",
$router->generate('admin.brand.update', ['brand_id' => $brand->getId()], Router::ABSOLUTE_URL),
$tab
);
}
return $breadcrumb;
}
}

View File

@@ -19,10 +19,14 @@ interface BreadcrumbInterface
{
/**
* Create a breadcrumb from the current object, that will be displayed to the file management UI
*
* return the complete breadcrumb for a given resource.
* @param Router $router the router where to find routes
* @param ContainerInterface $container the container
* @param string $tab the tab to return to (probably 'image' or 'document')
* @param string $locale the current locale
*
* @return array
* @return array an array of (label => URL)
*/
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab);
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale);
}

View File

@@ -17,17 +17,19 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Router;
use Thelia\Core\Template\Loop\CategoryPath;
use Thelia\Core\Translation\Translator;
use Thelia\Model\Category;
use Thelia\Model\Product;
trait CatalogBreadcrumbTrait
{
public function getBaseBreadcrumb(Router $router, ContainerInterface $container, $categoryId, &$locale)
public function getBaseBreadcrumb(Router $router, ContainerInterface $container, $categoryId)
{
$translator = Translator::getInstance();
$catalogUrl = $router->generate('admin.catalog', [], Router::ABSOLUTE_URL);
$breadcrumb = [
$translator->trans('Home', [], 'bo.default') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL),
$translator->trans('Catalog', [], 'bo.default') => $catalogUrl,
$translator->trans('Home') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL),
$translator->trans('Catalog') => $catalogUrl,
];
$categoryPath = new CategoryPath($container);
@@ -42,15 +44,13 @@ trait CatalogBreadcrumbTrait
$breadcrumb[$result['TITLE']] = sprintf("%s?category_id=%d",$catalogUrl, $result['ID']);
}
$locale = $result['LOCALE'];
return $breadcrumb;
}
public function getProductBreadcrumb(Router $router, ContainerInterface $container, $tab)
public function getProductBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
{
/** @var Product $product */
$product = $this->getProduct();
$locale = null;
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $product->getDefaultCategoryId(), $locale);
@@ -65,11 +65,11 @@ trait CatalogBreadcrumbTrait
return $breadcrumb;
}
public function getCategoryBreadcrumb(Router $router, ContainerInterface $container, $tab)
public function getCategoryBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
{
$locale = null;
/** @var Category $category */
$category = $this->getCategory();
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $this->getParentId(), $locale);
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $this->getParentId());
$category->setLocale($locale);

View File

@@ -17,17 +17,19 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Router;
use Thelia\Core\Template\Loop\FolderPath;
use Thelia\Core\Translation\Translator;
use Thelia\Model\Content;
use Thelia\Model\Folder;
trait FolderBreadcrumbTrait
{
public function getBaseBreadcrumb(Router $router, ContainerInterface $container, $folderId, &$locale)
public function getBaseBreadcrumb(Router $router, ContainerInterface $container, $folderId)
{
$translator = Translator::getInstance();
$catalogUrl = $router->generate('admin.catalog', [], Router::ABSOLUTE_URL);
$breadcrumb = [
$translator->trans('Home', [], 'bo.default') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL),
$translator->trans('Folder', [], 'bo.default') => $catalogUrl,
$translator->trans('Home') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL),
$translator->trans('Folder') => $catalogUrl,
];
$folderPath = new FolderPath($container);
@@ -45,16 +47,14 @@ trait FolderBreadcrumbTrait
);
}
$locale = $result['LOCALE'];
return $breadcrumb;
}
public function getFolderBreadcrumb($router, $container, $tab)
public function getFolderBreadcrumb(Router $router, $container, $tab, $locale)
{
$locale = null;
/** @var Folder $folder */
$folder = $this->getFolder();
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $this->getParentId(), $locale);
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $this->getParentId());
$folder->setLocale($locale);
@@ -66,12 +66,12 @@ trait FolderBreadcrumbTrait
return $breadcrumb;
}
public function getContentBreadcrumb(Router $router, ContainerInterface $container, $tab)
public function getContentBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
{
/** @var Content $content */
$content = $this->getContent();
$locale = null;
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $content->getDefaultFolderId(), $locale);
$breadcrumb = $this->getBaseBreadcrumb($router, $container, $content->getDefaultFolderId());
$content->setLocale($locale);

View File

@@ -3,18 +3,22 @@
namespace Thelia\Model;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Files\FileModelParentInterface;
use Thelia\Model\Base\Category as BaseCategory;
use Thelia\Core\Event\TheliaEvents;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
use Thelia\Model\Tools\PositionManagementTrait;
use Thelia\Model\Tools\UrlRewritingTrait;
class Category extends BaseCategory
class Category extends BaseCategory implements FileModelParentInterface
{
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
use PositionManagementTrait;
use \Thelia\Model\Tools\UrlRewritingTrait;
use UrlRewritingTrait;
/**
* @return int number of child for the current category
@@ -58,7 +62,7 @@ class Category extends BaseCategory
/**
* Get the root category
* @param int $categoryId
* @param int $categoryId
* @return mixed
*/
public function getRoot($categoryId)
@@ -66,7 +70,7 @@ class Category extends BaseCategory
$category = CategoryQuery::create()->findPk($categoryId);
if(0 !== $category->getParent()) {
if (0 !== $category->getParent()) {
$parentCategory = CategoryQuery::create()->findPk($category->getParent());
if (null !== $parentCategory) {

View File

@@ -2,16 +2,22 @@
namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Router;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Files\FileModelParentInterface;
use Thelia\Form\BaseForm;
use Thelia\Form\CategoryDocumentModification;
use Thelia\Model\Base\CategoryDocument as BaseCategoryDocument;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Breadcrumb\BreadcrumbInterface;
use Thelia\Model\Breadcrumb\CatalogBreadcrumbTrait;
use Thelia\Files\FileModelInterface;
use Thelia\Model\Tools\PositionManagementTrait;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterface
class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterface, FileModelInterface
{
use ModelEventDispatcherTrait;
use PositionManagementTrait;
@@ -19,6 +25,8 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa
/**
* Calculate next position relative to our parent
*
* @param CategoryDocumentQuery $query
*/
protected function addCriteriaToPositionQuery($query)
{
@@ -36,11 +44,7 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa
}
/**
* Set Document parent id
*
* @param int $parentId parent id
*
* @return $this
* @inheritdoc
*/
public function setParentId($parentId)
{
@@ -50,9 +54,7 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa
}
/**
* Get Document parent id
*
* @return int parent id
* @inheritdoc
*/
public function getParentId()
{
@@ -71,13 +73,68 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa
}
/**
*
* return the complete breadcrumb for a given resource.
*
* @return array
* @inheritdoc
*/
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab)
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
{
return $this->getCategoryBreadcrumb($router, $container, $tab);
return $this->getCategoryBreadcrumb($router, $container, $tab, $locale);
}
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel()
{
return new Category();
}
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId()
{
return 'thelia.admin.category.document.modification';
}
/**
* Get the form instance used to change this object information
*
* @param \Thelia\Core\HttpFoundation\Request $request
*
* @return BaseForm the form
*/
public function getUpdateFormInstance(Request $request)
{
return new CategoryDocumentModification($request);
}
/**
* @return string the path to the upload directory where files are stored, without final slash
*/
public function getUploadDir()
{
return THELIA_LOCAL_DIR . 'media'.DS.'documents'.DS.'category';
}
/**
* @param int $objectId the ID of the object
*
* @return string the URL to redirect to after update from the back-office
*/
public function getRedirectionUrl()
{
return '/admin/categories/update?category_id=' . $this->getCategoryId();
}
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance()
{
return CategoryDocumentQuery::create();
}
}

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