Inital commit
This commit is contained in:
@@ -26,7 +26,6 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
||||
*/
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
|
||||
public $kernel;
|
||||
|
||||
public function __construct(KernelInterface $kernel)
|
||||
@@ -35,6 +34,8 @@ class Application extends BaseApplication
|
||||
|
||||
parent::__construct("Thelia", Thelia::THELIA_VERSION);
|
||||
|
||||
$this->kernel->boot();
|
||||
|
||||
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
|
||||
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
|
||||
}
|
||||
@@ -53,13 +54,15 @@ class Application extends BaseApplication
|
||||
{
|
||||
$this->registerCommands();
|
||||
|
||||
/** @var \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher $eventDispatcher */
|
||||
$eventDispatcher = $this->getContainer()->get('event_dispatcher');
|
||||
$this->setDispatcher($eventDispatcher);
|
||||
|
||||
return parent::doRun($input, $output);
|
||||
}
|
||||
|
||||
protected function registerCommands()
|
||||
{
|
||||
$this->kernel->boot();
|
||||
|
||||
$container = $this->kernel->getContainer();
|
||||
|
||||
foreach ($container->getParameter("command.definition") as $command) {
|
||||
@@ -69,6 +72,5 @@ class Application extends BaseApplication
|
||||
$this->add($r->newInstance());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
89
core/lib/Thelia/Core/Archiver/AbstractArchiver.php
Normal file
89
core/lib/Thelia/Core/Archiver/AbstractArchiver.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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\Archiver;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class AbstractArchiver
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
abstract class AbstractArchiver implements ArchiverInterface
|
||||
{
|
||||
/**
|
||||
* @var mixed The archive resource
|
||||
*/
|
||||
protected $archive;
|
||||
|
||||
/**
|
||||
* @var string Path to archive
|
||||
*/
|
||||
protected $archivePath;
|
||||
|
||||
public function __construct($checkIsAvailable = false)
|
||||
{
|
||||
if ($checkIsAvailable && !$this->isAvailable()) {
|
||||
throw new \Exception(
|
||||
Translator::getInstance()->trans(
|
||||
"The archiver :name is not available. Please install the php extension :extension first.",
|
||||
[
|
||||
':name' => $this->getName(),
|
||||
':extension' => $this->getExtension(),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getArchivePath()
|
||||
{
|
||||
return $this->archivePath;
|
||||
}
|
||||
|
||||
public function setArchivePath($archivePath)
|
||||
{
|
||||
$this->archivePath = $archivePath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function add($path, $pathInArchive = null)
|
||||
{
|
||||
$path = realpath($path);
|
||||
if (!file_exists($path)) {
|
||||
throw new \RuntimeException('File ' . $path . ' doesn\'t exists');
|
||||
}
|
||||
|
||||
if ($pathInArchive === null) {
|
||||
$pathInArchive = basename($path);
|
||||
}
|
||||
|
||||
if (is_dir($path)) {
|
||||
foreach (new \DirectoryIterator($path) as $dirItem) {
|
||||
if ($dirItem->isDot()) {
|
||||
continue;
|
||||
}
|
||||
$this->add($dirItem->getPathname(), $pathInArchive . DS . $dirItem->getFilename());
|
||||
}
|
||||
} else {
|
||||
$this->archive->addFile($path, $pathInArchive);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extract($toPath = null)
|
||||
{
|
||||
$this->archive->extractTo($toPath);
|
||||
}
|
||||
}
|
||||
84
core/lib/Thelia/Core/Archiver/Archiver/TarArchiver.php
Normal file
84
core/lib/Thelia/Core/Archiver/Archiver/TarArchiver.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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\Archiver\Archiver;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Thelia\Core\Archiver\AbstractArchiver;
|
||||
use Thelia\Core\Archiver\ArchiverInterface;
|
||||
|
||||
/**
|
||||
* Class TarArchiver
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class TarArchiver extends AbstractArchiver
|
||||
{
|
||||
/**
|
||||
* @var integer Compression method
|
||||
*/
|
||||
const COMPRESSION_METHOD = \Phar::NONE;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return 'thelia.tar';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Tar';
|
||||
}
|
||||
|
||||
public function getExtension()
|
||||
{
|
||||
return 'tar';
|
||||
}
|
||||
|
||||
public function getMimeType()
|
||||
{
|
||||
return 'application/x-tar';
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return class_exists('\\PharData');
|
||||
}
|
||||
|
||||
public function create($baseName)
|
||||
{
|
||||
$this->archivePath = $baseName . '.' . $this->getExtension();
|
||||
|
||||
$this->archive = new \PharData($this->archivePath);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function open($path)
|
||||
{
|
||||
$this->archivePath = $path;
|
||||
|
||||
$this->archive = new \PharData($this->archivePath);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
/** @var \PharData $newArchive */
|
||||
$newArchive = $this->archive->compress(static::COMPRESSION_METHOD, $this->getExtension());
|
||||
|
||||
$fileSystem = new Filesystem;
|
||||
$fileSystem->remove($this->archivePath);
|
||||
$fileSystem->rename($newArchive->getPath(), $this->archivePath);
|
||||
|
||||
$this->archive = new \PharData($this->archivePath);
|
||||
}
|
||||
}
|
||||
47
core/lib/Thelia/Core/Archiver/Archiver/TarBz2Archiver.php
Normal file
47
core/lib/Thelia/Core/Archiver/Archiver/TarBz2Archiver.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\Archiver\Archiver;
|
||||
|
||||
/**
|
||||
* Class TarBz2Archiver
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class TarBz2Archiver extends TarArchiver
|
||||
{
|
||||
const COMPRESSION_METHOD = \Phar::BZ2;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return 'thelia.tar.bz2';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Bzip2';
|
||||
}
|
||||
|
||||
public function getExtension()
|
||||
{
|
||||
return 'bz2';
|
||||
}
|
||||
|
||||
public function getMimeType()
|
||||
{
|
||||
return 'application/x-bzip2';
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return parent::isAvailable() && extension_loaded('bz2');
|
||||
}
|
||||
}
|
||||
47
core/lib/Thelia/Core/Archiver/Archiver/TarGzArchiver.php
Normal file
47
core/lib/Thelia/Core/Archiver/Archiver/TarGzArchiver.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\Archiver\Archiver;
|
||||
|
||||
/**
|
||||
* Class TarGzArchiver
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class TarGzArchiver extends TarArchiver
|
||||
{
|
||||
const COMPRESSION_METHOD = \Phar::GZ;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return 'thelia.tar.gz';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Gz';
|
||||
}
|
||||
|
||||
public function getExtension()
|
||||
{
|
||||
return 'tgz';
|
||||
}
|
||||
|
||||
public function getMimeType()
|
||||
{
|
||||
return 'application/x-gzip';
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return parent::isAvailable() && extension_loaded('zlib');
|
||||
}
|
||||
}
|
||||
79
core/lib/Thelia/Core/Archiver/Archiver/ZipArchiver.php
Normal file
79
core/lib/Thelia/Core/Archiver/Archiver/ZipArchiver.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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\Archiver\Archiver;
|
||||
|
||||
use Thelia\Core\Archiver\AbstractArchiver;
|
||||
|
||||
/**
|
||||
* Class ZipArchiver
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class ZipArchiver extends AbstractArchiver
|
||||
{
|
||||
public function getId()
|
||||
{
|
||||
return 'thelia.zip';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Zip';
|
||||
}
|
||||
|
||||
public function getExtension()
|
||||
{
|
||||
return 'zip';
|
||||
}
|
||||
|
||||
public function getMimeType()
|
||||
{
|
||||
return 'application/zip';
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return class_exists('\\ZipArchive');
|
||||
}
|
||||
|
||||
public function create($baseName)
|
||||
{
|
||||
$this->archive = new \ZipArchive;
|
||||
|
||||
$this->archivePath = $baseName . '.' . $this->getExtension();
|
||||
|
||||
$this->archive->open($this->archivePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function open($path)
|
||||
{
|
||||
$this->archive = new \ZipArchive;
|
||||
|
||||
$this->archivePath = $path;
|
||||
|
||||
$this->archive->open($this->archivePath);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
return $this->close();
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return $this->archive->close();
|
||||
}
|
||||
}
|
||||
115
core/lib/Thelia/Core/Archiver/ArchiverInterface.php
Normal file
115
core/lib/Thelia/Core/Archiver/ArchiverInterface.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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\Archiver;
|
||||
|
||||
/**
|
||||
* Interface ArchiverInterface
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
interface ArchiverInterface
|
||||
{
|
||||
/**
|
||||
* Get archiver identifier
|
||||
*
|
||||
* @return string The archiver identifier
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Get archiver name
|
||||
*
|
||||
* @return string The archiver name
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Get archiver extension
|
||||
*
|
||||
* @return string The archiver extension
|
||||
*/
|
||||
public function getExtension();
|
||||
|
||||
/**
|
||||
* Get archiver mime type
|
||||
*
|
||||
* @return string The archiver mime type
|
||||
*/
|
||||
public function getMimeType();
|
||||
|
||||
/**
|
||||
* Get archiver availability
|
||||
*
|
||||
* @return boolean Archiver availability
|
||||
*/
|
||||
public function isAvailable();
|
||||
|
||||
/**
|
||||
* Get archive path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getArchivePath();
|
||||
|
||||
/**
|
||||
* Set archive path
|
||||
*
|
||||
* @param string $archivePath
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function setArchivePath($archivePath);
|
||||
|
||||
/**
|
||||
* Create a new archive
|
||||
*
|
||||
* @param string $baseName The archive name without extension
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function create($baseName);
|
||||
|
||||
/**
|
||||
* Open an archive
|
||||
*
|
||||
* @param string $path Path to archive
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function open($path);
|
||||
|
||||
/**
|
||||
* Add directory or file to archive
|
||||
*
|
||||
* @param string $path
|
||||
* @param null|string $pathInArchive
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function add($path, $pathInArchive = null);
|
||||
|
||||
/**
|
||||
* Save archive
|
||||
*
|
||||
* @return boolean True on success, false otherwise
|
||||
*/
|
||||
public function save();
|
||||
|
||||
/**
|
||||
* Extract archive
|
||||
*
|
||||
* @param string $toPath Where to extract
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\File\File
|
||||
*/
|
||||
public function extract($toPath);
|
||||
}
|
||||
165
core/lib/Thelia/Core/Archiver/ArchiverManager.php
Normal file
165
core/lib/Thelia/Core/Archiver/ArchiverManager.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?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\Archiver;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class ArchiverManager
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class ArchiverManager
|
||||
{
|
||||
/**
|
||||
* @var array List of handled archivers
|
||||
*/
|
||||
protected $archivers = [];
|
||||
|
||||
/**
|
||||
* Reset manager
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->archivers = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all archivers or only those match availability
|
||||
*
|
||||
* @param null|boolean $isAvailable Filter archivers by availability
|
||||
*
|
||||
* @return array All, or filtered by availability, archivers
|
||||
*/
|
||||
public function getArchivers($isAvailable = null)
|
||||
{
|
||||
if ($isAvailable === null) {
|
||||
return $this->archivers;
|
||||
}
|
||||
|
||||
$filteredArchivers = [];
|
||||
|
||||
/** @var \Thelia\Core\Archiver\ArchiverInterface $archiver */
|
||||
foreach ($this->archivers as $archiver) {
|
||||
if ($archiver->isAvailable() === (bool) $isAvailable) {
|
||||
$filteredArchivers[] = $archiver;
|
||||
}
|
||||
}
|
||||
|
||||
return $filteredArchivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an archiver exists under the given identifier
|
||||
*
|
||||
* @param string $archiverId An archiver identifier
|
||||
* @param boolean $throwException Throw exception if archiver doesn't exists or not
|
||||
*
|
||||
* @throws \InvalidArgumentException if the archiver identifier does not exist
|
||||
*
|
||||
* @return boolean True if the archiver exists, false otherwise
|
||||
*/
|
||||
public function has($archiverId, $throwException = false)
|
||||
{
|
||||
$exists = isset($this->archivers[$archiverId]);
|
||||
|
||||
if (!$exists && $throwException) {
|
||||
throw new \InvalidArgumentException(
|
||||
Translator::getInstance()->trans(
|
||||
'The archiver identifier "%archiverId" doesn\’t exist',
|
||||
[
|
||||
'%archiverId' => $archiverId
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an archiver
|
||||
*
|
||||
* @param string $archiverId An archiver identifier
|
||||
* @param null|boolean $isAvailable Filter archiver by availability
|
||||
*
|
||||
* @return null|\Thelia\Core\Archiver\ArchiverInterface Return an archiver or null depends on availability
|
||||
*/
|
||||
public function get($archiverId, $isAvailable = null)
|
||||
{
|
||||
$this->has($archiverId, true);
|
||||
|
||||
if ($isAvailable === null) {
|
||||
return $this->archivers[$archiverId];
|
||||
}
|
||||
|
||||
if ($this->archivers[$archiverId]->isAvailable() === (bool) $isAvailable) {
|
||||
return $this->archivers[$archiverId];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set archivers
|
||||
*
|
||||
* @param array $archivers An array of archiver
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function setArchivers(array $archivers)
|
||||
{
|
||||
$this->archivers = [];
|
||||
|
||||
foreach ($archivers as $archiver) {
|
||||
if (!($archiver instanceof ArchiverInterface)) {
|
||||
throw new \Exception('ArchiverManager manage only ' . __NAMESPACE__ . '\\ArchiverInterface');
|
||||
}
|
||||
|
||||
$this->archivers[$archiver->getId()] = $archiver;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an archiver
|
||||
*
|
||||
* @param \Thelia\Core\Archiver\ArchiverInterface $archiver An archiver
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function add(ArchiverInterface $archiver)
|
||||
{
|
||||
$this->archivers[$archiver->getId()] = $archiver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an archiver
|
||||
*
|
||||
* @param string $archiverId An archiver identifier
|
||||
*/
|
||||
public function remove($archiverId)
|
||||
{
|
||||
$this->has($archiverId, true);
|
||||
|
||||
unset($this->archivers[$archiverId]);
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,18 @@ namespace Thelia\Core\Bundle;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Scope;
|
||||
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterArchiveBuilderPass;
|
||||
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\CurrencyConverterProviderPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\FallbackParserPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterArchiverPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterAssetFilterPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterFormatterPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterSerializerPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterFormExtensionPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterHookListenersPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterCouponConditionPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\StackPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\TranslatorPass;
|
||||
|
||||
/**
|
||||
@@ -34,7 +37,7 @@ use Thelia\Core\DependencyInjection\Compiler\TranslatorPass;
|
||||
* @TODO register database configuration.
|
||||
*
|
||||
*
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
|
||||
class TheliaBundle extends Bundle
|
||||
@@ -50,17 +53,20 @@ class TheliaBundle extends Bundle
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container->addScope(new Scope('request'));
|
||||
|
||||
$container
|
||||
->addCompilerPass(new FallbackParserPass())
|
||||
->addCompilerPass(new TranslatorPass())
|
||||
->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_AFTER_REMOVING)
|
||||
->addCompilerPass(new RegisterParserPluginPass())
|
||||
->addCompilerPass(new RegisterHookListenersPass(), PassConfig::TYPE_AFTER_REMOVING)
|
||||
->addCompilerPass(new RegisterRouterPass())
|
||||
->addCompilerPass(new RegisterCouponPass())
|
||||
->addCompilerPass(new RegisterCouponConditionPass())
|
||||
->addCompilerPass(new RegisterArchiveBuilderPass())
|
||||
->addCompilerPass(new RegisterFormatterPass())
|
||||
->addCompilerPass(new RegisterArchiverPass)
|
||||
->addCompilerPass(new RegisterAssetFilterPass())
|
||||
->addCompilerPass(new RegisterSerializerPass)
|
||||
->addCompilerPass(new StackPass())
|
||||
->addCompilerPass(new RegisterFormExtensionPass())
|
||||
->addCompilerPass(new CurrencyConverterProviderPass())
|
||||
->addCompilerPass(new RegisterListenersPass())
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@ namespace Thelia\Core\Controller;
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Exception\AdminAccessDenied;
|
||||
use Thelia\Controller\BaseController;
|
||||
|
||||
/**
|
||||
* ControllerResolver that supports "a:b:c", "service:method" and class::method" notations in routes definition
|
||||
@@ -59,7 +57,9 @@ class ControllerResolver extends BaseControllerResolver
|
||||
$count = substr_count($controller, ':');
|
||||
if (2 == $count) {
|
||||
// controller in the a:b:c notation then
|
||||
$controller = $this->parser->parse($controller);
|
||||
list($moduleName, $controllerName, $method) = explode(':', $controller, 3);
|
||||
$class = $moduleName . '\\Controller\\' . $controllerName . 'Controller';
|
||||
$method .= 'Action';
|
||||
} elseif (1 == $count) {
|
||||
// controller in the service:method notation
|
||||
list($service, $method) = explode(':', $controller, 2);
|
||||
@@ -68,26 +68,23 @@ class ControllerResolver extends BaseControllerResolver
|
||||
} else {
|
||||
throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller));
|
||||
}
|
||||
} else {
|
||||
list($class, $method) = explode('::', $controller, 2);
|
||||
}
|
||||
|
||||
list($class, $method) = explode('::', $controller, 2);
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||
}
|
||||
|
||||
/** @var BaseController $controller */
|
||||
$controller = new $class();
|
||||
if ($controller instanceof ContainerAwareInterface) {
|
||||
$controller->setContainer($this->container);
|
||||
}
|
||||
|
||||
//check if an admin is logged in
|
||||
if ($controller instanceof BaseAdminController) {
|
||||
$securityContext = $this->container->get('thelia.securityContext');
|
||||
$request = $this->container->get('request');
|
||||
if (false === $securityContext->hasAdminUser() && $request->attributes->get('not-logged') != 1) {
|
||||
throw new AdminAccessDenied();
|
||||
}
|
||||
$this->container->get('request_stack')->getCurrentRequest()->setControllerType(
|
||||
$controller->getControllerType()
|
||||
);
|
||||
|
||||
if (method_exists($controller, 'setContainer')) {
|
||||
$controller->setContainer($this->container);
|
||||
}
|
||||
|
||||
return array($controller, $method);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Class CurrencyConverterProviderPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CurrencyConverterProviderPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('currency.converter')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$currencyConverter = $container->getDefinition('currency.converter');
|
||||
$services = $container->findTaggedServiceIds('currency.converter.provider');
|
||||
|
||||
$providers = [];
|
||||
|
||||
foreach ($services as $id => $attributes) {
|
||||
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
|
||||
$providers[$priority] = $id;
|
||||
}
|
||||
|
||||
if (false === empty($providers)) {
|
||||
$service = array_pop($providers);
|
||||
$currencyConverter->addMethodCall('setProvider', [new Reference($service)]);
|
||||
} else {
|
||||
throw new \LogicException('the currency converter needs a provider, please define one');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
/**
|
||||
* Class FallbackParserPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class FallbackParserPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if ($container->has('thelia.parser')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$container->addDefinitions(
|
||||
[
|
||||
'thelia.parser' => new Definition("Thelia\\Core\\Template\\Parser\\ParserFallback"),
|
||||
'thelia.parser.helper' => new Definition("Thelia\\Core\\Template\\Parser\\ParserHelperFallback"),
|
||||
'thelia.parser.asset.resolver' => new Definition("Thelia\\Core\\Template\\Parser\\ParserHelperFallback")
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Class RegisterArchiverPass
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class RegisterArchiverPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @var string Archiver manager service ID
|
||||
*/
|
||||
const MANAGER_SERVICE_ID = 'thelia.archiver.manager';
|
||||
|
||||
/**
|
||||
* @var string Archiver tag name
|
||||
*/
|
||||
const ARCHIVER_SERVICE_TAG = 'thelia.archiver';
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
try {
|
||||
$manager = $container->getDefinition(self::MANAGER_SERVICE_ID);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (array_keys($container->findTaggedServiceIds(self::ARCHIVER_SERVICE_TAG)) as $serviceId) {
|
||||
$manager->addMethodCall(
|
||||
'add',
|
||||
[
|
||||
new Reference($serviceId)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Class RegisterAssetFilterPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class RegisterAssetFilterPass implements CompilerPassInterface
|
||||
{
|
||||
const MANAGER_DEFINITION = "assetic.asset.manager";
|
||||
|
||||
const SERVICE_TAG = "thelia.asset.filter";
|
||||
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
* @param ContainerBuilder $container Container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition(static::MANAGER_DEFINITION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$manager = $container->getDefinition(static::MANAGER_DEFINITION);
|
||||
$services = $container->findTaggedServiceIds(static::SERVICE_TAG);
|
||||
|
||||
foreach ($services as $id => $attributes) {
|
||||
if (! isset($attributes[0]['key']) || empty($attributes[0]['key'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Service "%s" must define the "key" attribute on "thelia.asset.filter" tag.',
|
||||
$id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$class = $container->getDefinition($id)->getClass();
|
||||
|
||||
if (! is_subclass_of($class, '\Assetic\Filter\FilterInterface')) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Service "%s" should implement the \Assetic\Filter\FilterInterface interface',
|
||||
$id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$manager->addMethodCall(
|
||||
'registerAssetFilter',
|
||||
[ $attributes[0]['key'], new Reference($id) ]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Class RegisterFormExtensionPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class RegisterFormExtensionPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition("thelia.form_factory_builder")) {
|
||||
return;
|
||||
}
|
||||
|
||||
$formFactoryBuilderDefinition = $container->getDefinition("thelia.form_factory_builder");
|
||||
|
||||
/**
|
||||
* Add form extensions
|
||||
*/
|
||||
foreach ($container->findTaggedServiceIds("thelia.forms.extension") as $id => $definition) {
|
||||
$formFactoryBuilderDefinition
|
||||
->addMethodCall("addExtension", [new Reference($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* And form types
|
||||
*/
|
||||
foreach ($container->findTaggedServiceIds("thelia.form.type") as $id => $definition) {
|
||||
$formFactoryBuilderDefinition
|
||||
->addMethodCall("addType", [new Reference($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* And form type extensions
|
||||
*/
|
||||
foreach ($container->findTaggedServiceIds("thelia.form.type_extension") as $id => $definition) {
|
||||
$formFactoryBuilderDefinition
|
||||
->addMethodCall("addTypeExtension", [new Reference($id)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use ReflectionException;
|
||||
use ReflectionMethod;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Core\Hook\HookDefinition;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Base\IgnoredModuleHookQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Hook;
|
||||
use Thelia\Model\HookQuery;
|
||||
use Thelia\Model\ModuleHook;
|
||||
use Thelia\Model\ModuleHookQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
* Class RegisterListenersPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
*
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class RegisterHookListenersPass implements CompilerPassInterface
|
||||
{
|
||||
protected $debugEnabled;
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('event_dispatcher')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition('event_dispatcher');
|
||||
|
||||
// We have to check if Propel is initialized before registering hooks
|
||||
$managers = Propel::getServiceContainer()->getConnectionManagers();
|
||||
if (! array_key_exists('thelia', $managers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->debugEnabled = $container->getParameter("kernel.debug");
|
||||
|
||||
if (true === version_compare(ConfigQuery::getTheliaSimpleVersion(), '2.1.0', ">=")) {
|
||||
$this->processHook($container, $definition);
|
||||
}
|
||||
}
|
||||
|
||||
protected function logAlertMessage($message, $failSafe = false)
|
||||
{
|
||||
Tlog::getInstance()->addAlert($message);
|
||||
|
||||
if (!$failSafe && $this->debugEnabled) {
|
||||
throw new \InvalidArgumentException($message);
|
||||
}
|
||||
}
|
||||
|
||||
protected function processHook(ContainerBuilder $container, $definition)
|
||||
{
|
||||
foreach ($container->findTaggedServiceIds('hook.event_listener') as $id => $events) {
|
||||
$class = $container->getDefinition($id)->getClass();
|
||||
|
||||
// the class must extends BaseHook
|
||||
$implementClass = HookDefinition::BASE_CLASS;
|
||||
if (! is_subclass_of($class, $implementClass)) {
|
||||
throw new \InvalidArgumentException(sprintf('Hook class "%s" must extends class "%s".', $class, $implementClass));
|
||||
}
|
||||
|
||||
// retrieve the module id
|
||||
$properties = $container->getDefinition($id)->getProperties();
|
||||
$module = null;
|
||||
if (array_key_exists('module', $properties)) {
|
||||
$moduleCode = explode(".", $properties['module'])[1];
|
||||
$module = ModuleQuery::create()->findOneByCode($moduleCode);
|
||||
}
|
||||
|
||||
foreach ($events as $hookAttributes) {
|
||||
$this->registerHook($class, $module, $id, $hookAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
// now we can add listeners for active hooks and active module
|
||||
$this->addHooksMethodCall($container, $definition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new hook if the hook definition is valid.
|
||||
*
|
||||
* @param string $class the namespace of the class
|
||||
* @param \Thelia\Model\Module $module the module
|
||||
* @param string $id the service (hook) id
|
||||
* @param array $attributes the hook attributes
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function registerHook($class, $module, $id, $attributes)
|
||||
{
|
||||
if (!isset($attributes['event'])) {
|
||||
throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "hook.event_listener" tags.', $id));
|
||||
}
|
||||
|
||||
$active = isset($attributes['active']) ? intval($attributes['active']) : 1;
|
||||
$attributes['active'] = (1 === $active);
|
||||
$attributes['templates'] = isset($attributes['templates']) ? strval($attributes['templates']) : '';
|
||||
$attributes['type'] = (isset($attributes['type'])) ? $this->getHookType($attributes['type']) : TemplateDefinition::FRONT_OFFICE;
|
||||
|
||||
if (null === $hook = $this->getHook($attributes['event'], $attributes['type'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = $this->getMethodName($attributes);
|
||||
|
||||
// test if method exists
|
||||
$validMethod = true;
|
||||
if (! $this->isValidHookMethod($class, $attributes['method'], $hook->getBlock())) {
|
||||
$validMethod = false;
|
||||
}
|
||||
|
||||
// test if hook is already registered in ModuleHook
|
||||
$moduleHook = ModuleHookQuery::create()
|
||||
->filterByModuleId($module->getId())
|
||||
->filterByHook($hook)
|
||||
->filterByMethod($attributes['method'])
|
||||
->findOne();
|
||||
|
||||
if (null === $moduleHook) {
|
||||
if (!$validMethod) {
|
||||
$this->logAlertMessage(
|
||||
sprintf(
|
||||
"Module [%s] could not be registered hook [%s], method [%s] is not reachable.",
|
||||
$module->getCode(),
|
||||
$attributes['event'],
|
||||
$attributes['method']
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Assign the module to the hook only if it has not been "deleted"
|
||||
$ignoreCount = IgnoredModuleHookQuery::create()
|
||||
->filterByHook($hook)
|
||||
->filterByModuleId($module->getId())
|
||||
->count();
|
||||
|
||||
if (0 === $ignoreCount) {
|
||||
// hook for module doesn't exist, we add it with default registered values
|
||||
$moduleHook = new ModuleHook();
|
||||
|
||||
$moduleHook->setHook($hook)
|
||||
->setModuleId($module->getId())
|
||||
->setClassname($id)
|
||||
->setMethod($attributes['method'])
|
||||
->setActive($active)
|
||||
->setHookActive(true)
|
||||
->setModuleActive(true)
|
||||
->setPosition(ModuleHook::MAX_POSITION);
|
||||
|
||||
if (isset($attributes['templates'])) {
|
||||
$moduleHook->setTemplates($attributes['templates']);
|
||||
}
|
||||
|
||||
$moduleHook->save();
|
||||
}
|
||||
} else {
|
||||
if (!$validMethod) {
|
||||
$this->logAlertMessage(
|
||||
sprintf(
|
||||
"Module [%s] could not use hook [%s], method [%s] is not reachable anymore.",
|
||||
$module->getCode(),
|
||||
$attributes['event'],
|
||||
$attributes['method']
|
||||
)
|
||||
);
|
||||
|
||||
$moduleHook
|
||||
->setHookActive(false)
|
||||
->save();
|
||||
} else {
|
||||
//$moduleHook->setTemplates($attributes['templates']);
|
||||
|
||||
// Update hook if id was changed in the definition
|
||||
if ($moduleHook->getClassname() != $id) {
|
||||
$moduleHook
|
||||
->setClassname($id);
|
||||
}
|
||||
|
||||
$moduleHook->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* First the new hooks are positioning next to the last module hook.
|
||||
* Next, if the module, hook and module hook is active, a new listener is
|
||||
* added to the service definition.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
* @param Definition $definition The service definition
|
||||
*/
|
||||
protected function addHooksMethodCall(ContainerBuilder $container, Definition $definition)
|
||||
{
|
||||
$moduleHooks = ModuleHookQuery::create()
|
||||
->orderByHookId()
|
||||
->orderByPosition()
|
||||
->orderById()
|
||||
->find();
|
||||
|
||||
$modulePosition = 0;
|
||||
$hookId = 0;
|
||||
/** @var ModuleHook $moduleHook */
|
||||
foreach ($moduleHooks as $moduleHook) {
|
||||
|
||||
// check if class and method exists
|
||||
if (!$container->hasDefinition($moduleHook->getClassname())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hook = $moduleHook->getHook();
|
||||
|
||||
if (!$this->isValidHookMethod(
|
||||
$container->getDefinition($moduleHook->getClassname())->getClass(),
|
||||
$moduleHook->getMethod(),
|
||||
$hook->getBlock(),
|
||||
true
|
||||
)
|
||||
) {
|
||||
$moduleHook->delete();
|
||||
continue;
|
||||
}
|
||||
|
||||
// manage module hook position for new hook
|
||||
if ($hookId !== $moduleHook->getHookId()) {
|
||||
$hookId = $moduleHook->getHookId();
|
||||
$modulePosition = 1;
|
||||
} else {
|
||||
$modulePosition++;
|
||||
}
|
||||
|
||||
if ($moduleHook->getPosition() === ModuleHook::MAX_POSITION) {
|
||||
// new module hook, we set it at the end of the queue for this event
|
||||
$moduleHook->setPosition($modulePosition)->save();
|
||||
} else {
|
||||
$modulePosition = $moduleHook->getPosition();
|
||||
}
|
||||
|
||||
// Add the the new listener for active hooks, we have to reverse the priority and the position
|
||||
if ($moduleHook->getActive() && $moduleHook->getModuleActive() && $moduleHook->getHookActive()) {
|
||||
$eventName = sprintf('hook.%s.%s', $hook->getType(), $hook->getCode());
|
||||
|
||||
// we a register an event which is relative to a specific module
|
||||
if ($hook->getByModule()) {
|
||||
$eventName .= '.' . $moduleHook->getModuleId();
|
||||
}
|
||||
|
||||
$definition->addMethodCall(
|
||||
'addListenerService',
|
||||
array(
|
||||
$eventName,
|
||||
array($moduleHook->getClassname(), $moduleHook->getMethod()),
|
||||
ModuleHook::MAX_POSITION - $moduleHook->getPosition()
|
||||
)
|
||||
);
|
||||
|
||||
if ($moduleHook->getTemplates()) {
|
||||
if ($container->hasDefinition($moduleHook->getClassname())) {
|
||||
$moduleHookEventName = 'hook.' . $hook->getType() . '.' . $hook->getCode();
|
||||
if (true === $moduleHook->getHook()->getByModule()) {
|
||||
$moduleHookEventName .= '.' . $moduleHook->getModuleId();
|
||||
}
|
||||
$container
|
||||
->getDefinition($moduleHook->getClassname())
|
||||
->addMethodCall(
|
||||
'addTemplate',
|
||||
array(
|
||||
$moduleHookEventName,
|
||||
$moduleHook->getTemplates()
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the hook type according to the type attribute of the hook tag
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return int the hook type
|
||||
*/
|
||||
protected function getHookType($name)
|
||||
{
|
||||
$type = TemplateDefinition::FRONT_OFFICE;
|
||||
|
||||
if (null !== $name && is_string($name)) {
|
||||
$name = preg_replace("[^a-z]", "", strtolower(trim($name)));
|
||||
if (in_array($name, array('bo', 'back', 'backoffice'))) {
|
||||
$type = TemplateDefinition::BACK_OFFICE;
|
||||
} elseif (in_array($name, array('email'))) {
|
||||
$type = TemplateDefinition::EMAIL;
|
||||
} elseif (in_array($name, array('pdf'))) {
|
||||
$type = TemplateDefinition::PDF;
|
||||
}
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* G<et a hook for a hook name (code) and a hook type. The hook should exists and be activated.
|
||||
*
|
||||
* @param string $hookName
|
||||
* @param int $hookType
|
||||
*
|
||||
* @return Hook|null
|
||||
*/
|
||||
protected function getHook($hookName, $hookType)
|
||||
{
|
||||
$hook = HookQuery::create()
|
||||
->filterByCode($hookName)
|
||||
->filterByType($hookType)
|
||||
->findOne();
|
||||
|
||||
if (null === $hook) {
|
||||
$this->logAlertMessage(sprintf("Hook %s is unknown.", $hookName));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $hook->getActivate()) {
|
||||
$this->logAlertMessage(sprintf("Hook %s is not activated.", $hookName), true);
|
||||
}
|
||||
|
||||
return $hook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the method that will handled the hook is valid
|
||||
*
|
||||
* @param string $className the namespace of the class
|
||||
* @param string $methodName the method name
|
||||
* @param bool $block tell if the hook is a block or a function
|
||||
* @param bool $failSafe
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidHookMethod($className, $methodName, $block, $failSafe = false)
|
||||
{
|
||||
try {
|
||||
$method = new ReflectionMethod($className, $methodName);
|
||||
|
||||
$parameters = $method->getParameters();
|
||||
|
||||
$eventType = ($block) ?
|
||||
HookDefinition::RENDER_BLOCK_EVENT :
|
||||
HookDefinition::RENDER_FUNCTION_EVENT;
|
||||
|
||||
if (!($parameters[0]->getClass()->getName() == $eventType || is_subclass_of($parameters[0]->getClass()->getName(), $eventType))) {
|
||||
$this->logAlertMessage(sprintf("Method %s should use an event of type %s. found: %s", $methodName, $eventType, $parameters[0]->getClass()->getName()));
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (ReflectionException $ex) {
|
||||
$this->logAlertMessage(
|
||||
sprintf("Method %s does not exist in %s : %s", $methodName, $className, $ex),
|
||||
$failSafe
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMethodName($event)
|
||||
{
|
||||
if (!isset($event['method'])) {
|
||||
if (!empty($event['templates'])) {
|
||||
$event['method'] = BaseHook::INJECT_TEMPLATE_METHOD_NAME;
|
||||
return $event;
|
||||
} else {
|
||||
$callback = function ($matches) {
|
||||
return strtoupper($matches[0]);
|
||||
};
|
||||
$event['method'] = 'on' . preg_replace_callback(
|
||||
array(
|
||||
'/(?<=\b)[a-z]/i',
|
||||
'/[^a-z0-9]/i',
|
||||
),
|
||||
$callback,
|
||||
$event['event']
|
||||
);
|
||||
$event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']);
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -24,11 +26,10 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
*
|
||||
* Class RegisterRouterPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class RegisterRouterPass implements CompilerPassInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
@@ -51,11 +52,11 @@ class RegisterRouterPass implements CompilerPassInterface
|
||||
$router->addMethodCall("setOption", array("generator_cache_class", $container::camelize("ProjectUrlGenerator".$id)));
|
||||
|
||||
$chainRouter->addMethodCall("add", array(new Reference($id), $priority));
|
||||
|
||||
}
|
||||
if (defined("THELIA_INSTALL_MODE") === false) {
|
||||
$modules = \Thelia\Model\ModuleQuery::getActivated();
|
||||
$modules = ModuleQuery::getActivated();
|
||||
|
||||
/** @var Module $module */
|
||||
foreach ($modules as $module) {
|
||||
$moduleBaseDir = $module->getBaseDir();
|
||||
$routingConfigFilePath = $module->getAbsoluteBaseDir() . DS . "Config" . DS . "routing.xml";
|
||||
@@ -78,10 +79,9 @@ class RegisterRouterPass implements CompilerPassInterface
|
||||
|
||||
$container->setDefinition("router.".$moduleBaseDir, $definition);
|
||||
|
||||
$chainRouter->addMethodCall("add", array(new Reference("router.".$moduleBaseDir), 150));
|
||||
$chainRouter->addMethodCall("add", array(new Reference("router.".$moduleBaseDir), 150 + $module->getPosition()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Class RegisterSerializerPass
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class RegisterSerializerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @var string Serializer manager service ID
|
||||
*/
|
||||
const MANAGER_SERVICE_ID = 'thelia.serializer.manager';
|
||||
|
||||
/**
|
||||
* @var string Serializer tag name
|
||||
*/
|
||||
const SERIALIZER_SERVICE_TAG = 'thelia.serializer';
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
try {
|
||||
$manager = $container->getDefinition(self::MANAGER_SERVICE_ID);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (array_keys($container->findTaggedServiceIds(self::SERIALIZER_SERVICE_TAG)) as $serviceId) {
|
||||
$manager->addMethodCall(
|
||||
'add',
|
||||
[
|
||||
new Reference($serviceId)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
/**
|
||||
* Class StackPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class StackPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('stack_factory')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stackFactory = $container->getDefinition('stack_factory');
|
||||
$stackPriority = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds('stack_middleware') as $id => $attributes) {
|
||||
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
|
||||
$stackPriority[$priority][] = $this->retrieveArguments($container, $id);
|
||||
}
|
||||
|
||||
if (false === empty($stackPriority)) {
|
||||
$this->addMiddlewares($stackFactory, $stackPriority);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addMiddlewares(Definition $stackFactory, $stackMiddlewares)
|
||||
{
|
||||
krsort($stackMiddlewares);
|
||||
|
||||
foreach ($stackMiddlewares as $priority => $stacks) {
|
||||
foreach ($stacks as $arguments) {
|
||||
$stackFactory->addMethodCall('push', $arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function retrieveArguments(ContainerBuilder $container, $id)
|
||||
{
|
||||
$definition = $container->getDefinition($id);
|
||||
$arguments = $definition->getArguments();
|
||||
array_unshift($arguments, $definition->getClass());
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@@ -18,11 +19,10 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
/**
|
||||
* Class TranslatorPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class TranslatorPass implements CompilerPassInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
|
||||
@@ -21,10 +21,10 @@ use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\SimpleXMLElement;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLoader;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Export;
|
||||
use Thelia\Model\ExportCategory;
|
||||
@@ -38,6 +38,8 @@ use Thelia\Model\Map\ExportCategoryTableMap;
|
||||
use Thelia\Model\Map\ExportTableMap;
|
||||
use Thelia\Model\Map\ImportCategoryTableMap;
|
||||
use Thelia\Model\Map\ImportTableMap;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
use SimpleXMLElement;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -45,10 +47,11 @@ use Thelia\Model\Map\ImportTableMap;
|
||||
*
|
||||
* Class XmlFileLoader
|
||||
* @package Thelia\Core\DependencyInjection\Loader
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class XmlFileLoader extends FileLoader
|
||||
{
|
||||
const DEFAULT_HOOK_CLASS = "Thelia\\Core\\Hook\\DefaultHook";
|
||||
|
||||
/**
|
||||
* Loads an XML file.
|
||||
@@ -63,6 +66,8 @@ class XmlFileLoader extends FileLoader
|
||||
$xml = $this->parseFile($path);
|
||||
$xml->registerXPathNamespace('config', 'http://thelia.net/schema/dic/config');
|
||||
|
||||
$this->removeScope($xml);
|
||||
|
||||
$this->container->addResource(new FileResource($path));
|
||||
|
||||
$this->parseLoops($xml);
|
||||
@@ -79,41 +84,32 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
$this->parseDefinitions($xml, $path);
|
||||
|
||||
$this->parseHooks($xml, $path, $type);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseExportCategories"],
|
||||
$xml,
|
||||
ExportCategoryTableMap::DATABASE_NAME
|
||||
$xml
|
||||
);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseExports"],
|
||||
$xml,
|
||||
ExportTableMap::DATABASE_NAME
|
||||
$xml
|
||||
);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseImportCategories"],
|
||||
$xml,
|
||||
ImportCategoryTableMap::DATABASE_NAME
|
||||
$xml
|
||||
);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseImports"],
|
||||
$xml,
|
||||
ImportTableMap::DATABASE_NAME
|
||||
$xml
|
||||
);
|
||||
}
|
||||
|
||||
public function propelOnlyRun(callable $method, $arg, $name)
|
||||
public function propelOnlyRun(callable $method, $arg)
|
||||
{
|
||||
$doRun = false;
|
||||
|
||||
try {
|
||||
Propel::getConnection($name);
|
||||
$doRun = true;
|
||||
} catch (\ErrorException $e) {}
|
||||
|
||||
if ($doRun) {
|
||||
if (Thelia::isInstalled()) {
|
||||
call_user_func($method, $arg);
|
||||
}
|
||||
}
|
||||
@@ -130,7 +126,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
foreach ($commands as $command) {
|
||||
array_push($commandConfig, $command->getAttributeAsPhp("class"));
|
||||
array_push($commandConfig, $this->getAttributeAsPhp($command, "class"));
|
||||
}
|
||||
|
||||
$this->container->setParameter("command.definition", $commandConfig);
|
||||
@@ -147,7 +143,7 @@ class XmlFileLoader extends FileLoader
|
||||
return;
|
||||
}
|
||||
|
||||
$this->container->getParameterBag()->add($xml->parameters->getArgumentsAsPhp('parameter'));
|
||||
$this->container->getParameterBag()->add($this->getArgumentsAsPhp($xml->parameters, 'parameter'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +164,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
foreach ($loops as $loop) {
|
||||
$loopConfig[$loop->getAttributeAsPhp("name")] = $loop->getAttributeAsPhp("class");
|
||||
$loopConfig[$this->getAttributeAsPhp($loop, "name")] = $this->getAttributeAsPhp($loop, "class");
|
||||
}
|
||||
|
||||
$this->container->setParameter("Thelia.parser.loops", $loopConfig);
|
||||
@@ -187,7 +183,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
foreach ($forms as $form) {
|
||||
$formConfig[$form->getAttributeAsPhp('name')] = $form->getAttributeAsPhp('class');
|
||||
$formConfig[$this->getAttributeAsPhp($form, 'name')] = $this->getAttributeAsPhp($form, 'class');
|
||||
}
|
||||
|
||||
$this->container->setParameter('Thelia.parser.forms', $formConfig);
|
||||
@@ -210,7 +206,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
$filterConfig[$filter->getAttributeAsPhp("name")] = $filter->getAttributeAsPhp("class");
|
||||
$filterConfig[$this->getAttributeAsPhp($filter, "name")] = $this->getAttributeAsPhp($filter, "class");
|
||||
}
|
||||
|
||||
$this->container->setParameter("Thelia.parser.filters", $filterConfig);
|
||||
@@ -233,7 +229,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
foreach ($baseParams as $baseParam) {
|
||||
$baseParamConfig[$baseParam->getAttributeAsPhp("name")] = $baseParam->getAttributeAsPhp("class");
|
||||
$baseParamConfig[$this->getAttributeAsPhp($baseParam, "name")] = $this->getAttributeAsPhp($baseParam, "class");
|
||||
}
|
||||
|
||||
$this->container->setParameter("Thelia.parser.templateDirectives", $baseParamConfig);
|
||||
@@ -255,20 +251,65 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseDefinition($id, $service, $file)
|
||||
{
|
||||
$definition = $this->parseService($id, $service, $file);
|
||||
if (null !== $definition) {
|
||||
$this->container->setDefinition($id, $definition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses multiple definitions
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
* @param string $file
|
||||
* @param string $type
|
||||
*/
|
||||
protected function parseHooks(SimpleXMLElement $xml, $file, $type)
|
||||
{
|
||||
if (false === $hooks = $xml->xpath('//config:hooks/config:hook')) {
|
||||
return;
|
||||
}
|
||||
foreach ($hooks as $hook) {
|
||||
$this->parseHook((string) $hook['id'], $hook, $file, $type);
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseHook($id, $hook, $file, $type)
|
||||
{
|
||||
if (! isset($hook['class'])) {
|
||||
$hook['class'] = self::DEFAULT_HOOK_CLASS;
|
||||
}
|
||||
|
||||
$definition = $this->parseService($id, $hook, $file);
|
||||
if (null !== $definition) {
|
||||
if (null !== $type) {
|
||||
// inject the BaseModule
|
||||
$definition->setProperty('module', new Reference($type));
|
||||
}
|
||||
$definition->setProperty('parser', new Reference('thelia.parser'));
|
||||
$definition->setProperty('translator', new Reference('thelia.translator'));
|
||||
$definition->setProperty('assetsResolver', new Reference('thelia.parser.asset.resolver'));
|
||||
$definition->setProperty('dispatcher', new Reference('event_dispatcher'));
|
||||
$this->container->setDefinition($id, $definition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an individual Definition
|
||||
*
|
||||
* @param string $id
|
||||
* @param SimpleXMLElement $service
|
||||
* @param string $file
|
||||
* @param string $id
|
||||
* @param SimpleXMLElement $service
|
||||
* @param string $file
|
||||
* @return Definition
|
||||
*/
|
||||
protected function parseDefinition($id, $service, $file)
|
||||
protected function parseService($id, $service, $file)
|
||||
{
|
||||
|
||||
if ((string) $service['alias']) {
|
||||
$public = true;
|
||||
if (isset($service['public'])) {
|
||||
$public = $service->getAttributeAsPhp('public');
|
||||
$public = $this->getAttributeAsPhp($service, 'public');
|
||||
}
|
||||
$this->container->setAlias($id, new Alias((string) $service['alias'], $public));
|
||||
|
||||
@@ -284,7 +325,7 @@ class XmlFileLoader extends FileLoader
|
||||
foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'abstract') as $key) {
|
||||
if (isset($service[$key])) {
|
||||
$method = 'set'.str_replace('-', '', $key);
|
||||
$definition->$method((string) $service->getAttributeAsPhp($key));
|
||||
$definition->$method((string) $this->getAttributeAsPhp($service, $key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,8 +333,8 @@ class XmlFileLoader extends FileLoader
|
||||
$definition->setFile((string) $service->file);
|
||||
}
|
||||
|
||||
$definition->setArguments($service->getArgumentsAsPhp('argument'));
|
||||
$definition->setProperties($service->getArgumentsAsPhp('property'));
|
||||
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
|
||||
$definition->setProperties($this->getArgumentsAsPhp($service, 'property'));
|
||||
|
||||
if (isset($service->configurator)) {
|
||||
if (isset($service->configurator['function'])) {
|
||||
@@ -310,7 +351,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
foreach ($service->call as $call) {
|
||||
$definition->addMethodCall((string) $call['method'], $call->getArgumentsAsPhp('argument'));
|
||||
$definition->addMethodCall((string) $call['method'], $this->getArgumentsAsPhp($call, 'argument'));
|
||||
}
|
||||
|
||||
foreach ($service->tag as $tag) {
|
||||
@@ -320,13 +361,13 @@ class XmlFileLoader extends FileLoader
|
||||
continue;
|
||||
}
|
||||
|
||||
$parameters[$name] = SimpleXMLElement::phpize($value);
|
||||
$parameters[$name] = XmlUtils::phpize($value);
|
||||
}
|
||||
|
||||
$definition->addTag((string) $tag['name'], $parameters);
|
||||
}
|
||||
|
||||
$this->container->setDefinition($id, $definition);
|
||||
return $definition;
|
||||
}
|
||||
|
||||
protected function parseExportCategories(SimpleXMLElement $xml)
|
||||
@@ -341,7 +382,7 @@ class XmlFileLoader extends FileLoader
|
||||
try {
|
||||
/** @var SimpleXMLElement $exportCategory */
|
||||
foreach ($exportCategories as $exportCategory) {
|
||||
$id = (string) $exportCategory->getAttributeAsPhp("id");
|
||||
$id = (string) $this->getAttributeAsPhp($exportCategory, "id");
|
||||
|
||||
$exportCategoryModel = ExportCategoryQuery::create()->findOneByRef($id);
|
||||
|
||||
@@ -355,7 +396,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
/** @var SimpleXMLElement $child */
|
||||
foreach ($exportCategory->children() as $child) {
|
||||
$locale = (string) $child->getAttributeAsPhp("locale");
|
||||
$locale = (string) $this->getAttributeAsPhp($child, "locale");
|
||||
$value = (string) $child;
|
||||
|
||||
$exportCategoryModel
|
||||
@@ -384,12 +425,11 @@ class XmlFileLoader extends FileLoader
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
/** @var SimpleXMLElement $export */
|
||||
foreach ($exports as $export) {
|
||||
$id = (string) $export->getAttributeAsPhp("id");
|
||||
$class = (string) $export->getAttributeAsPhp("class");
|
||||
$categoryRef = (string) $export->getAttributeAsPhp("category_id");
|
||||
$id = (string) $this->getAttributeAsPhp($export, "id");
|
||||
$class = (string) $this->getAttributeAsPhp($export, "class");
|
||||
$categoryRef = (string) $this->getAttributeAsPhp($export, "category_id");
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \ErrorException(
|
||||
@@ -401,7 +441,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
if (null === $category) {
|
||||
throw new \ErrorException(
|
||||
"The export category \"$categoryRef\" doesn't exist"
|
||||
"The export category \"$categoryRef\" doesn't exist"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -422,7 +462,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
/** @var SimpleXMLElement $descriptive */
|
||||
foreach ($export->children() as $descriptive) {
|
||||
$locale = $descriptive->getAttributeAsPhp("locale");
|
||||
$locale = $this->getAttributeAsPhp($descriptive, "locale");
|
||||
$title = null;
|
||||
$description = null;
|
||||
|
||||
@@ -465,10 +505,9 @@ class XmlFileLoader extends FileLoader
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
/** @var SimpleXMLElement $importCategory */
|
||||
foreach ($importCategories as $importCategory) {
|
||||
$id = (string) $importCategory->getAttributeAsPhp("id");
|
||||
$id = (string) $this->getAttributeAsPhp($importCategory, "id");
|
||||
|
||||
$importCategoryModel = ImportCategoryQuery::create()->findOneByRef($id);
|
||||
|
||||
@@ -482,7 +521,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
/** @var SimpleXMLElement $child */
|
||||
foreach ($importCategory->children() as $child) {
|
||||
$locale = (string) $child->getAttributeAsPhp("locale");
|
||||
$locale = (string) $this->getAttributeAsPhp($child, "locale");
|
||||
$value = (string) $child;
|
||||
|
||||
$importCategoryModel
|
||||
@@ -491,7 +530,6 @@ class XmlFileLoader extends FileLoader
|
||||
->save($con);
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
@@ -514,13 +552,13 @@ class XmlFileLoader extends FileLoader
|
||||
try {
|
||||
/** @var SimpleXMLElement $import */
|
||||
foreach ($imports as $import) {
|
||||
$id = (string) $import->getAttributeAsPhp("id");
|
||||
$class = (string) $import->getAttributeAsPhp("class");
|
||||
$categoryRef = (string) $import->getAttributeAsPhp("category_id");
|
||||
$id = (string) $this->getAttributeAsPhp($import, "id");
|
||||
$class = (string) $this->getAttributeAsPhp($import, "class");
|
||||
$categoryRef = (string) $this->getAttributeAsPhp($import, "category_id");
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \ErrorException(
|
||||
"The class \"$class\" doesn't exist"
|
||||
"The class \"$class\" doesn't exist"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -549,7 +587,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
/** @var SimpleXMLElement $descriptive */
|
||||
foreach ($import->children() as $descriptive) {
|
||||
$locale = $descriptive->getAttributeAsPhp("locale");
|
||||
$locale = $this->getAttributeAsPhp($descriptive, "locale");
|
||||
$title = null;
|
||||
$description = null;
|
||||
|
||||
@@ -599,7 +637,7 @@ class XmlFileLoader extends FileLoader
|
||||
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
return simplexml_import_dom($dom, 'Symfony\\Component\\DependencyInjection\\SimpleXMLElement');
|
||||
return simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,7 +651,7 @@ class XmlFileLoader extends FileLoader
|
||||
*/
|
||||
public function validateSchema(\DOMDocument $dom)
|
||||
{
|
||||
$schemaLocations = array('http://thelia.net/schema/dic/config' => str_replace('\\', '/',__DIR__.'/schema/dic/config/thelia-1.0.xsd'));
|
||||
$schemaLocations = array('http://thelia.net/schema/dic/config' => str_replace('\\', '/', __DIR__.'/schema/dic/config/thelia-1.0.xsd'));
|
||||
|
||||
$tmpfiles = array();
|
||||
$imports = '';
|
||||
@@ -667,4 +705,91 @@ EOF
|
||||
{
|
||||
// TODO: Implement supports() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns arguments as valid PHP types.
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
* @param $name
|
||||
* @param bool $lowercase
|
||||
* @return array
|
||||
*/
|
||||
private function getArgumentsAsPhp(SimpleXMLElement $xml, $name, $lowercase = true)
|
||||
{
|
||||
$arguments = array();
|
||||
foreach ($xml->$name as $arg) {
|
||||
if (isset($arg['name'])) {
|
||||
$arg['key'] = (string) $arg['name'];
|
||||
}
|
||||
$key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
|
||||
|
||||
// parameter keys are case insensitive
|
||||
if ('parameter' == $name && $lowercase) {
|
||||
$key = strtolower($key);
|
||||
}
|
||||
|
||||
// this is used by DefinitionDecorator to overwrite a specific
|
||||
// argument of the parent definition
|
||||
if (isset($arg['index'])) {
|
||||
$key = 'index_'.$arg['index'];
|
||||
}
|
||||
|
||||
switch ($arg['type']) {
|
||||
case 'service':
|
||||
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
|
||||
if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) {
|
||||
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
|
||||
} elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) {
|
||||
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
|
||||
}
|
||||
|
||||
if (isset($arg['strict'])) {
|
||||
$strict = XmlUtils::phpize($arg['strict']);
|
||||
} else {
|
||||
$strict = true;
|
||||
}
|
||||
|
||||
$arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict);
|
||||
break;
|
||||
case 'expression':
|
||||
$arguments[$key] = new Expression((string) $arg);
|
||||
break;
|
||||
case 'collection':
|
||||
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);
|
||||
break;
|
||||
case 'string':
|
||||
$arguments[$key] = (string) $arg;
|
||||
break;
|
||||
case 'constant':
|
||||
$arguments[$key] = constant((string) $arg);
|
||||
break;
|
||||
default:
|
||||
$arguments[$key] = XmlUtils::phpize($arg);
|
||||
}
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an attribute as a PHP type.
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
* @param $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttributeAsPhp(SimpleXMLElement $xml, $name)
|
||||
{
|
||||
return XmlUtils::phpize($xml[$name]);
|
||||
}
|
||||
|
||||
private function removeScope(SimpleXMLElement $xml)
|
||||
{
|
||||
$nodes = $xml->xpath('//*[@scope]');
|
||||
|
||||
/** @var \DOMElement $node */
|
||||
foreach ($nodes as $node) {
|
||||
unset($node['scope']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<xsd:element name="commands" type="commands"/>
|
||||
<xsd:element name="forms" type="forms" />
|
||||
<xsd:element name="routing" type="routing" />
|
||||
<xsd:element name="hooks" type="hooks" />
|
||||
<xsd:element name="export_categories" type="export_categories" />
|
||||
<xsd:element name="exports" type="exports" />
|
||||
<xsd:element name="import_categories" type="import_categories" />
|
||||
@@ -134,6 +135,17 @@
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="hooks">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Enclosing element for the definition of all hooks
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element name="hook" type="hook" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="service">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="file" type="xsd:string" minOccurs="0" maxOccurs="1" />
|
||||
@@ -156,6 +168,60 @@
|
||||
<xsd:attribute name="parent" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="hook">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="file" type="xsd:string" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="configurator" type="configurator" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="call" type="call" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="tag" type="hook_tag" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="class" type="xsd:string" />
|
||||
<xsd:attribute name="scope" type="xsd:string" />
|
||||
<xsd:attribute name="public" type="boolean" />
|
||||
<xsd:attribute name="synthetic" type="boolean" />
|
||||
<xsd:attribute name="abstract" type="boolean" />
|
||||
<xsd:attribute name="factory-class" type="xsd:string" />
|
||||
<xsd:attribute name="factory-method" type="xsd:string" />
|
||||
<xsd:attribute name="factory-service" type="xsd:string" />
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="parent" type="xsd:string" />
|
||||
<xsd:attribute name="event" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="hook_type" />
|
||||
<xsd:attribute name="active" type="hook_active" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="hook_tag">
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="event" type="xsd:string" />
|
||||
<xsd:attribute name="method" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="hook_type" />
|
||||
<xsd:attribute name="active" type="hook_active" />
|
||||
<xsd:attribute name="templates" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="hook_type">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="fo" />
|
||||
<xsd:enumeration value="front" />
|
||||
<xsd:enumeration value="frontoffice" />
|
||||
<xsd:enumeration value="bo" />
|
||||
<xsd:enumeration value="back" />
|
||||
<xsd:enumeration value="backoffice" />
|
||||
<xsd:enumeration value="pdf" />
|
||||
<xsd:enumeration value="email" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name="hook_active">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="0" />
|
||||
<xsd:enumeration value="1" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:complexType name="tag">
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:anyAttribute namespace="##any" processContents="lax" />
|
||||
|
||||
53
core/lib/Thelia/Core/DependencyInjection/TheliaContainer.php
Normal file
53
core/lib/Thelia/Core/DependencyInjection/TheliaContainer.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* To override the methods of the symfony container
|
||||
*
|
||||
* Class TheliaContainer
|
||||
* @package Thelia\Core\DependencyInjection
|
||||
* @author Gilles Bourgeat <manu@raynaud.io>
|
||||
* @since 2.3
|
||||
*/
|
||||
class TheliaContainer extends Container
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
|
||||
{
|
||||
if ($id === 'request'
|
||||
&& php_sapi_name() === "cli"
|
||||
) {
|
||||
if (!isset($this->services['request_stack'])) {
|
||||
$this->services['request_stack'] = new RequestStack();
|
||||
}
|
||||
|
||||
/** @var RequestStack $requestStack */
|
||||
$requestStack = $this->services['request_stack'];
|
||||
|
||||
if ($requestStack->getCurrentRequest() === null) {
|
||||
@trigger_error('Request is deprecated as a service since Thelia 2.3. Please inject your Request in the RequestStack service.', E_USER_DEPRECATED);
|
||||
/** @var Request $service */
|
||||
$requestStack->push($service);
|
||||
}
|
||||
}
|
||||
|
||||
parent::set($id, $service, $scope);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,10 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\Form\Form;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class thrown on Thelia.action event
|
||||
@@ -37,4 +40,26 @@ abstract class ActionEvent extends Event
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function bindForm(Form $form)
|
||||
{
|
||||
$fields = $form->getIterator();
|
||||
|
||||
/** @var \Symfony\Component\Form\Form $field */
|
||||
foreach ($fields as $field) {
|
||||
$functionName = sprintf("set%s", Container::camelize($field->getName()));
|
||||
if (method_exists($this, $functionName)) {
|
||||
$getFunctionName = sprintf("get%s", Container::camelize($field->getName()));
|
||||
if (method_exists($this, $getFunctionName)) {
|
||||
if (null === $this->{$getFunctionName}()) {
|
||||
$this->{$functionName}($field->getData());
|
||||
}
|
||||
} else {
|
||||
$this->{$functionName}($field->getData());
|
||||
}
|
||||
} else {
|
||||
$this->{$field->getName()} = $field->getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use Thelia\Model\Customer;
|
||||
/**
|
||||
* Class AddressCreateOrUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
@@ -78,6 +78,11 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
*/
|
||||
protected $country;
|
||||
|
||||
/**
|
||||
* @var int state id
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* @var string cell phone
|
||||
*/
|
||||
@@ -103,8 +108,23 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
*/
|
||||
protected $isDefault;
|
||||
|
||||
public function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company, $isDefault = 0)
|
||||
{
|
||||
public function __construct(
|
||||
$label,
|
||||
$title,
|
||||
$firstname,
|
||||
$lastname,
|
||||
$address1,
|
||||
$address2,
|
||||
$address3,
|
||||
$zipcode,
|
||||
$city,
|
||||
$country,
|
||||
$cellphone,
|
||||
$phone,
|
||||
$company,
|
||||
$isDefault = 0,
|
||||
$state = null
|
||||
) {
|
||||
$this->address1 = $address1;
|
||||
$this->address2 = $address2;
|
||||
$this->address3 = $address3;
|
||||
@@ -112,6 +132,7 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
$this->city = $city;
|
||||
$this->company = $company;
|
||||
$this->country = $country;
|
||||
$this->state = $state;
|
||||
$this->firstname = $firstname;
|
||||
$this->label = $label;
|
||||
$this->lastname = $lastname;
|
||||
@@ -177,6 +198,14 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -265,5 +294,4 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use Thelia\Model\Address;
|
||||
/**
|
||||
* Class AddressEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AddressEvent extends ActionEvent
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ class AdministratorEvent extends ActionEvent
|
||||
protected $firstname = null;
|
||||
protected $lastname = null;
|
||||
protected $login = null;
|
||||
protected $email = null;
|
||||
protected $password = null;
|
||||
protected $profile = null;
|
||||
protected $locale = null;
|
||||
@@ -110,6 +111,10 @@ class AdministratorEvent extends ActionEvent
|
||||
|
||||
public function setProfile($profile)
|
||||
{
|
||||
if (0 === $profile) {
|
||||
$profile = null;
|
||||
}
|
||||
|
||||
$this->profile = $profile;
|
||||
|
||||
return $this;
|
||||
@@ -131,4 +136,24 @@ class AdministratorEvent extends ActionEvent
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Administrator;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
/**
|
||||
* Class AdministratorUpdatePasswordEvent
|
||||
* @package Thelia\Core\Event\Administrator
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Thelia\Model\Admin
|
||||
*/
|
||||
@@ -72,5 +72,4 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
{
|
||||
return $this->admin;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
64
core/lib/Thelia/Core/Event/Api/ApiCreateEvent.php
Normal file
64
core/lib/Thelia/Core/Event/Api/ApiCreateEvent.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\Api;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
/**
|
||||
* Class ApiCreateEvent
|
||||
* @package Thelia\Core\Event\Api
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ApiCreateEvent extends ActionEvent
|
||||
{
|
||||
protected $label;
|
||||
protected $profile;
|
||||
|
||||
public function __construct($label, $profile)
|
||||
{
|
||||
$this->label = $label;
|
||||
$this->profile = $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $label
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $profile
|
||||
*/
|
||||
public function setProfile($profile)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
}
|
||||
45
core/lib/Thelia/Core/Event/Api/ApiDeleteEvent.php
Normal file
45
core/lib/Thelia/Core/Event/Api/ApiDeleteEvent.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\Api;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Api;
|
||||
|
||||
/**
|
||||
* Class ApiDeleteEvent
|
||||
* @package Thelia\Core\Event\Api
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ApiDeleteEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Api
|
||||
*/
|
||||
protected $api;
|
||||
|
||||
/**
|
||||
* @param $api
|
||||
*/
|
||||
public function __construct(Api $api)
|
||||
{
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Api
|
||||
*/
|
||||
public function getApi()
|
||||
{
|
||||
return $this->api;
|
||||
}
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Api/ApiUpdateEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Api/ApiUpdateEvent.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Api;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
/**
|
||||
* Class ApiUpdateEvent
|
||||
* @package Thelia\Core\Event\Api
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ApiUpdateEvent extends ActionEvent
|
||||
{
|
||||
protected $api;
|
||||
|
||||
protected $profile;
|
||||
|
||||
public function __construct($api, $profile)
|
||||
{
|
||||
$this->api = $api;
|
||||
$this->profile = $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Api $api
|
||||
*/
|
||||
public function setApi($api)
|
||||
{
|
||||
$this->api = $api;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Api
|
||||
*/
|
||||
public function getApi()
|
||||
{
|
||||
return $this->api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $profile
|
||||
*/
|
||||
public function setProfile($profile)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
}
|
||||
@@ -15,27 +15,29 @@ namespace Thelia\Core\Event\Area;
|
||||
/**
|
||||
* Class AreaAddCountryEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaAddCountryEvent extends AreaEvent
|
||||
{
|
||||
protected $area_id;
|
||||
protected $country_id;
|
||||
protected $areaId;
|
||||
protected $countryId;
|
||||
|
||||
public function __construct($area_id, $country_id)
|
||||
public function __construct($areaId, $countryId)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
$this->country_id = $country_id;
|
||||
parent::__construct();
|
||||
|
||||
$this->areaId = $areaId;
|
||||
$this->countryId = $countryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area_id
|
||||
* @param mixed $areaId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
public function setAreaId($areaId)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
$this->areaId = $areaId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -45,17 +47,17 @@ class AreaAddCountryEvent extends AreaEvent
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
return $this->areaId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $country_id
|
||||
* @param mixed $countryId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
public function setCountryId($countryId)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
$this->countryId = $countryId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -65,7 +67,6 @@ class AreaAddCountryEvent extends AreaEvent
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
return $this->countryId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Area;
|
||||
/**
|
||||
* Class AreaCreateEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaCreateEvent extends AreaEvent
|
||||
{
|
||||
@@ -38,5 +38,4 @@ class AreaCreateEvent extends AreaEvent
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Area;
|
||||
/**
|
||||
* Class AreaDeleteEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaDeleteEvent extends AreaEvent
|
||||
{
|
||||
@@ -48,5 +48,4 @@ class AreaDeleteEvent extends AreaEvent
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
/**
|
||||
* Class AreaEvent
|
||||
* @package Thelia\Core\Event\Shipping
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaEvent extends ActionEvent
|
||||
{
|
||||
|
||||
@@ -15,9 +15,34 @@ namespace Thelia\Core\Event\Area;
|
||||
/**
|
||||
* Class AreaRemoveCountryEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaRemoveCountryEvent extends AreaAddCountryEvent
|
||||
{
|
||||
/** @var int|null */
|
||||
protected $stateId;
|
||||
|
||||
public function __construct($areaId, $countryId, $stateId = null)
|
||||
{
|
||||
parent::__construct($areaId, $countryId);
|
||||
|
||||
$this->stateId = $stateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStateId()
|
||||
{
|
||||
return $this->stateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $stateId
|
||||
*/
|
||||
public function setStateId($stateId)
|
||||
{
|
||||
$this->stateId = $stateId;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,27 @@ namespace Thelia\Core\Event\Area;
|
||||
/**
|
||||
* Class AreaUpdateEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaUpdateEvent extends AreaCreateEvent
|
||||
{
|
||||
protected $area_id;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $area_id
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Area;
|
||||
/**
|
||||
* Class AreaUpdatePostageEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaUpdatePostageEvent extends AreaEvent
|
||||
{
|
||||
@@ -66,5 +66,4 @@ class AreaUpdatePostageEvent extends AreaEvent
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,5 +53,4 @@ class AttributeAvCreateEvent extends AttributeAvEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,12 @@ namespace Thelia\Core\Event\Attribute;
|
||||
|
||||
class AttributeAvDeleteEvent extends AttributeAvEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $attributeAv_id;
|
||||
|
||||
/**
|
||||
* @param int $attributeAv_id
|
||||
*/
|
||||
public function __construct($attributeAv_id)
|
||||
{
|
||||
$this->setAttributeAvId($attributeAv_id);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Attribute;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\AttributeAv;
|
||||
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace Thelia\Core\Event\Attribute;
|
||||
|
||||
class AttributeAvUpdateEvent extends AttributeAvCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $attributeAv_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $attributeAv_id
|
||||
*/
|
||||
public function __construct($attributeAv_id)
|
||||
{
|
||||
$this->setAttributeAvId($attributeAv_id);
|
||||
|
||||
@@ -53,5 +53,4 @@ class AttributeCreateEvent extends AttributeEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,12 @@ namespace Thelia\Core\Event\Attribute;
|
||||
|
||||
class AttributeDeleteEvent extends AttributeEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $attribute_id;
|
||||
|
||||
/**
|
||||
* @param int $attribute_id
|
||||
*/
|
||||
public function __construct($attribute_id)
|
||||
{
|
||||
$this->setAttributeId($attribute_id);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Attribute;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Attribute;
|
||||
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace Thelia\Core\Event\Attribute;
|
||||
|
||||
class AttributeUpdateEvent extends AttributeCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $attribute_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $attribute_id
|
||||
*/
|
||||
public function __construct($attribute_id)
|
||||
{
|
||||
$this->setAttributeId($attribute_id);
|
||||
|
||||
@@ -19,8 +19,12 @@ namespace Thelia\Core\Event\Brand;
|
||||
*/
|
||||
class BrandDeleteEvent extends BrandEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $brand_id;
|
||||
|
||||
/**
|
||||
* @param int $brand_id
|
||||
*/
|
||||
public function __construct($brand_id)
|
||||
{
|
||||
$this->brand_id = $brand_id;
|
||||
|
||||
@@ -17,7 +17,7 @@ use Thelia\Core\Event\ActionEvent;
|
||||
/**
|
||||
* Class CacheEvent
|
||||
* @package Thelia\Core\Event\Cache
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CacheEvent extends ActionEvent
|
||||
{
|
||||
@@ -50,5 +50,4 @@ class CacheEvent extends ActionEvent
|
||||
{
|
||||
return $this->dir;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
41
core/lib/Thelia/Core/Event/Cart/CartCreateEvent.php
Normal file
41
core/lib/Thelia/Core/Event/Cart/CartCreateEvent.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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\Cart;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Cart;
|
||||
|
||||
class CartCreateEvent extends ActionEvent
|
||||
{
|
||||
protected $cart;
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Cart
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCart(Cart $cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Core/Event/Cart/CartDuplicationEvent.php
Normal file
43
core/lib/Thelia/Core/Event/Cart/CartDuplicationEvent.php
Normal 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\Core\Event\Cart;
|
||||
|
||||
use Thelia\Model\Cart;
|
||||
|
||||
class CartDuplicationEvent extends CartEvent
|
||||
{
|
||||
protected $originalCart;
|
||||
|
||||
public function __construct(Cart $duplicatedCart, Cart $originalCart)
|
||||
{
|
||||
parent::__construct($duplicatedCart);
|
||||
|
||||
$this->originalCart = $originalCart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cart
|
||||
*/
|
||||
public function getDuplicatedCart()
|
||||
{
|
||||
return $this->getCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cart
|
||||
*/
|
||||
public function getOriginalCart()
|
||||
{
|
||||
return $this->originalCart;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ class CartEvent extends ActionEvent
|
||||
protected $product;
|
||||
protected $cartItem;
|
||||
|
||||
protected $cartItemId;
|
||||
|
||||
public function __construct(Cart $cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
@@ -51,16 +53,28 @@ class CartEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartItem $cartItem
|
||||
* @param CartItem $cartItem
|
||||
* @return CartEvent
|
||||
*/
|
||||
public function setCartItem($cartItem)
|
||||
public function setCartItem(CartItem $cartItem)
|
||||
{
|
||||
$this->cartItem = $cartItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the current cart item
|
||||
*
|
||||
* @return CartEvent
|
||||
*/
|
||||
public function clearCartItem()
|
||||
{
|
||||
$this->cartItem = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CartItem
|
||||
*/
|
||||
@@ -69,6 +83,25 @@ class CartEvent extends ActionEvent
|
||||
return $this->cartItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCartItemId()
|
||||
{
|
||||
return $this->cartItemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $cartItemId
|
||||
* @return $this
|
||||
*/
|
||||
public function setCartItemId($cartItemId)
|
||||
{
|
||||
$this->cartItemId = $cartItemId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $newness
|
||||
* @return CartEvent
|
||||
|
||||
@@ -18,7 +18,7 @@ use Thelia\Model\CartItem;
|
||||
/**
|
||||
* Class CartItemDuplicationItem
|
||||
* @package Thelia\Core\Event\Cart
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CartItemDuplicationItem extends ActionEvent
|
||||
{
|
||||
@@ -53,5 +53,4 @@ class CartItemDuplicationItem extends ActionEvent
|
||||
{
|
||||
return $this->oldItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
60
core/lib/Thelia/Core/Event/Cart/CartPersistEvent.php
Normal file
60
core/lib/Thelia/Core/Event/Cart/CartPersistEvent.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Cart;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Cart;
|
||||
|
||||
/**
|
||||
* Class CartPersistEvent
|
||||
* @package Thelia\Core\Event\Cart
|
||||
* @author Julien Chanséaume <julien@thelia.net>
|
||||
*/
|
||||
class CartPersistEvent extends ActionEvent
|
||||
{
|
||||
/** @var Cart $cart */
|
||||
protected $cart;
|
||||
|
||||
public function __construct(Cart $cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cart
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart
|
||||
*/
|
||||
public function setCart($cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if cart exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCart()
|
||||
{
|
||||
return null !== $this->cart;
|
||||
}
|
||||
}
|
||||
41
core/lib/Thelia/Core/Event/Cart/CartRestoreEvent.php
Normal file
41
core/lib/Thelia/Core/Event/Cart/CartRestoreEvent.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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\Cart;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Cart;
|
||||
|
||||
class CartRestoreEvent extends ActionEvent
|
||||
{
|
||||
protected $cart;
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Cart
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCart(Cart $cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -14,19 +14,25 @@ namespace Thelia\Core\Event\Category;
|
||||
|
||||
class CategoryDeleteEvent extends CategoryEvent
|
||||
{
|
||||
public function __construct($category_id)
|
||||
/** @var int */
|
||||
protected $categoryId;
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
*/
|
||||
public function __construct($categoryId)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
$this->categoryId = $categoryId;
|
||||
}
|
||||
|
||||
public function getCategoryId()
|
||||
{
|
||||
return $this->category_id;
|
||||
return $this->categoryId;
|
||||
}
|
||||
|
||||
public function setCategoryId($category_id)
|
||||
public function setCategoryId($categoryId)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
$this->categoryId = $categoryId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Thelia\Core\Event\Category;
|
||||
|
||||
class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $category_id;
|
||||
|
||||
protected $chapo;
|
||||
@@ -22,6 +23,11 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
|
||||
protected $parent;
|
||||
|
||||
protected $defaultTemplateId;
|
||||
|
||||
/**
|
||||
* @param int $category_id
|
||||
*/
|
||||
public function __construct($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
@@ -86,4 +92,22 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultTemplateId()
|
||||
{
|
||||
return $this->defaultTemplateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $defaultTemplateId
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultTemplateId($defaultTemplateId)
|
||||
{
|
||||
$this->defaultTemplateId = $defaultTemplateId;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,12 @@ namespace Thelia\Core\Event\Config;
|
||||
|
||||
class ConfigDeleteEvent extends ConfigEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $config_id;
|
||||
|
||||
/**
|
||||
* @param int $config_id
|
||||
*/
|
||||
public function __construct($config_id)
|
||||
{
|
||||
$this->setConfigId($config_id);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Config;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Config;
|
||||
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace Thelia\Core\Event\Config;
|
||||
|
||||
class ConfigUpdateEvent extends ConfigCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $config_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $config_id
|
||||
*/
|
||||
public function __construct($config_id)
|
||||
{
|
||||
$this->setConfigId($config_id);
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Content;
|
||||
|
||||
use Thelia\Model\Content;
|
||||
|
||||
/**
|
||||
* Class ContentAddFolderEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentAddFolderEvent extends ContentEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int folder id
|
||||
*/
|
||||
@@ -48,5 +48,4 @@ class ContentAddFolderEvent extends ContentEvent
|
||||
{
|
||||
return $this->folderId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Content;
|
||||
/**
|
||||
* Class ContentCreateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentCreateEvent extends ContentEvent
|
||||
{
|
||||
@@ -103,5 +103,4 @@ class ContentCreateEvent extends ContentEvent
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,14 +15,19 @@ namespace Thelia\Core\Event\Content;
|
||||
/**
|
||||
* Class ContentDeleteEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentDeleteEvent extends ContentEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $content_id;
|
||||
|
||||
/** @var int */
|
||||
protected $folder_id;
|
||||
|
||||
/**
|
||||
* @param int $content_id
|
||||
*/
|
||||
public function __construct($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
@@ -57,5 +62,4 @@ class ContentDeleteEvent extends ContentEvent
|
||||
{
|
||||
return $this->folder_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Content;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Content;
|
||||
|
||||
/**
|
||||
* Class ContentEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentEvent extends ActionEvent
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Content;
|
||||
/**
|
||||
* Class ContentRemoveFolderEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentRemoveFolderEvent extends ContentAddFolderEvent
|
||||
{
|
||||
|
||||
@@ -15,9 +15,8 @@ namespace Thelia\Core\Event\Content;
|
||||
/**
|
||||
* Class ContentToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentToggleVisibilityEvent extends ContentEvent
|
||||
class ContentToggleVisibilityEvent extends ContentEvent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -15,16 +15,20 @@ namespace Thelia\Core\Event\Content;
|
||||
/**
|
||||
* Class ContentUpdateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentUpdateEvent extends ContentCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $content_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $content_id
|
||||
*/
|
||||
public function __construct($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
@@ -109,5 +113,4 @@ class ContentUpdateEvent extends ContentCreateEvent
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Country;
|
||||
/**
|
||||
* Class CountryCreateEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryCreateEvent extends CountryEvent
|
||||
{
|
||||
@@ -25,9 +25,11 @@ class CountryCreateEvent extends CountryEvent
|
||||
protected $isoAlpha2;
|
||||
protected $isoAlpha3;
|
||||
|
||||
/**
|
||||
* @var int area zone
|
||||
*/
|
||||
/** @var bool is visible */
|
||||
protected $visible;
|
||||
/** @var bool has states */
|
||||
protected $hasStates;
|
||||
|
||||
protected $area;
|
||||
|
||||
/**
|
||||
@@ -138,4 +140,37 @@ class CountryCreateEvent extends CountryEvent
|
||||
return $this->area;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $visible
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHasStates()
|
||||
{
|
||||
return $this->hasStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $hasStates
|
||||
*/
|
||||
public function setHasStates($hasStates)
|
||||
{
|
||||
$this->hasStates = $hasStates;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Country;
|
||||
/**
|
||||
* Class CountryDeleteEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryDeleteEvent extends CountryEvent
|
||||
{
|
||||
@@ -24,6 +24,9 @@ class CountryDeleteEvent extends CountryEvent
|
||||
*/
|
||||
protected $country_id;
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
*/
|
||||
public function __construct($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
@@ -44,5 +47,4 @@ class CountryDeleteEvent extends CountryEvent
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Country;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Country;
|
||||
|
||||
/**
|
||||
* Class CountryEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryEvent extends ActionEvent
|
||||
{
|
||||
@@ -56,5 +57,4 @@ class CountryEvent extends ActionEvent
|
||||
{
|
||||
return null !== $this->country;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,16 @@ namespace Thelia\Core\Event\Country;
|
||||
/**
|
||||
* Class CountryToggleDefaultEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryToggleDefaultEvent extends CountryEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $country_id;
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
*/
|
||||
public function __construct($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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\Country;
|
||||
|
||||
/**
|
||||
* Class CountryToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Julien Chanséaume <julien@thelia.net>
|
||||
*/
|
||||
class CountryToggleVisibilityEvent extends CountryEvent
|
||||
{
|
||||
}
|
||||
@@ -15,23 +15,39 @@ namespace Thelia\Core\Event\Country;
|
||||
/**
|
||||
* Class CountryUpdateEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryUpdateEvent extends CountryCreateEvent
|
||||
{
|
||||
/** @var $country_id */
|
||||
protected $country_id;
|
||||
|
||||
/** @var bool */
|
||||
protected $needZipCode;
|
||||
|
||||
/** @var string */
|
||||
protected $zipCodeFormat;
|
||||
|
||||
/** @var string */
|
||||
protected $chapo;
|
||||
|
||||
/** @var string */
|
||||
protected $description;
|
||||
|
||||
/** @var string */
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
*/
|
||||
public function __construct($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
* @param string $chapo
|
||||
* @return $this
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
@@ -41,7 +57,7 @@ class CountryUpdateEvent extends CountryCreateEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
@@ -49,7 +65,8 @@ class CountryUpdateEvent extends CountryCreateEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
@@ -67,7 +84,8 @@ class CountryUpdateEvent extends CountryCreateEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
* @param string $postscriptum
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
@@ -85,7 +103,8 @@ class CountryUpdateEvent extends CountryCreateEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $country_id
|
||||
* @param int $country_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
{
|
||||
@@ -95,11 +114,46 @@ class CountryUpdateEvent extends CountryCreateEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return int
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function isNeedZipCode()
|
||||
{
|
||||
return $this->needZipCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $needZipCode
|
||||
* @return $this
|
||||
*/
|
||||
public function setNeedZipCode($needZipCode)
|
||||
{
|
||||
$this->needZipCode = $needZipCode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getZipCodeFormat()
|
||||
{
|
||||
return $this->zipCodeFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zipCodeFormat
|
||||
* @return $this
|
||||
*/
|
||||
public function setZipCodeFormat($zipCodeFormat)
|
||||
{
|
||||
$this->zipCodeFormat = $zipCodeFormat;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Coupon;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
/**
|
||||
@@ -42,7 +43,7 @@ class CouponConsumeEvent extends ActionEvent
|
||||
* @param bool $isValid If Coupon is valid or f Customer meets coupon conditions
|
||||
* @param bool $freeShipping true if coupon offers free shipping
|
||||
*/
|
||||
public function __construct($code, $discount = null, $isValid = null, $freeShipping = false)
|
||||
public function __construct($code, $discount = null, $isValid = null, $freeShipping = false)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->discount = $discount;
|
||||
@@ -141,5 +142,4 @@ class CouponConsumeEvent extends ActionEvent
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Coupon;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Condition\ConditionCollection;
|
||||
use Thelia\Model\Coupon;
|
||||
@@ -42,6 +43,9 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
/** @var bool if Coupon is enabled */
|
||||
protected $isEnabled = false;
|
||||
|
||||
/** @var \DateTime Coupon start date */
|
||||
protected $startDate = null;
|
||||
|
||||
/** @var \DateTime Coupon expiration date */
|
||||
protected $expirationDate = null;
|
||||
|
||||
@@ -102,13 +106,27 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param array $freeShippingForCountries ID of Countries to which shipping is free
|
||||
* @param array $freeShippingForMethods ID of Shipping modules for which shipping is free
|
||||
* @param boolean $perCustomerUsageCount Usage count is per customer
|
||||
* @param \DateTime $startDate Coupon start date
|
||||
*/
|
||||
public function __construct(
|
||||
$code, $serviceId, $title, array $effects, $shortDescription, $description,
|
||||
$isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative,
|
||||
$isRemovingPostage, $maxUsage, $locale, $freeShippingForCountries, $freeShippingForMethods,
|
||||
$perCustomerUsageCount)
|
||||
{
|
||||
$code,
|
||||
$serviceId,
|
||||
$title,
|
||||
array $effects,
|
||||
$shortDescription,
|
||||
$description,
|
||||
$isEnabled,
|
||||
\DateTime $expirationDate,
|
||||
$isAvailableOnSpecialOffers,
|
||||
$isCumulative,
|
||||
$isRemovingPostage,
|
||||
$maxUsage,
|
||||
$locale,
|
||||
$freeShippingForCountries,
|
||||
$freeShippingForMethods,
|
||||
$perCustomerUsageCount,
|
||||
\DateTime $startDate = null
|
||||
) {
|
||||
$this->code = $code;
|
||||
$this->description = $description;
|
||||
$this->expirationDate = $expirationDate;
|
||||
@@ -125,6 +143,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
$this->startDate = $startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,6 +274,19 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->effects['amount'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon start date
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getStartDate()
|
||||
{
|
||||
if ($this->startDate === null) {
|
||||
return null;
|
||||
}
|
||||
return clone $this->startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon expiration date
|
||||
*
|
||||
@@ -427,5 +459,4 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
70
core/lib/Thelia/Core/Event/Coupon/CouponDeleteEvent.php
Normal file
70
core/lib/Thelia/Core/Event/Coupon/CouponDeleteEvent.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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\Coupon;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Coupon;
|
||||
|
||||
/**
|
||||
* Class CouponDeleteEvent
|
||||
* @package Thelia\Core\Event\Coupon
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class CouponDeleteEvent extends ActionEvent
|
||||
{
|
||||
/** @var Coupon */
|
||||
protected $coupon;
|
||||
|
||||
protected $couponId;
|
||||
|
||||
public function __construct($couponId, Coupon $coupon = null)
|
||||
{
|
||||
$this->coupon = $coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Coupon
|
||||
*/
|
||||
public function getCoupon()
|
||||
{
|
||||
return $this->coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Coupon $coupon
|
||||
* @return $this
|
||||
*/
|
||||
public function setCoupon(Coupon $coupon = null)
|
||||
{
|
||||
$this->coupon = $coupon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCouponId()
|
||||
{
|
||||
return $this->couponId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $couponId
|
||||
* @return $this
|
||||
*/
|
||||
public function setCouponId($couponId)
|
||||
{
|
||||
$this->couponId = $couponId;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ class CurrencyChangeEvent extends CurrencyEvent
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
@@ -48,5 +49,4 @@ class CurrencyChangeEvent extends CurrencyEvent
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class CurrencyCreateEvent extends CurrencyEvent
|
||||
protected $currency_name;
|
||||
protected $locale;
|
||||
protected $symbol;
|
||||
protected $format;
|
||||
protected $code;
|
||||
protected $rate;
|
||||
|
||||
@@ -57,6 +58,18 @@ class CurrencyCreateEvent extends CurrencyEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
public function setFormat($format)
|
||||
{
|
||||
$this->format = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
|
||||
@@ -14,22 +14,11 @@ namespace Thelia\Core\Event\Currency;
|
||||
|
||||
class CurrencyDeleteEvent extends CurrencyEvent
|
||||
{
|
||||
protected $currency_id;
|
||||
|
||||
public function __construct($currency_id)
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*/
|
||||
public function __construct($currencyId)
|
||||
{
|
||||
$this->setCurrencyId($currency_id);
|
||||
}
|
||||
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
|
||||
return $this;
|
||||
$this->setCurrencyId($currencyId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Currency;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
@@ -18,25 +19,56 @@ class CurrencyEvent extends ActionEvent
|
||||
{
|
||||
protected $currency = null;
|
||||
|
||||
protected $currencyId;
|
||||
|
||||
public function __construct(Currency $currency = null)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCurrency()
|
||||
{
|
||||
return ! is_null($this->currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Currency
|
||||
*/
|
||||
public function getCurrency()
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function setCurrency($currency)
|
||||
/**
|
||||
* @param Currency $currency
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurrency(Currency $currency)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currencyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $currencyId
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurrencyId($currencyId)
|
||||
{
|
||||
$this->currencyId = $currencyId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,35 +14,56 @@ namespace Thelia\Core\Event\Currency;
|
||||
|
||||
class CurrencyUpdateEvent extends CurrencyCreateEvent
|
||||
{
|
||||
protected $currency_id;
|
||||
/** @var int */
|
||||
protected $is_default;
|
||||
|
||||
public function __construct($currency_id)
|
||||
|
||||
/** @var int */
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*/
|
||||
public function __construct($currencyId)
|
||||
{
|
||||
$this->setCurrencyId($currency_id);
|
||||
}
|
||||
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
|
||||
return $this;
|
||||
$this->setCurrencyId($currencyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIsDefault()
|
||||
{
|
||||
return $this->is_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $is_default
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsDefault($is_default)
|
||||
{
|
||||
$this->is_default = $is_default;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $visible
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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\Currency;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CurrencyUpdateRateEvent extends ActionEvent
|
||||
{
|
||||
protected $undefinedRates = [];
|
||||
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*/
|
||||
public function addUndefinedRate($currencyId)
|
||||
{
|
||||
$this->undefinedRates[] = $currencyId;
|
||||
}
|
||||
|
||||
public function hasUndefinedRates()
|
||||
{
|
||||
return ! empty($this->undefinedRates);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array of currency objects
|
||||
*/
|
||||
public function getUndefinedRates()
|
||||
{
|
||||
return $this->undefinedRates;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Core\Event\Customer;
|
||||
/**
|
||||
* Class CustomerCreateOrUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
{
|
||||
@@ -31,14 +31,17 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
protected $zipcode;
|
||||
protected $city;
|
||||
protected $country;
|
||||
protected $state;
|
||||
protected $email;
|
||||
protected $password;
|
||||
protected $lang;
|
||||
protected $langId;
|
||||
protected $reseller;
|
||||
protected $sponsor;
|
||||
protected $discount;
|
||||
protected $company;
|
||||
protected $ref;
|
||||
protected $emailUpdateAllowed;
|
||||
protected $notifyCustomerOfAccountCreation;
|
||||
|
||||
/**
|
||||
* @param int $title the title customer id
|
||||
@@ -54,22 +57,43 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
* @param int $country the country id
|
||||
* @param string $email
|
||||
* @param string $password plain password, don't put hash password, it will hashes again
|
||||
* @param $lang
|
||||
* @param $langId
|
||||
* @param int $reseller if customer is a reseller
|
||||
* @param int $sponsor customer's id sponsor
|
||||
* @param float $discount
|
||||
* @param string $company
|
||||
* @param string $ref
|
||||
*/
|
||||
public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount, $company, $ref)
|
||||
{
|
||||
public function __construct(
|
||||
$title,
|
||||
$firstname,
|
||||
$lastname,
|
||||
$address1,
|
||||
$address2,
|
||||
$address3,
|
||||
$phone,
|
||||
$cellphone,
|
||||
$zipcode,
|
||||
$city,
|
||||
$country,
|
||||
$email,
|
||||
$password,
|
||||
$langId,
|
||||
$reseller,
|
||||
$sponsor,
|
||||
$discount,
|
||||
$company,
|
||||
$ref,
|
||||
$state = null
|
||||
) {
|
||||
$this->address1 = $address1;
|
||||
$this->address2 = $address2;
|
||||
$this->address3 = $address3;
|
||||
$this->country = $country;
|
||||
$this->state = $state;
|
||||
$this->email = $email;
|
||||
$this->firstname = $firstname;
|
||||
$this->lang = $lang;
|
||||
$this->langId = $langId;
|
||||
$this->lastname = $lastname;
|
||||
$this->password = $password;
|
||||
$this->phone = $phone;
|
||||
@@ -83,6 +107,7 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
$this->company = $company;
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -123,6 +148,14 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -142,9 +175,9 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLang()
|
||||
public function getLangId()
|
||||
{
|
||||
return $this->lang;
|
||||
return $this->langId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,6 +196,17 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -235,4 +279,41 @@ class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $emailUpdateAllowed
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmailUpdateAllowed($emailUpdateAllowed)
|
||||
{
|
||||
$this->emailUpdateAllowed = $emailUpdateAllowed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEmailUpdateAllowed()
|
||||
{
|
||||
return $this->emailUpdateAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $notifyCustomerOfAccountCreation
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotifyCustomerOfAccountCreation($notifyCustomerOfAccountCreation)
|
||||
{
|
||||
$this->notifyCustomerOfAccountCreation = $notifyCustomerOfAccountCreation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getNotifyCustomerOfAccountCreation()
|
||||
{
|
||||
return $this->notifyCustomerOfAccountCreation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CustomerEvent extends ActionEvent
|
||||
{
|
||||
/** @var null|Customer */
|
||||
public $customer = null;
|
||||
|
||||
public function __construct(Customer $customer = null)
|
||||
@@ -26,6 +27,7 @@ class CustomerEvent extends ActionEvent
|
||||
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomer(Customer $customer)
|
||||
{
|
||||
@@ -35,7 +37,7 @@ class CustomerEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Customer
|
||||
* @return null|Customer
|
||||
*/
|
||||
public function getCustomer()
|
||||
{
|
||||
@@ -49,5 +51,4 @@ class CustomerEvent extends ActionEvent
|
||||
{
|
||||
return $this->customer != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
144
core/lib/Thelia/Core/Event/CustomerTitle/CustomerTitleEvent.php
Normal file
144
core/lib/Thelia/Core/Event/CustomerTitle/CustomerTitleEvent.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?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\CustomerTitle;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\CustomerTitle;
|
||||
|
||||
/**
|
||||
* Class CustomerTitleEvent
|
||||
* @package Thelia\Core\Event\CustomerTitle
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class CustomerTitleEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $default = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $short;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $long;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* @var null|\Thelia\Model\CustomerTitle
|
||||
*/
|
||||
protected $customerTitle;
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\CustomerTitle
|
||||
*/
|
||||
public function getCustomerTitle()
|
||||
{
|
||||
return $this->customerTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|\Thelia\Model\CustomerTitle $customerTitle
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomerTitle(CustomerTitle $customerTitle = null)
|
||||
{
|
||||
$this->customerTitle = $customerTitle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $default
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefault($default)
|
||||
{
|
||||
$this->default = $default;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLong()
|
||||
{
|
||||
return $this->long;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $long
|
||||
* @return $this
|
||||
*/
|
||||
public function setLong($long)
|
||||
{
|
||||
$this->long = $long;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShort()
|
||||
{
|
||||
return $this->short;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $short
|
||||
* @return $this
|
||||
*/
|
||||
public function setShort($short)
|
||||
{
|
||||
$this->short = $short;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
234
core/lib/Thelia/Core/Event/Delivery/DeliveryPostageEvent.php
Normal file
234
core/lib/Thelia/Core/Event/Delivery/DeliveryPostageEvent.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?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\Delivery;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\Cart;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Model\State;
|
||||
use Thelia\Module\DeliveryModuleInterface;
|
||||
|
||||
/**
|
||||
* Class DeliveryPostageEvent
|
||||
* @package Thelia\Core\Event\Delivery
|
||||
* @author Julien Chanséaume <julien@thelia.net>
|
||||
*/
|
||||
class DeliveryPostageEvent extends ActionEvent
|
||||
{
|
||||
/** @var DeliveryModuleInterface */
|
||||
protected $module = null;
|
||||
|
||||
/** @var Cart */
|
||||
protected $cart = null;
|
||||
|
||||
/** @var Address */
|
||||
protected $address = null;
|
||||
|
||||
/** @var Country */
|
||||
protected $country = null;
|
||||
|
||||
/** @var State */
|
||||
protected $state = null;
|
||||
|
||||
/** @var bool */
|
||||
protected $validModule = false;
|
||||
|
||||
/** @var OrderPostage|null */
|
||||
protected $postage = null;
|
||||
|
||||
/** @var \DateTime|null */
|
||||
protected $deliveryDate = null;
|
||||
|
||||
/** @var array */
|
||||
protected $additionalData = [];
|
||||
|
||||
/**
|
||||
* DeliveryPostageEvent constructor.
|
||||
* @param DeliveryModuleInterface $module
|
||||
* @param Country $country
|
||||
* @param Cart $cart
|
||||
* @param State $state
|
||||
*/
|
||||
public function __construct(
|
||||
DeliveryModuleInterface $module,
|
||||
Cart $cart,
|
||||
Address $address = null,
|
||||
Country $country = null,
|
||||
State $state = null
|
||||
) {
|
||||
$this->module = $module;
|
||||
$this->cart = $cart;
|
||||
$this->address = $address;
|
||||
$this->country = $country;
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cart
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart
|
||||
*/
|
||||
public function setCart($cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Address
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
*/
|
||||
public function setAddress($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDeliveryDate()
|
||||
{
|
||||
return $this->deliveryDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $deliveryDate
|
||||
*/
|
||||
public function setDeliveryDate($deliveryDate)
|
||||
{
|
||||
$this->deliveryDate = $deliveryDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeliveryModuleInterface
|
||||
*/
|
||||
public function getModule()
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeliveryModuleInterface $module
|
||||
*/
|
||||
public function setModule($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|OrderPostage
|
||||
*/
|
||||
public function getPostage()
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|double|OrderPostage $postage
|
||||
*/
|
||||
public function setPostage($postage)
|
||||
{
|
||||
$this->postage = OrderPostage::loadFromPostage($postage);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidModule()
|
||||
{
|
||||
return $this->validModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $validModule
|
||||
*/
|
||||
public function setValidModule($validModule)
|
||||
{
|
||||
$this->validModule = $validModule;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAdditionalData()
|
||||
{
|
||||
return count($this->additionalData) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAdditionalData()
|
||||
{
|
||||
return $this->additionalData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $additionalData
|
||||
*/
|
||||
public function setAdditionalData($additionalData)
|
||||
{
|
||||
$this->additionalData = $additionalData;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key the key of the additional data
|
||||
* @param mixed $value the value of the additional data
|
||||
*
|
||||
* return $this
|
||||
*/
|
||||
public function addAdditionalData($key, $value)
|
||||
{
|
||||
$this->additionalData[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Country|null
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->getAddress() !== null ? $this->getAddress()->getCountry() : $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return State|null
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->getAddress() !== null ? $this->getAddress()->getState() : $this->state;
|
||||
}
|
||||
}
|
||||
@@ -93,5 +93,4 @@ class DocumentDeleteEvent extends FileDeleteEvent
|
||||
{
|
||||
return parent::getFileToDelete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Document;
|
||||
|
||||
use Thelia\Core\Event\CachedFileEvent;
|
||||
|
||||
/**
|
||||
@@ -70,5 +71,4 @@ class DocumentEvent extends CachedFileEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
158
core/lib/Thelia/Core/Event/ExportEvent.php
Normal file
158
core/lib/Thelia/Core/Event/ExportEvent.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?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;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Core\Archiver\ArchiverInterface;
|
||||
use Thelia\Core\Serializer\SerializerInterface;
|
||||
use Thelia\ImportExport\Export\AbstractExport;
|
||||
|
||||
/**
|
||||
* Class ExportEvent
|
||||
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||
*/
|
||||
class ExportEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\ImportExport\Export\AbstractExport An export
|
||||
*/
|
||||
protected $export;
|
||||
|
||||
/**
|
||||
* @var \Thelia\Core\Serializer\SerializerInterface A serializer interface
|
||||
*/
|
||||
protected $serializer;
|
||||
|
||||
/**
|
||||
* @var null|\Thelia\Core\Archiver\ArchiverInterface An archiver interface
|
||||
*/
|
||||
protected $archiver;
|
||||
|
||||
/**
|
||||
* @var string Path to generated export
|
||||
*/
|
||||
protected $filePath;
|
||||
|
||||
/**
|
||||
* Event constructor
|
||||
*
|
||||
* @param \Thelia\ImportExport\Export\AbstractExport $export An export
|
||||
* @param \Thelia\Core\Serializer\SerializerInterface $serializer A serializer interface
|
||||
* @param \Thelia\Core\Archiver\ArchiverInterface $archiver An archiver interface
|
||||
*/
|
||||
public function __construct(
|
||||
AbstractExport $export,
|
||||
SerializerInterface $serializer,
|
||||
ArchiverInterface $archiver = null
|
||||
) {
|
||||
$this->export = $export;
|
||||
$this->serializer = $serializer;
|
||||
$this->archiver = $archiver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get export
|
||||
*
|
||||
* @return \Thelia\ImportExport\Export\AbstractExport An export
|
||||
*/
|
||||
public function getExport()
|
||||
{
|
||||
return $this->export;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set export
|
||||
*
|
||||
* @param \Thelia\ImportExport\Export\AbstractExport $export An export
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function setExport(AbstractExport $export)
|
||||
{
|
||||
$this->export = $export;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get serializer
|
||||
*
|
||||
* @return \Thelia\Core\Serializer\SerializerInterface A serializer interface
|
||||
*/
|
||||
public function getSerializer()
|
||||
{
|
||||
return $this->serializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set serializer
|
||||
*
|
||||
* @param \Thelia\Core\Serializer\SerializerInterface $serializer A serializer interface
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function setSerializer(SerializerInterface $serializer)
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get archiver
|
||||
*
|
||||
* @return mixed|\Thelia\Core\Archiver\ArchiverInterface An archiver interface
|
||||
*/
|
||||
public function getArchiver()
|
||||
{
|
||||
return $this->archiver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set archiver
|
||||
*
|
||||
* @param mixed|\Thelia\Core\Archiver\ArchiverInterface $archiver An archiver interface
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function setArchiver(ArchiverInterface $archiver = null)
|
||||
{
|
||||
$this->archiver = $archiver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get export file path
|
||||
*
|
||||
* @return string Export file path
|
||||
*/
|
||||
public function getFilePath()
|
||||
{
|
||||
return $this->filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set export file path
|
||||
*
|
||||
* @param string $filePath Export file path
|
||||
*
|
||||
* @return $this Return $this, allow chaining
|
||||
*/
|
||||
public function setFilePath($filePath)
|
||||
{
|
||||
$this->filePath = $filePath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -53,5 +53,4 @@ class FeatureAvCreateEvent extends FeatureAvEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,12 @@ namespace Thelia\Core\Event\Feature;
|
||||
|
||||
class FeatureAvDeleteEvent extends FeatureAvEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $featureAv_id;
|
||||
|
||||
/**
|
||||
* @param int $featureAv_id
|
||||
*/
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Feature;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\FeatureAv;
|
||||
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace Thelia\Core\Event\Feature;
|
||||
|
||||
class FeatureAvUpdateEvent extends FeatureAvCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $featureAv_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $featureAv_id
|
||||
*/
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
|
||||
@@ -53,5 +53,4 @@ class FeatureCreateEvent extends FeatureEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,12 @@ namespace Thelia\Core\Event\Feature;
|
||||
|
||||
class FeatureDeleteEvent extends FeatureEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $feature_id;
|
||||
|
||||
/**
|
||||
* @param int $feature_id
|
||||
*/
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Feature;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Feature;
|
||||
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace Thelia\Core\Event\Feature;
|
||||
|
||||
class FeatureUpdateEvent extends FeatureCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $feature_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param int $feature_id
|
||||
*/
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
|
||||
@@ -14,11 +14,22 @@ namespace Thelia\Core\Event\FeatureProduct;
|
||||
|
||||
class FeatureProductDeleteEvent extends FeatureProductEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $product_id;
|
||||
|
||||
/** @var int */
|
||||
protected $feature_id;
|
||||
|
||||
/**
|
||||
* FeatureProductDeleteEvent constructor.
|
||||
*
|
||||
* @param int $product_id
|
||||
* @param int $feature_id
|
||||
*/
|
||||
public function __construct($product_id, $feature_id)
|
||||
{
|
||||
parent::__construct(null);
|
||||
|
||||
$this->product_id = $product_id;
|
||||
$this->feature_id = $feature_id;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\FeatureProduct;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\FeatureProduct;
|
||||
|
||||
|
||||
@@ -14,24 +14,42 @@ namespace Thelia\Core\Event\FeatureProduct;
|
||||
|
||||
class FeatureProductUpdateEvent extends FeatureProductEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $product_id;
|
||||
|
||||
/** @var int */
|
||||
protected $feature_id;
|
||||
|
||||
protected $feature_value;
|
||||
protected $is_text_value;
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* @param int $product_id
|
||||
* @param int $feature_id
|
||||
* @param $feature_value
|
||||
* @param bool $is_text_value
|
||||
*/
|
||||
public function __construct($product_id, $feature_id, $feature_value, $is_text_value = false)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
$this->feature_id = $feature_id;
|
||||
$this->feature_value = $feature_value;
|
||||
$this->is_text_value = $is_text_value;
|
||||
$this->setIsTextValue($is_text_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the product id
|
||||
*/
|
||||
public function getProductId()
|
||||
{
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $product_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setProductId($product_id)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
@@ -39,11 +57,18 @@ class FeatureProductUpdateEvent extends FeatureProductEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $feature_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
@@ -65,13 +90,23 @@ class FeatureProductUpdateEvent extends FeatureProductEvent
|
||||
|
||||
public function getIsTextValue()
|
||||
{
|
||||
return $this->is_text_value;
|
||||
return (bool)$this->is_text_value;
|
||||
}
|
||||
|
||||
public function setIsTextValue($is_text_value)
|
||||
{
|
||||
$this->is_text_value = $is_text_value;
|
||||
$this->is_text_value = (bool)$is_text_value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class FileCreateOrUpdateEvent extends ActionEvent
|
||||
/**
|
||||
* Set uploaded file
|
||||
*
|
||||
* @param UploadedFile $uploadedFile File being uploaded
|
||||
* @param UploadedFile|null $uploadedFile File being uploaded
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -115,7 +115,7 @@ class FileCreateOrUpdateEvent extends ActionEvent
|
||||
/**
|
||||
* Get uploaded file
|
||||
*
|
||||
* @return UploadedFile
|
||||
* @return UploadedFile|null
|
||||
*/
|
||||
public function getUploadedFile()
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user