Rajout du dossier core + MAJ .gitignore
This commit is contained in:
76
core/lib/Thelia/Core/Application.php
Normal file
76
core/lib/Thelia/Core/Application.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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;
|
||||
|
||||
use Symfony\Component\Console\Application as BaseApplication;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
||||
* cli application for Thelia
|
||||
* Class Application
|
||||
* @package Thelia\Core
|
||||
* mfony\Component\HttpFoundation\Session\Session
|
||||
*/
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
public $kernel;
|
||||
|
||||
public function __construct(KernelInterface $kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
|
||||
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.'));
|
||||
}
|
||||
|
||||
public function getKernel()
|
||||
{
|
||||
return $this->kernel;
|
||||
}
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
return $this->kernel->getContainer();
|
||||
}
|
||||
|
||||
public function doRun(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$container = $this->kernel->getContainer();
|
||||
|
||||
foreach ($container->getParameter("command.definition") as $command) {
|
||||
$r = new \ReflectionClass($command);
|
||||
|
||||
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
|
||||
$this->add($r->newInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
core/lib/Thelia/Core/Archiver/AbstractArchiver.php
Normal file
87
core/lib/Thelia/Core/Archiver/AbstractArchiver.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
if (!$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]);
|
||||
}
|
||||
}
|
||||
72
core/lib/Thelia/Core/Bundle/TheliaBundle.php
Normal file
72
core/lib/Thelia/Core/Bundle/TheliaBundle.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Bundle;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
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\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;
|
||||
|
||||
/**
|
||||
* First Bundle use in Thelia
|
||||
* It initialize dependency injection container.
|
||||
*
|
||||
* @TODO load configuration from thelia plugin
|
||||
* @TODO register database configuration.
|
||||
*
|
||||
*
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
|
||||
class TheliaBundle extends Bundle
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Construct the depency injection builder
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
|
||||
*/
|
||||
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container
|
||||
->addCompilerPass(new FallbackParserPass())
|
||||
->addCompilerPass(new TranslatorPass())
|
||||
->addCompilerPass(new RegisterHookListenersPass(), PassConfig::TYPE_AFTER_REMOVING)
|
||||
->addCompilerPass(new RegisterRouterPass())
|
||||
->addCompilerPass(new RegisterCouponPass())
|
||||
->addCompilerPass(new RegisterCouponConditionPass())
|
||||
->addCompilerPass(new RegisterArchiverPass)
|
||||
->addCompilerPass(new RegisterAssetFilterPass())
|
||||
->addCompilerPass(new RegisterSerializerPass)
|
||||
->addCompilerPass(new StackPass())
|
||||
->addCompilerPass(new RegisterFormExtensionPass())
|
||||
->addCompilerPass(new CurrencyConverterProviderPass())
|
||||
->addCompilerPass(new RegisterListenersPass())
|
||||
;
|
||||
}
|
||||
}
|
||||
92
core/lib/Thelia/Core/Controller/ControllerResolver.php
Normal file
92
core/lib/Thelia/Core/Controller/ControllerResolver.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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\Controller;
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Thelia\Controller\BaseController;
|
||||
|
||||
/**
|
||||
* ControllerResolver that supports "a:b:c", "service:method" and class::method" notations in routes definition
|
||||
* thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ControllerResolver extends BaseControllerResolver
|
||||
{
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerInterface $container A ContainerInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a callable for the given controller.
|
||||
*
|
||||
* @param string $controller A Controller string
|
||||
*
|
||||
* @return mixed A PHP callable
|
||||
*
|
||||
* @throws \LogicException When the name could not be parsed
|
||||
* @throws \InvalidArgumentException When the controller class does not exist
|
||||
*/
|
||||
protected function createController($controller)
|
||||
{
|
||||
if (false === strpos($controller, '::')) {
|
||||
$count = substr_count($controller, ':');
|
||||
if (2 == $count) {
|
||||
// controller in the a:b:c notation then
|
||||
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);
|
||||
|
||||
return array($this->container->get($service), $method);
|
||||
} else {
|
||||
throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller));
|
||||
}
|
||||
} else {
|
||||
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();
|
||||
|
||||
$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,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 RegisterListenersPass
|
||||
* Source code come from Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass class
|
||||
*
|
||||
* Register all available Conditions for the coupon module
|
||||
*
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RegisterCouponConditionPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* 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('thelia.coupon.manager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$couponManager = $container->getDefinition('thelia.coupon.manager');
|
||||
$services = $container->findTaggedServiceIds("thelia.coupon.addCondition");
|
||||
|
||||
foreach ($services as $id => $condition) {
|
||||
$couponManager->addMethodCall(
|
||||
'addAvailableCondition',
|
||||
array(
|
||||
new Reference($id)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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\Reference;
|
||||
|
||||
/**
|
||||
* Class RegisterListenersPass
|
||||
* Source code come from Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass class
|
||||
*
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RegisterCouponPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* 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('thelia.coupon.manager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$couponManager = $container->getDefinition('thelia.coupon.manager');
|
||||
$services = $container->findTaggedServiceIds("thelia.coupon.addCoupon");
|
||||
|
||||
foreach ($services as $id => $rule) {
|
||||
$couponManager->addMethodCall(
|
||||
'addAvailableCoupon',
|
||||
array(
|
||||
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,420 @@
|
||||
<?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\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
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\ModuleHookQuery;
|
||||
use Thelia\Model\ModuleHook;
|
||||
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)
|
||||
{
|
||||
Tlog::getInstance()->addAlert($message);
|
||||
|
||||
if ($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()
|
||||
)
|
||||
) {
|
||||
$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));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidHookMethod($className, $methodName, $block)
|
||||
{
|
||||
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));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
*
|
||||
* this compiler can add many router to symfony-cms routing
|
||||
*
|
||||
* Class RegisterRouterPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class RegisterRouterPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
try {
|
||||
$chainRouter = $container->getDefinition("router.chainRequest");
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($container->findTaggedServiceIds("router.register") as $id => $attributes) {
|
||||
$priority = isset($attributes[0]["priority"]) ? $attributes[0]["priority"] : 0;
|
||||
$router = $container->getDefinition($id);
|
||||
$router->addMethodCall("setOption", array("matcher_cache_class", $container::camelize("ProjectUrlMatcher".$id)));
|
||||
$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();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$moduleBaseDir = $module->getBaseDir();
|
||||
$routingConfigFilePath = $module->getAbsoluteBaseDir() . DS . "Config" . DS . "routing.xml";
|
||||
|
||||
if (file_exists($routingConfigFilePath)) {
|
||||
$definition = new Definition(
|
||||
$container->getParameter("router.class"),
|
||||
array(
|
||||
new Reference("router.module.xmlLoader"),
|
||||
$routingConfigFilePath,
|
||||
array(
|
||||
"cache_dir" => $container->getParameter("kernel.cache_dir"),
|
||||
"debug" => $container->getParameter("kernel.debug"),
|
||||
"matcher_cache_class" => $container::camelize("ProjectUrlMatcher".$moduleBaseDir),
|
||||
"generator_cache_class" => $container::camelize("ProjectUrlGenerator".$moduleBaseDir),
|
||||
),
|
||||
new Reference("request.context")
|
||||
)
|
||||
);
|
||||
|
||||
$container->setDefinition("router.".$moduleBaseDir, $definition);
|
||||
|
||||
$chainRouter->addMethodCall("add", array(new Reference("router.".$moduleBaseDir), 150));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Class TranslatorPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class TranslatorPass 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.translator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$translator = $container->getDefinition('thelia.translator');
|
||||
|
||||
foreach ($container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
|
||||
$translator->addMethodCall('addLoader', array($attributes[0]['alias'], new Reference($id)));
|
||||
if (isset($attributes[0]['legacy-alias'])) {
|
||||
$translator->addMethodCall('addLoader', array($attributes[0]['legacy-alias'], new Reference($id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,795 @@
|
||||
<?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\Loader;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
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\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;
|
||||
use Thelia\Model\ExportCategoryQuery;
|
||||
use Thelia\Model\ExportQuery;
|
||||
use Thelia\Model\Import;
|
||||
use Thelia\Model\ImportCategory;
|
||||
use Thelia\Model\ImportCategoryQuery;
|
||||
use Thelia\Model\ImportQuery;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Load, read and validate config xml files
|
||||
*
|
||||
* Class XmlFileLoader
|
||||
* @package Thelia\Core\DependencyInjection\Loader
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class XmlFileLoader extends FileLoader
|
||||
{
|
||||
const DEFAULT_HOOK_CLASS = "Thelia\\Core\\Hook\\DefaultHook";
|
||||
|
||||
/**
|
||||
* Loads an XML file.
|
||||
*
|
||||
* @param mixed $file The resource
|
||||
* @param string $type The resource type
|
||||
*/
|
||||
public function load($file, $type = null)
|
||||
{
|
||||
$path = $this->locator->locate($file);
|
||||
|
||||
$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);
|
||||
|
||||
$this->parseFilters($xml);
|
||||
|
||||
$this->parseTemplateDirectives($xml);
|
||||
|
||||
$this->parseParameters($xml);
|
||||
|
||||
$this->parseCommands($xml);
|
||||
|
||||
$this->parseForms($xml);
|
||||
|
||||
$this->parseDefinitions($xml, $path);
|
||||
|
||||
$this->parseHooks($xml, $path, $type);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseExportCategories"],
|
||||
$xml
|
||||
);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseExports"],
|
||||
$xml
|
||||
);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseImportCategories"],
|
||||
$xml
|
||||
);
|
||||
|
||||
$this->propelOnlyRun(
|
||||
[$this, "parseImports"],
|
||||
$xml
|
||||
);
|
||||
}
|
||||
|
||||
public function propelOnlyRun(callable $method, $arg)
|
||||
{
|
||||
if (Thelia::isInstalled()) {
|
||||
call_user_func($method, $arg);
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseCommands(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $commands = $xml->xpath('//config:commands/config:command')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$commandConfig = $this->container->getParameter("command.definition");
|
||||
} catch (ParameterNotFoundException $e) {
|
||||
$commandConfig = array();
|
||||
}
|
||||
|
||||
foreach ($commands as $command) {
|
||||
array_push($commandConfig, $this->getAttributeAsPhp($command, "class"));
|
||||
}
|
||||
|
||||
$this->container->setParameter("command.definition", $commandConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses parameters
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
*/
|
||||
protected function parseParameters(SimpleXMLElement $xml)
|
||||
{
|
||||
if (!$xml->parameters) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->container->getParameterBag()->add($this->getArgumentsAsPhp($xml->parameters, 'parameter'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* parse Loops property
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
*/
|
||||
protected function parseLoops(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $loops = $xml->xpath('//config:loops/config:loop')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$loopConfig = $this->container->getParameter("Thelia.parser.loops");
|
||||
} catch (ParameterNotFoundException $e) {
|
||||
$loopConfig = array();
|
||||
}
|
||||
|
||||
foreach ($loops as $loop) {
|
||||
$loopConfig[$this->getAttributeAsPhp($loop, "name")] = $this->getAttributeAsPhp($loop, "class");
|
||||
}
|
||||
|
||||
$this->container->setParameter("Thelia.parser.loops", $loopConfig);
|
||||
}
|
||||
|
||||
protected function parseForms(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $forms = $xml->xpath('//config:forms/config:form')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$formConfig = $this->container->getParameter("Thelia.parser.forms");
|
||||
} catch (ParameterNotFoundException $e) {
|
||||
$formConfig = array();
|
||||
}
|
||||
|
||||
foreach ($forms as $form) {
|
||||
$formConfig[$this->getAttributeAsPhp($form, 'name')] = $this->getAttributeAsPhp($form, 'class');
|
||||
}
|
||||
|
||||
$this->container->setParameter('Thelia.parser.forms', $formConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse Filters property
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
*/
|
||||
protected function parseFilters(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $filters = $xml->xpath('//config:filters/config:filter')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
|
||||
} catch (ParameterNotFoundException $e) {
|
||||
$filterConfig = array();
|
||||
}
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
$filterConfig[$this->getAttributeAsPhp($filter, "name")] = $this->getAttributeAsPhp($filter, "class");
|
||||
}
|
||||
|
||||
$this->container->setParameter("Thelia.parser.filters", $filterConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse BaseParams property
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
*/
|
||||
protected function parseTemplateDirectives(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $baseParams = $xml->xpath('//config:templateDirectives/config:templateDirective')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives");
|
||||
} catch (ParameterNotFoundException $e) {
|
||||
$baseParamConfig = array();
|
||||
}
|
||||
|
||||
foreach ($baseParams as $baseParam) {
|
||||
$baseParamConfig[$this->getAttributeAsPhp($baseParam, "name")] = $this->getAttributeAsPhp($baseParam, "class");
|
||||
}
|
||||
|
||||
$this->container->setParameter("Thelia.parser.templateDirectives", $baseParamConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses multiple definitions
|
||||
*
|
||||
* @param SimpleXMLElement $xml
|
||||
* @param string $file
|
||||
*/
|
||||
protected function parseDefinitions(SimpleXMLElement $xml, $file)
|
||||
{
|
||||
if (false === $services = $xml->xpath('//config:services/config:service')) {
|
||||
return;
|
||||
}
|
||||
foreach ($services as $service) {
|
||||
$this->parseDefinition((string) $service['id'], $service, $file);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
* @return Definition
|
||||
*/
|
||||
protected function parseService($id, $service, $file)
|
||||
{
|
||||
if ((string) $service['alias']) {
|
||||
$public = true;
|
||||
if (isset($service['public'])) {
|
||||
$public = $this->getAttributeAsPhp($service, 'public');
|
||||
}
|
||||
$this->container->setAlias($id, new Alias((string) $service['alias'], $public));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($service['parent'])) {
|
||||
$definition = new DefinitionDecorator((string) $service['parent']);
|
||||
} else {
|
||||
$definition = new Definition();
|
||||
}
|
||||
|
||||
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) $this->getAttributeAsPhp($service, $key));
|
||||
}
|
||||
}
|
||||
|
||||
if ($service->file) {
|
||||
$definition->setFile((string) $service->file);
|
||||
}
|
||||
|
||||
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
|
||||
$definition->setProperties($this->getArgumentsAsPhp($service, 'property'));
|
||||
|
||||
if (isset($service->configurator)) {
|
||||
if (isset($service->configurator['function'])) {
|
||||
$definition->setConfigurator((string) $service->configurator['function']);
|
||||
} else {
|
||||
if (isset($service->configurator['service'])) {
|
||||
$class = new Reference((string) $service->configurator['service'], ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);
|
||||
} else {
|
||||
$class = (string) $service->configurator['class'];
|
||||
}
|
||||
|
||||
$definition->setConfigurator(array($class, (string) $service->configurator['method']));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($service->call as $call) {
|
||||
$definition->addMethodCall((string) $call['method'], $this->getArgumentsAsPhp($call, 'argument'));
|
||||
}
|
||||
|
||||
foreach ($service->tag as $tag) {
|
||||
$parameters = array();
|
||||
foreach ($tag->attributes() as $name => $value) {
|
||||
if ('name' === $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parameters[$name] = XmlUtils::phpize($value);
|
||||
}
|
||||
|
||||
$definition->addTag((string) $tag['name'], $parameters);
|
||||
}
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
protected function parseExportCategories(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $exportCategories = $xml->xpath('//config:export_categories/config:export_category')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$con = Propel::getWriteConnection(ExportCategoryTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
/** @var SimpleXMLElement $exportCategory */
|
||||
foreach ($exportCategories as $exportCategory) {
|
||||
$id = (string) $this->getAttributeAsPhp($exportCategory, "id");
|
||||
|
||||
$exportCategoryModel = ExportCategoryQuery::create()->findOneByRef($id);
|
||||
|
||||
if ($exportCategoryModel === null) {
|
||||
$exportCategoryModel = new ExportCategory();
|
||||
$exportCategoryModel
|
||||
->setRef($id)
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
|
||||
/** @var SimpleXMLElement $child */
|
||||
foreach ($exportCategory->children() as $child) {
|
||||
$locale = (string) $this->getAttributeAsPhp($child, "locale");
|
||||
$value = (string) $child;
|
||||
|
||||
$exportCategoryModel
|
||||
->setLocale($locale)
|
||||
->setTitle($value)
|
||||
->save($con);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
|
||||
Tlog::getInstance()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseExports(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $exports = $xml->xpath('//config:exports/config:export')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$con = Propel::getWriteConnection(ExportTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
/** @var SimpleXMLElement $export */
|
||||
foreach ($exports as $export) {
|
||||
$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(
|
||||
"The class \"$class\" doesn't exist"
|
||||
);
|
||||
}
|
||||
|
||||
$category = ExportCategoryQuery::create()->findOneByRef($categoryRef);
|
||||
|
||||
if (null === $category) {
|
||||
throw new \ErrorException(
|
||||
"The export category \"$categoryRef\" doesn't exist"
|
||||
);
|
||||
}
|
||||
|
||||
$exportModel = ExportQuery::create()->findOneByRef($id);
|
||||
|
||||
if (null === $exportModel) {
|
||||
$exportModel = new Export();
|
||||
$exportModel
|
||||
->setRef($id)
|
||||
;
|
||||
}
|
||||
|
||||
$exportModel
|
||||
->setExportCategory($category)
|
||||
->setHandleClass($class)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
/** @var SimpleXMLElement $descriptive */
|
||||
foreach ($export->children() as $descriptive) {
|
||||
$locale = $this->getAttributeAsPhp($descriptive, "locale");
|
||||
$title = null;
|
||||
$description = null;
|
||||
|
||||
/** @var SimpleXMLElement $row */
|
||||
foreach ($descriptive->children() as $row) {
|
||||
switch ($row->getName()) {
|
||||
case "title":
|
||||
$title = (string) $row;
|
||||
break;
|
||||
case "description":
|
||||
$description = (string) $row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$exportModel
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setDescription($description)
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
|
||||
Tlog::getInstance()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseImportCategories(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $importCategories = $xml->xpath('//config:import_categories/config:import_category')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$con = Propel::getWriteConnection(ImportCategoryTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
/** @var SimpleXMLElement $importCategory */
|
||||
foreach ($importCategories as $importCategory) {
|
||||
$id = (string) $this->getAttributeAsPhp($importCategory, "id");
|
||||
|
||||
$importCategoryModel = ImportCategoryQuery::create()->findOneByRef($id);
|
||||
|
||||
if ($importCategoryModel === null) {
|
||||
$importCategoryModel = new ImportCategory();
|
||||
$importCategoryModel
|
||||
->setRef($id)
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
|
||||
/** @var SimpleXMLElement $child */
|
||||
foreach ($importCategory->children() as $child) {
|
||||
$locale = (string) $this->getAttributeAsPhp($child, "locale");
|
||||
$value = (string) $child;
|
||||
|
||||
$importCategoryModel
|
||||
->setLocale($locale)
|
||||
->setTitle($value)
|
||||
->save($con);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
|
||||
Tlog::getInstance()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseImports(SimpleXMLElement $xml)
|
||||
{
|
||||
if (false === $imports = $xml->xpath('//config:imports/config:import')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$con = Propel::getWriteConnection(ImportTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
/** @var SimpleXMLElement $import */
|
||||
foreach ($imports as $import) {
|
||||
$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"
|
||||
);
|
||||
}
|
||||
|
||||
$category = ImportCategoryQuery::create()->findOneByRef($categoryRef);
|
||||
|
||||
if (null === $category) {
|
||||
throw new \ErrorException(
|
||||
"The import category \"$categoryRef\" doesn't exist"
|
||||
);
|
||||
}
|
||||
|
||||
$importModel = ImportQuery::create()->findOneByRef($id);
|
||||
|
||||
if (null === $importModel) {
|
||||
$importModel = new Import();
|
||||
$importModel
|
||||
->setRef($id)
|
||||
;
|
||||
}
|
||||
|
||||
$importModel
|
||||
->setImportCategory($category)
|
||||
->setHandleClass($class)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
/** @var SimpleXMLElement $descriptive */
|
||||
foreach ($import->children() as $descriptive) {
|
||||
$locale = $this->getAttributeAsPhp($descriptive, "locale");
|
||||
$title = null;
|
||||
$description = null;
|
||||
|
||||
/** @var SimpleXMLElement $row */
|
||||
foreach ($descriptive->children() as $row) {
|
||||
switch ($row->getName()) {
|
||||
case "title":
|
||||
$title = (string) $row;
|
||||
break;
|
||||
case "description":
|
||||
$description = (string) $row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$importModel
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setDescription($description)
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
|
||||
Tlog::getInstance()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a XML file.
|
||||
*
|
||||
* @param string $file Path to a file
|
||||
*
|
||||
* @return SimpleXMLElement
|
||||
*
|
||||
* @throws InvalidArgumentException When loading of XML file returns error
|
||||
*/
|
||||
protected function parseFile($file)
|
||||
{
|
||||
try {
|
||||
$dom = XmlUtils::loadFile($file, array($this, 'validateSchema'));
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
return simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a documents XML schema.
|
||||
*
|
||||
* @param \DOMDocument $dom
|
||||
*
|
||||
* @return Boolean
|
||||
*
|
||||
* @throws RuntimeException When extension references a non-existent XSD file
|
||||
*/
|
||||
public function validateSchema(\DOMDocument $dom)
|
||||
{
|
||||
$schemaLocations = array('http://thelia.net/schema/dic/config' => str_replace('\\', '/', __DIR__.'/schema/dic/config/thelia-1.0.xsd'));
|
||||
|
||||
$tmpfiles = array();
|
||||
$imports = '';
|
||||
foreach ($schemaLocations as $namespace => $location) {
|
||||
$parts = explode('/', $location);
|
||||
if (0 === stripos($location, 'phar://')) {
|
||||
$tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
|
||||
if ($tmpfile) {
|
||||
copy($location, $tmpfile);
|
||||
$tmpfiles[] = $tmpfile;
|
||||
$parts = explode('/', str_replace('\\', '/', $tmpfile));
|
||||
}
|
||||
}
|
||||
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
|
||||
$location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
|
||||
|
||||
$imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location);
|
||||
}
|
||||
|
||||
$source = <<<EOF
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<xsd:schema xmlns="http://symfony.com/schema"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://symfony.com/schema"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
|
||||
$imports
|
||||
</xsd:schema>
|
||||
EOF
|
||||
;
|
||||
|
||||
$valid = @$dom->schemaValidateSource($source);
|
||||
|
||||
foreach ($tmpfiles as $tmpfile) {
|
||||
@unlink($tmpfile);
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this class supports the given resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return Boolean true if this class supports the given resource, false otherwise
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
// 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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<xsd:schema xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://thelia.net/schema/dic/config"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<xsd:element name="config" type="config" />
|
||||
|
||||
<xsd:complexType name="config">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="loops" type="loops" />
|
||||
<xsd:element name="filters" type="filters" />
|
||||
<xsd:element name="templateDirectives" type="templateDirectives" />
|
||||
<xsd:element name="services" type="services" />
|
||||
<xsd:element name="parameters" type="parameters"/>
|
||||
<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" />
|
||||
<xsd:element name="imports" type="imports" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="parameters">
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element name="parameter" type="parameter" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="parameter_type" />
|
||||
<xsd:attribute name="key" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="parameter" mixed="true">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="parameter" type="parameter" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="parameter_type" />
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="key" type="xsd:string" />
|
||||
<xsd:attribute name="on-invalid" type="invalid_sequence" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="parameter_type">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="collection" />
|
||||
<xsd:enumeration value="service" />
|
||||
<xsd:enumeration value="string" />
|
||||
<xsd:enumeration value="constant" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name="invalid_sequence">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="null" />
|
||||
<xsd:enumeration value="ignore" />
|
||||
<xsd:enumeration value="exception" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:complexType name="routing">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="file" type="file"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="file">
|
||||
<xsd:attribute name="path" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="loops">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
|
||||
<xsd:element name="loop" type="loop"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="loop">
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="commands">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
|
||||
<xsd:element name="command" type="command"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="command">
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="forms">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
|
||||
<xsd:element name="form" type="form" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="form">
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="filters">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="filter" type="filter" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="filter">
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="templateDirectives">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="templateDirective" type="templateDirective" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="templateDirective">
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="services">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Enclosing element for the definition of all services
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element name="service" type="service" />
|
||||
</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" />
|
||||
<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="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: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" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="property" mixed="true">
|
||||
<xsd:choice minOccurs="0" maxOccurs="1">
|
||||
<xsd:element name="service" type="service" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="argument_type" />
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="on-invalid" type="xsd:string" />
|
||||
<xsd:attribute name="strict" type="boolean" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="argument" mixed="true">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="service" type="service" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="argument_type" />
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="key" type="xsd:string" />
|
||||
<xsd:attribute name="index" type="xsd:integer" />
|
||||
<xsd:attribute name="on-invalid" type="xsd:string" />
|
||||
<xsd:attribute name="strict" type="boolean" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="call" mixed="true">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="service" type="service" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="method" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="argument_type">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="collection" />
|
||||
<xsd:enumeration value="service" />
|
||||
<xsd:enumeration value="string" />
|
||||
<xsd:enumeration value="constant" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name="boolean">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:pattern value="(%.+%|true|false)" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:complexType name="configurator">
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="service" type="xsd:string" />
|
||||
<xsd:attribute name="class" type="xsd:string" />
|
||||
<xsd:attribute name="method" type="xsd:string" />
|
||||
<xsd:attribute name="function" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="export_categories">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="export_category" type="export_category"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="export_category">
|
||||
<xsd:choice maxOccurs="unbounded" minOccurs="1">
|
||||
<xsd:element name="title" type="export_category_title" />
|
||||
</xsd:choice>
|
||||
|
||||
<xsd:attribute name="id" use="required" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="export_category_title">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="locale" type="xsd:string" use="required"/>
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="exports">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="export" type="export"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="export">
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element name="export_descriptive" type="export_descriptive" />
|
||||
</xsd:choice>
|
||||
|
||||
<xsd:attribute name="id" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="class" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="category_id" type="xsd:string" use="required"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="export_descriptive">
|
||||
<xsd:sequence minOccurs="1" maxOccurs="1">
|
||||
<xsd:element name="title" type="xsd:string" />
|
||||
<xsd:element minOccurs="0" maxOccurs="1" name="description" type="xsd:string" />
|
||||
</xsd:sequence>
|
||||
|
||||
<xsd:attribute name="locale" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="import_categories">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="import_category" type="import_category"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="import_category">
|
||||
<xsd:choice maxOccurs="unbounded" minOccurs="1">
|
||||
<xsd:element name="title" type="import_category_title" />
|
||||
</xsd:choice>
|
||||
|
||||
<xsd:attribute name="id" use="required" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="import_category_title">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="locale" type="xsd:string" use="required"/>
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="imports">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="import" type="import"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="import">
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element name="import_descriptive" type="import_descriptive" />
|
||||
</xsd:choice>
|
||||
|
||||
<xsd:attribute name="id" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="class" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="category_id" type="xsd:string" use="required"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="import_descriptive">
|
||||
<xsd:sequence minOccurs="1" maxOccurs="1">
|
||||
<xsd:element name="title" type="xsd:string" />
|
||||
<xsd:element minOccurs="0" maxOccurs="1" name="description" type="xsd:string" />
|
||||
</xsd:sequence>
|
||||
|
||||
<xsd:attribute name="locale" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
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);
|
||||
}
|
||||
}
|
||||
42
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
42
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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 Thelia\Model\Accessory;
|
||||
|
||||
class AccessoryEvent extends ActionEvent
|
||||
{
|
||||
public $accessory = null;
|
||||
|
||||
public function __construct(Accessory $accessory = null)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
}
|
||||
|
||||
public function hasAccessory()
|
||||
{
|
||||
return ! is_null($this->accessory);
|
||||
}
|
||||
|
||||
public function getAccessory()
|
||||
{
|
||||
return $this->accessory;
|
||||
}
|
||||
|
||||
public function setAccessory(Accessory $accessory)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
65
core/lib/Thelia/Core/Event/ActionEvent.php
Normal file
65
core/lib/Thelia/Core/Event/ActionEvent.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\DependencyInjection\Container;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\Form\Form;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class thrown on Thelia.action event
|
||||
*
|
||||
* call setAction if action match yours
|
||||
*
|
||||
*/
|
||||
abstract class ActionEvent extends Event
|
||||
{
|
||||
protected $parameters = array();
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->parameters[$name] = $value;
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->parameters)) {
|
||||
return $this->parameters[$name];
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
<?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\Address;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
/**
|
||||
* Class AddressCreateOrUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var string address label
|
||||
*/
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* @var int title id
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* @var string|null company name
|
||||
*/
|
||||
protected $company;
|
||||
|
||||
/**
|
||||
* @var string first name
|
||||
*/
|
||||
protected $firstname;
|
||||
|
||||
/**
|
||||
* @var string last name
|
||||
*/
|
||||
protected $lastname;
|
||||
|
||||
/**
|
||||
* @var string address
|
||||
*/
|
||||
protected $address1;
|
||||
|
||||
/**
|
||||
* @var string address line 2
|
||||
*/
|
||||
protected $address2;
|
||||
|
||||
/**
|
||||
* @var string address line 3
|
||||
*/
|
||||
protected $address3;
|
||||
|
||||
/**
|
||||
* @var string zipcode
|
||||
*/
|
||||
protected $zipcode;
|
||||
|
||||
/**
|
||||
* @var string city
|
||||
*/
|
||||
protected $city;
|
||||
|
||||
/**
|
||||
* @var int country id
|
||||
*/
|
||||
protected $country;
|
||||
|
||||
/**
|
||||
* @var int state id
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* @var string cell phone
|
||||
*/
|
||||
protected $cellphone;
|
||||
|
||||
/**
|
||||
* @var string phone
|
||||
*/
|
||||
protected $phone;
|
||||
|
||||
/**
|
||||
* @var \Thelia\Model\Customer
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* @var \Thelia\Model\Address
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $isDefault;
|
||||
|
||||
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;
|
||||
$this->cellphone = $cellphone;
|
||||
$this->city = $city;
|
||||
$this->company = $company;
|
||||
$this->country = $country;
|
||||
$this->state = $state;
|
||||
$this->firstname = $firstname;
|
||||
$this->label = $label;
|
||||
$this->lastname = $lastname;
|
||||
$this->phone = $phone;
|
||||
$this->title = $title;
|
||||
$this->zipcode = $zipcode;
|
||||
$this->isDefault = $isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress1()
|
||||
{
|
||||
return $this->address1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress2()
|
||||
{
|
||||
return $this->address2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress3()
|
||||
{
|
||||
return $this->address3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCellphone()
|
||||
{
|
||||
return $this->cellphone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCity()
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstname()
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastname()
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone()
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getZipcode()
|
||||
{
|
||||
return $this->zipcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIsDefault()
|
||||
{
|
||||
return $this->isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Customer $customer
|
||||
*/
|
||||
public function setCustomer(Customer $customer)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Customer
|
||||
*/
|
||||
public function getCustomer()
|
||||
{
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Address $address
|
||||
*/
|
||||
public function setAddress(Address $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->setCustomer($address->getCustomer());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Address
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
}
|
||||
42
core/lib/Thelia/Core/Event/Address/AddressEvent.php
Normal file
42
core/lib/Thelia/Core/Event/Address/AddressEvent.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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\Address;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Address;
|
||||
|
||||
/**
|
||||
* Class AddressEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AddressEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Address
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
public function __construct(Address $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Address
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
}
|
||||
159
core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
Normal file
159
core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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\Administrator;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
class AdministratorEvent extends ActionEvent
|
||||
{
|
||||
protected $administrator = null;
|
||||
protected $id = null;
|
||||
protected $firstname = null;
|
||||
protected $lastname = null;
|
||||
protected $login = null;
|
||||
protected $email = null;
|
||||
protected $password = null;
|
||||
protected $profile = null;
|
||||
protected $locale = null;
|
||||
|
||||
public function __construct(Admin $administrator = null)
|
||||
{
|
||||
$this->administrator = $administrator;
|
||||
}
|
||||
|
||||
public function hasAdministrator()
|
||||
{
|
||||
return ! is_null($this->administrator);
|
||||
}
|
||||
|
||||
public function getAdministrator()
|
||||
{
|
||||
return $this->administrator;
|
||||
}
|
||||
|
||||
public function setAdministrator(Admin $administrator)
|
||||
{
|
||||
$this->administrator = $administrator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setFirstname($firstname)
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFirstname()
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
public function setLastname($lastname)
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastname()
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setProfile($profile)
|
||||
{
|
||||
if (0 === $profile) {
|
||||
$profile = null;
|
||||
}
|
||||
|
||||
$this->profile = $profile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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\Administrator;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
/**
|
||||
* Class AdministratorUpdatePasswordEvent
|
||||
* @package Thelia\Core\Event\Administrator
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Admin
|
||||
*/
|
||||
protected $admin;
|
||||
|
||||
/**
|
||||
* @var string new administrator password
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
public function __construct(Admin $admin)
|
||||
{
|
||||
$this->admin = $admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Admin $admin
|
||||
*/
|
||||
public function setAdmin(Admin $admin)
|
||||
{
|
||||
$this->admin = $admin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Admin
|
||||
*/
|
||||
public function getAdmin()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
72
core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php
Normal file
72
core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Area;
|
||||
|
||||
/**
|
||||
* Class AreaAddCountryEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaAddCountryEvent extends AreaEvent
|
||||
{
|
||||
protected $areaId;
|
||||
protected $countryId;
|
||||
|
||||
public function __construct($areaId, $countryId)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->areaId = $areaId;
|
||||
$this->countryId = $countryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $areaId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($areaId)
|
||||
{
|
||||
$this->areaId = $areaId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->areaId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $countryId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCountryId($countryId)
|
||||
{
|
||||
$this->countryId = $countryId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->countryId;
|
||||
}
|
||||
}
|
||||
41
core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php
Normal file
41
core/lib/Thelia/Core/Event/Area/AreaCreateEvent.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\Area;
|
||||
|
||||
/**
|
||||
* Class AreaCreateEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaCreateEvent extends AreaEvent
|
||||
{
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function setAreaName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php
Normal file
51
core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Area;
|
||||
|
||||
/**
|
||||
* Class AreaDeleteEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaDeleteEvent extends AreaEvent
|
||||
{
|
||||
/**
|
||||
* @var int area id
|
||||
*/
|
||||
protected $area_id;
|
||||
|
||||
public function __construct($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $area_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
}
|
||||
58
core/lib/Thelia/Core/Event/Area/AreaEvent.php
Normal file
58
core/lib/Thelia/Core/Event/Area/AreaEvent.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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\Area;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
/**
|
||||
* Class AreaEvent
|
||||
* @package Thelia\Core\Event\Shipping
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Area
|
||||
*/
|
||||
protected $area;
|
||||
|
||||
public function __construct($area = null)
|
||||
{
|
||||
$this->area = $area;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setArea($area)
|
||||
{
|
||||
$this->area = $area;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|\Thelia\Model\Area
|
||||
*/
|
||||
public function getArea()
|
||||
{
|
||||
return $this->area;
|
||||
}
|
||||
|
||||
public function hasArea()
|
||||
{
|
||||
return null !== $this->area;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
/**
|
||||
* Class AreaRemoveCountryEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
41
core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php
Normal file
41
core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.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\Area;
|
||||
|
||||
/**
|
||||
* Class AreaUpdateEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.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\Area;
|
||||
|
||||
/**
|
||||
* Class AreaUpdatePostageEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AreaUpdatePostageEvent extends AreaEvent
|
||||
{
|
||||
protected $area_id;
|
||||
protected $postage;
|
||||
|
||||
public function __construct($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postage
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostage($postage)
|
||||
{
|
||||
$this->postage = $postage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostage()
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
}
|
||||
@@ -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\Event\Attribute;
|
||||
|
||||
class AttributeAvCreateEvent extends AttributeAvEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $attribute_id;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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\Attribute;
|
||||
|
||||
class AttributeAvDeleteEvent extends AttributeAvEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $attributeAv_id;
|
||||
|
||||
/**
|
||||
* @param int $attributeAv_id
|
||||
*/
|
||||
public function __construct($attributeAv_id)
|
||||
{
|
||||
$this->setAttributeAvId($attributeAv_id);
|
||||
}
|
||||
|
||||
public function getAttributeAvId()
|
||||
{
|
||||
return $this->attributeAv_id;
|
||||
}
|
||||
|
||||
public function setAttributeAvId($attributeAv_id)
|
||||
{
|
||||
$this->attributeAv_id = $attributeAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Core/Event/Attribute/AttributeAvEvent.php
Normal file
43
core/lib/Thelia/Core/Event/Attribute/AttributeAvEvent.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\Attribute;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\AttributeAv;
|
||||
|
||||
class AttributeAvEvent extends ActionEvent
|
||||
{
|
||||
protected $attributeAv = null;
|
||||
|
||||
public function __construct(AttributeAv $attributeAv = null)
|
||||
{
|
||||
$this->attributeAv = $attributeAv;
|
||||
}
|
||||
|
||||
public function hasAttributeAv()
|
||||
{
|
||||
return ! is_null($this->attributeAv);
|
||||
}
|
||||
|
||||
public function getAttributeAv()
|
||||
{
|
||||
return $this->attributeAv;
|
||||
}
|
||||
|
||||
public function setAttributeAv($attributeAv)
|
||||
{
|
||||
$this->attributeAv = $attributeAv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -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\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);
|
||||
}
|
||||
|
||||
public function getAttributeAvId()
|
||||
{
|
||||
return $this->attributeAv_id;
|
||||
}
|
||||
|
||||
public function setAttributeAvId($attributeAv_id)
|
||||
{
|
||||
$this->attributeAv_id = $attributeAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -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\Event\Attribute;
|
||||
|
||||
class AttributeCreateEvent extends AttributeEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $add_to_all_templates;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddToAllTemplates()
|
||||
{
|
||||
return $this->add_to_all_templates;
|
||||
}
|
||||
|
||||
public function setAddToAllTemplates($add_to_all_templates)
|
||||
{
|
||||
$this->add_to_all_templates = $add_to_all_templates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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\Attribute;
|
||||
|
||||
class AttributeDeleteEvent extends AttributeEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $attribute_id;
|
||||
|
||||
/**
|
||||
* @param int $attribute_id
|
||||
*/
|
||||
public function __construct($attribute_id)
|
||||
{
|
||||
$this->setAttributeId($attribute_id);
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Core/Event/Attribute/AttributeEvent.php
Normal file
43
core/lib/Thelia/Core/Event/Attribute/AttributeEvent.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\Attribute;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Attribute;
|
||||
|
||||
class AttributeEvent extends ActionEvent
|
||||
{
|
||||
protected $attribute = null;
|
||||
|
||||
public function __construct(Attribute $attribute = null)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
}
|
||||
|
||||
public function hasAttribute()
|
||||
{
|
||||
return ! is_null($this->attribute);
|
||||
}
|
||||
|
||||
public function getAttribute()
|
||||
{
|
||||
return $this->attribute;
|
||||
}
|
||||
|
||||
public function setAttribute($attribute)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -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\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);
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
85
core/lib/Thelia/Core/Event/Brand/BrandCreateEvent.php
Normal file
85
core/lib/Thelia/Core/Event/Brand/BrandCreateEvent.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Brand;
|
||||
|
||||
/**
|
||||
* Class BrandCreateEvent
|
||||
* @package Thelia\Core\Event\Brand
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class BrandCreateEvent extends BrandEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param string $locale
|
||||
*
|
||||
* @return BrandCreateEvent $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*
|
||||
* @return BrandCreateEvent $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $visible
|
||||
*
|
||||
* @return BrandCreateEvent $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/Brand/BrandDeleteEvent.php
Normal file
52
core/lib/Thelia/Core/Event/Brand/BrandDeleteEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Brand;
|
||||
|
||||
/**
|
||||
* Class BrandDeleteEvent
|
||||
* @package Thelia\Core\Event\Brand
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class BrandDeleteEvent extends BrandEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $brand_id;
|
||||
|
||||
/**
|
||||
* @param int $brand_id
|
||||
*/
|
||||
public function __construct($brand_id)
|
||||
{
|
||||
$this->brand_id = $brand_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $brand_id
|
||||
*
|
||||
* @return BrandDeleteEvent $this
|
||||
*/
|
||||
public function setBrandId($brand_id)
|
||||
{
|
||||
$this->brand_id = $brand_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBrandId()
|
||||
{
|
||||
return $this->brand_id;
|
||||
}
|
||||
}
|
||||
63
core/lib/Thelia/Core/Event/Brand/BrandEvent.php
Normal file
63
core/lib/Thelia/Core/Event/Brand/BrandEvent.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Brand;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Brand;
|
||||
|
||||
/**
|
||||
* Class BrandEvent
|
||||
* @package Thelia\Core\Event\Brand
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class BrandEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Brand
|
||||
*/
|
||||
protected $brand;
|
||||
|
||||
public function __construct(Brand $brand = null)
|
||||
{
|
||||
$this->brand = $brand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Brand $brand
|
||||
* @return BrandEvent
|
||||
*/
|
||||
public function setBrand(Brand $brand)
|
||||
{
|
||||
$this->brand = $brand;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Brand
|
||||
*/
|
||||
public function getBrand()
|
||||
{
|
||||
return $this->brand;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if brand exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBrand()
|
||||
{
|
||||
return null !== $this->brand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Brand;
|
||||
|
||||
/**
|
||||
* Class BrandToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event\Brand
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class BrandToggleVisibilityEvent extends BrandEvent
|
||||
{
|
||||
}
|
||||
135
core/lib/Thelia/Core/Event/Brand/BrandUpdateEvent.php
Normal file
135
core/lib/Thelia/Core/Event/Brand/BrandUpdateEvent.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Brand;
|
||||
|
||||
/**
|
||||
* Class BrandUpdateEvent
|
||||
* @package Thelia\Core\Event\Brand
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class BrandUpdateEvent extends BrandCreateEvent
|
||||
{
|
||||
protected $brandId;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
protected $logo_image_id;
|
||||
|
||||
/**
|
||||
* @param int $brandId
|
||||
*/
|
||||
public function __construct($brandId)
|
||||
{
|
||||
$this->brandId = $brandId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $chapo
|
||||
*
|
||||
* @return BrandUpdateEvent $this
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $brandId
|
||||
*
|
||||
* @return BrandUpdateEvent $this
|
||||
*/
|
||||
public function setBrandId($brandId)
|
||||
{
|
||||
$this->brandId = $brandId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBrandId()
|
||||
{
|
||||
return $this->brandId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*
|
||||
* @return BrandUpdateEvent $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $postscriptum
|
||||
*
|
||||
* @return BrandUpdateEvent $this
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $logo_image_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setLogoImageId($logo_image_id)
|
||||
{
|
||||
$this->logo_image_id = $logo_image_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLogoImageId()
|
||||
{
|
||||
return $this->logo_image_id;
|
||||
}
|
||||
}
|
||||
53
core/lib/Thelia/Core/Event/Cache/CacheEvent.php
Normal file
53
core/lib/Thelia/Core/Event/Cache/CacheEvent.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\Event\Cache;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
/**
|
||||
* Class CacheEvent
|
||||
* @package Thelia\Core\Event\Cache
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CacheEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var string cache directory
|
||||
*/
|
||||
protected $dir;
|
||||
|
||||
public function __construct($dir)
|
||||
{
|
||||
$this->dir = $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $dir
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDir($dir)
|
||||
{
|
||||
$this->dir = $dir;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDir()
|
||||
{
|
||||
return $this->dir;
|
||||
}
|
||||
}
|
||||
83
core/lib/Thelia/Core/Event/CachedFileEvent.php
Normal file
83
core/lib/Thelia/Core/Event/CachedFileEvent.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class CachedFileEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var string The complete file name (with path) of the source file
|
||||
*/
|
||||
protected $source_filepath = null;
|
||||
/**
|
||||
* @var string The target subdirectory in the cache
|
||||
*/
|
||||
protected $cache_subdirectory = null;
|
||||
|
||||
/**
|
||||
* @var string The absolute URL of the cached file (in the web space)
|
||||
*/
|
||||
protected $file_url = null;
|
||||
|
||||
/**
|
||||
* @var string The absolute path of the cached file
|
||||
*/
|
||||
protected $cache_filepath = null;
|
||||
|
||||
public function getFileUrl()
|
||||
{
|
||||
return $this->file_url;
|
||||
}
|
||||
|
||||
public function setFileUrl($file_url)
|
||||
{
|
||||
$this->file_url = $file_url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCacheFilepath()
|
||||
{
|
||||
return $this->cache_filepath;
|
||||
}
|
||||
|
||||
public function setCacheFilepath($cache_filepath)
|
||||
{
|
||||
$this->cache_filepath = $cache_filepath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSourceFilepath()
|
||||
{
|
||||
return $this->source_filepath;
|
||||
}
|
||||
|
||||
public function setSourceFilepath($source_filepath)
|
||||
{
|
||||
$this->source_filepath = $source_filepath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCacheSubdirectory()
|
||||
{
|
||||
return $this->cache_subdirectory;
|
||||
}
|
||||
|
||||
public function setCacheSubdirectory($cache_subdirectory)
|
||||
{
|
||||
$this->cache_subdirectory = $cache_subdirectory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
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 parent::getCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cart
|
||||
*/
|
||||
public function getOriginalCart()
|
||||
{
|
||||
return $this->originalCart;
|
||||
}
|
||||
}
|
||||
188
core/lib/Thelia/Core/Event/Cart/CartEvent.php
Normal file
188
core/lib/Thelia/Core/Event/Cart/CartEvent.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?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;
|
||||
use Thelia\Model\CartItem;
|
||||
|
||||
class CartEvent extends ActionEvent
|
||||
{
|
||||
protected $cart;
|
||||
protected $quantity;
|
||||
protected $append;
|
||||
protected $newness;
|
||||
protected $productSaleElementsId;
|
||||
protected $product;
|
||||
protected $cartItem;
|
||||
|
||||
protected $cartItemId;
|
||||
|
||||
public function __construct(Cart $cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $append
|
||||
* @return CartEvent
|
||||
*/
|
||||
public function setAppend($append)
|
||||
{
|
||||
$this->append = $append;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getAppend()
|
||||
{
|
||||
return $this->append;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartItem $cartItem
|
||||
* @return CartEvent
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public function getCartItem()
|
||||
{
|
||||
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
|
||||
*/
|
||||
public function setNewness($newness)
|
||||
{
|
||||
$this->newness = $newness;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getNewness()
|
||||
{
|
||||
return $this->newness;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $product the product ID
|
||||
* @return CartEvent
|
||||
*/
|
||||
public function setProduct($product)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the product ID
|
||||
*/
|
||||
public function getProduct()
|
||||
{
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $productSaleElementsId
|
||||
* @return CartEvent
|
||||
*/
|
||||
public function setProductSaleElementsId($productSaleElementsId)
|
||||
{
|
||||
$this->productSaleElementsId = $productSaleElementsId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getProductSaleElementsId()
|
||||
{
|
||||
return $this->productSaleElementsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $quantity
|
||||
* @return CartEvent
|
||||
*/
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Cart
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->cart;
|
||||
}
|
||||
}
|
||||
56
core/lib/Thelia/Core/Event/Cart/CartItemDuplicationItem.php
Normal file
56
core/lib/Thelia/Core/Event/Cart/CartItemDuplicationItem.php
Normal file
@@ -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\Event\Cart;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\CartItem;
|
||||
|
||||
/**
|
||||
* Class CartItemDuplicationItem
|
||||
* @package Thelia\Core\Event\Cart
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CartItemDuplicationItem extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\CartItem
|
||||
*/
|
||||
protected $oldItem;
|
||||
|
||||
/**
|
||||
* @var \Thelia\Model\CartItem
|
||||
*/
|
||||
protected $newItem;
|
||||
|
||||
public function __construct(CartItem $newItem, CartItem $oldItem)
|
||||
{
|
||||
$this->newItem = $newItem;
|
||||
$this->oldItem = $oldItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\CartItem
|
||||
*/
|
||||
public function getNewItem()
|
||||
{
|
||||
return $this->newItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\CartItem
|
||||
*/
|
||||
public function getOldItem()
|
||||
{
|
||||
return $this->oldItem;
|
||||
}
|
||||
}
|
||||
31
core/lib/Thelia/Core/Event/Cart/CartItemEvent.php
Normal file
31
core/lib/Thelia/Core/Event/Cart/CartItemEvent.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\CartItem;
|
||||
|
||||
class CartItemEvent extends ActionEvent
|
||||
{
|
||||
protected $cartItem;
|
||||
|
||||
public function __construct(CartItem $cartItem)
|
||||
{
|
||||
$this->cartItem = $cartItem;
|
||||
}
|
||||
|
||||
public function getCartItem()
|
||||
{
|
||||
return $this->cartItem;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Category;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryAddContentEvent extends CategoryEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Category $category, $content_id)
|
||||
{
|
||||
parent::__construct($category);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
@@ -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\Category;
|
||||
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CategoryAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(CategoryAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasCategoryAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getCategoryAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setCategoryAssociatedContent(CategoryAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Category/CategoryCreateEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Category/CategoryCreateEvent.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\Category;
|
||||
|
||||
class CategoryCreateEvent extends CategoryEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Category;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryDeleteContentEvent extends CategoryEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Category $category, $content_id)
|
||||
{
|
||||
parent::__construct($category);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
39
core/lib/Thelia/Core/Event/Category/CategoryDeleteEvent.php
Normal file
39
core/lib/Thelia/Core/Event/Category/CategoryDeleteEvent.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\Category;
|
||||
|
||||
class CategoryDeleteEvent extends CategoryEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $categoryId;
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
*/
|
||||
public function __construct($categoryId)
|
||||
{
|
||||
$this->categoryId = $categoryId;
|
||||
}
|
||||
|
||||
public function getCategoryId()
|
||||
{
|
||||
return $this->categoryId;
|
||||
}
|
||||
|
||||
public function setCategoryId($categoryId)
|
||||
{
|
||||
$this->categoryId = $categoryId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Core/Event/Category/CategoryEvent.php
Normal file
43
core/lib/Thelia/Core/Event/Category/CategoryEvent.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\Category;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CategoryEvent extends ActionEvent
|
||||
{
|
||||
public $category = null;
|
||||
|
||||
public function __construct(Category $category = null)
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
public function hasCategory()
|
||||
{
|
||||
return ! is_null($this->category);
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory(Category $category)
|
||||
{
|
||||
$this->category = $category;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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\Category;
|
||||
|
||||
class CategoryToggleVisibilityEvent extends CategoryEvent
|
||||
{
|
||||
}
|
||||
113
core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php
Normal file
113
core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?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\Category;
|
||||
|
||||
class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $category_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $parent;
|
||||
|
||||
protected $defaultTemplateId;
|
||||
|
||||
/**
|
||||
* @param int $category_id
|
||||
*/
|
||||
public function __construct($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
}
|
||||
|
||||
public function getCategoryId()
|
||||
{
|
||||
return $this->category_id;
|
||||
}
|
||||
|
||||
public function setCategoryId($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultTemplateId()
|
||||
{
|
||||
return $this->defaultTemplateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $defaultTemplateId
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultTemplateId($defaultTemplateId)
|
||||
{
|
||||
$this->defaultTemplateId = $defaultTemplateId;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
96
core/lib/Thelia/Core/Event/Config/ConfigCreateEvent.php
Normal file
96
core/lib/Thelia/Core/Event/Config/ConfigCreateEvent.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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\Config;
|
||||
|
||||
class ConfigCreateEvent extends ConfigEvent
|
||||
{
|
||||
protected $event_name;
|
||||
protected $value;
|
||||
protected $locale;
|
||||
protected $title;
|
||||
protected $hidden;
|
||||
protected $secured;
|
||||
|
||||
// Use event_name to prevent conflict with Event::name property.
|
||||
public function getEventName()
|
||||
{
|
||||
return $this->event_name;
|
||||
}
|
||||
|
||||
public function setEventName($event_name)
|
||||
{
|
||||
$this->event_name = $event_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHidden()
|
||||
{
|
||||
return $this->hidden;
|
||||
}
|
||||
|
||||
public function setHidden($hidden)
|
||||
{
|
||||
$this->hidden = $hidden;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSecured()
|
||||
{
|
||||
return $this->secured;
|
||||
}
|
||||
|
||||
public function setSecured($secured)
|
||||
{
|
||||
$this->secured = $secured;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
39
core/lib/Thelia/Core/Event/Config/ConfigDeleteEvent.php
Normal file
39
core/lib/Thelia/Core/Event/Config/ConfigDeleteEvent.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\Config;
|
||||
|
||||
class ConfigDeleteEvent extends ConfigEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $config_id;
|
||||
|
||||
/**
|
||||
* @param int $config_id
|
||||
*/
|
||||
public function __construct($config_id)
|
||||
{
|
||||
$this->setConfigId($config_id);
|
||||
}
|
||||
|
||||
public function getConfigId()
|
||||
{
|
||||
return $this->config_id;
|
||||
}
|
||||
|
||||
public function setConfigId($config_id)
|
||||
{
|
||||
$this->config_id = $config_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Core/Event/Config/ConfigEvent.php
Normal file
43
core/lib/Thelia/Core/Event/Config/ConfigEvent.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\Config;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Config;
|
||||
|
||||
class ConfigEvent extends ActionEvent
|
||||
{
|
||||
protected $config = null;
|
||||
|
||||
public function __construct(Config $config = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function hasConfig()
|
||||
{
|
||||
return ! is_null($this->config);
|
||||
}
|
||||
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
public function setConfig($config)
|
||||
{
|
||||
$this->config = $config;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
79
core/lib/Thelia/Core/Event/Config/ConfigUpdateEvent.php
Normal file
79
core/lib/Thelia/Core/Event/Config/ConfigUpdateEvent.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\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);
|
||||
}
|
||||
|
||||
public function getConfigId()
|
||||
{
|
||||
return $this->config_id;
|
||||
}
|
||||
|
||||
public function setConfigId($config_id)
|
||||
{
|
||||
$this->config_id = $config_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php
Normal file
51
core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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\Content;
|
||||
|
||||
use Thelia\Model\Content;
|
||||
|
||||
/**
|
||||
* Class ContentAddFolderEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentAddFolderEvent extends ContentEvent
|
||||
{
|
||||
/**
|
||||
* @var int folder id
|
||||
*/
|
||||
protected $folderId;
|
||||
|
||||
public function __construct(Content $content, $folderId)
|
||||
{
|
||||
$this->folderId = $folderId;
|
||||
|
||||
parent::__construct($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $folderId
|
||||
*/
|
||||
public function setFolderId($folderId)
|
||||
{
|
||||
$this->folderId = $folderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
return $this->folderId;
|
||||
}
|
||||
}
|
||||
106
core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php
Normal file
106
core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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\Content;
|
||||
|
||||
/**
|
||||
* Class ContentCreateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentCreateEvent extends ContentEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $default_folder;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $default_folder
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultFolder($default_folder)
|
||||
{
|
||||
$this->default_folder = $default_folder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultFolder()
|
||||
{
|
||||
return $this->default_folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
65
core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php
Normal file
65
core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\Content;
|
||||
|
||||
/**
|
||||
* Class ContentDeleteEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $content_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setDefaultFolderId($folderid)
|
||||
{
|
||||
$this->folder_id = $folderid;
|
||||
}
|
||||
|
||||
public function getDefaultFolderId()
|
||||
{
|
||||
return $this->folder_id;
|
||||
}
|
||||
}
|
||||
62
core/lib/Thelia/Core/Event/Content/ContentEvent.php
Normal file
62
core/lib/Thelia/Core/Event/Content/ContentEvent.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Content;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Content;
|
||||
|
||||
/**
|
||||
* Class ContentEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Content
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
public function __construct(Content $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Content $content
|
||||
*/
|
||||
public function setContent(Content $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Content
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if content exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasContent()
|
||||
{
|
||||
return null !== $this->content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Content;
|
||||
|
||||
/**
|
||||
* Class ContentRemoveFolderEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentRemoveFolderEvent extends ContentAddFolderEvent
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Content;
|
||||
|
||||
/**
|
||||
* Class ContentToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContentToggleVisibilityEvent extends ContentEvent
|
||||
{
|
||||
}
|
||||
116
core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php
Normal file
116
core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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\Content;
|
||||
|
||||
/**
|
||||
* Class ContentUpdateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $content_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
}
|
||||
176
core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php
Normal file
176
core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?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 CountryCreateEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryCreateEvent extends CountryEvent
|
||||
{
|
||||
protected $locale;
|
||||
protected $title;
|
||||
protected $isocode;
|
||||
protected $isoAlpha2;
|
||||
protected $isoAlpha3;
|
||||
|
||||
/** @var bool is visible */
|
||||
protected $visible;
|
||||
/** @var bool has states */
|
||||
protected $hasStates;
|
||||
|
||||
protected $area;
|
||||
|
||||
/**
|
||||
* @param mixed $isoAlpha2
|
||||
*/
|
||||
public function setIsoAlpha2($isoAlpha2)
|
||||
{
|
||||
$this->isoAlpha2 = $isoAlpha2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIsoAlpha2()
|
||||
{
|
||||
return $this->isoAlpha2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $isoAlpha3
|
||||
*/
|
||||
public function setIsoAlpha3($isoAlpha3)
|
||||
{
|
||||
$this->isoAlpha3 = $isoAlpha3;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIsoAlpha3()
|
||||
{
|
||||
return $this->isoAlpha3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $isocode
|
||||
*/
|
||||
public function setIsocode($isocode)
|
||||
{
|
||||
$this->isocode = $isocode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIsocode()
|
||||
{
|
||||
return $this->isocode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $area
|
||||
*/
|
||||
public function setArea($area)
|
||||
{
|
||||
$this->area = $area;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getArea()
|
||||
{
|
||||
return $this->area;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
50
core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php
Normal file
50
core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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 CountryDeleteEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryDeleteEvent extends CountryEvent
|
||||
{
|
||||
/**
|
||||
* @var int country id
|
||||
*/
|
||||
protected $country_id;
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
*/
|
||||
public function __construct($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
}
|
||||
60
core/lib/Thelia/Core/Event/Country/CountryEvent.php
Normal file
60
core/lib/Thelia/Core/Event/Country/CountryEvent.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\Country;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Country;
|
||||
|
||||
/**
|
||||
* Class CountryEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CountryEvent extends ActionEvent
|
||||
{
|
||||
/*
|
||||
* @var \Thelia\Model\Country
|
||||
*/
|
||||
protected $country;
|
||||
|
||||
public function __construct(Country $country = null)
|
||||
{
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $country
|
||||
*/
|
||||
public function setCountry(Country $country)
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|\Thelia\Model\Country
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCountry()
|
||||
{
|
||||
return null !== $this->country;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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 CountryToggleDefaultEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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
|
||||
{
|
||||
|
||||
}
|
||||
159
core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php
Normal file
159
core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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 CountryUpdateEvent
|
||||
* @package Thelia\Core\Event\Country
|
||||
* @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 string $chapo
|
||||
* @return $this
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $postscriptum
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
145
core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php
Normal file
145
core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Occurring when a Coupon is consumed
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CouponConsumeEvent extends ActionEvent
|
||||
{
|
||||
/** @var string Coupon code */
|
||||
protected $code = null;
|
||||
|
||||
/** @var float Total discount given by this coupon */
|
||||
protected $discount = 0;
|
||||
|
||||
/** @var bool If Coupon is valid or if Customer meets coupon conditions */
|
||||
protected $isValid = null;
|
||||
|
||||
/** @var bool true if coupon offers free shipping */
|
||||
protected $freeShipping = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $code Coupon code
|
||||
* @param float $discount Total discount given by this coupon
|
||||
* @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)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->discount = $discount;
|
||||
$this->discount = $discount;
|
||||
|
||||
$this->freeShipping = $freeShipping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $freeShipping
|
||||
*/
|
||||
public function setFreeShipping($freeShipping)
|
||||
{
|
||||
$this->freeShipping = $freeShipping;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFreeShipping()
|
||||
{
|
||||
return $this->freeShipping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon code
|
||||
*
|
||||
* @param string $code Coupon code
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total discount given by this coupon
|
||||
*
|
||||
* @param float $discount Total discount given by this coupon
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDiscount($discount)
|
||||
{
|
||||
$this->discount = $discount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total discount given by this coupon
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount()
|
||||
{
|
||||
return $this->discount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if Coupon is valid or if Customer meets coupon conditions
|
||||
*
|
||||
* @param boolean $isValid if Coupon is valid or
|
||||
* if Customer meets coupon conditions
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsValid($isValid)
|
||||
{
|
||||
$this->isValid = $isValid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if Coupon is valid or if Customer meets coupon conditions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsValid()
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
}
|
||||
462
core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php
Normal file
462
core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php
Normal file
@@ -0,0 +1,462 @@
|
||||
<?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\Condition\ConditionCollection;
|
||||
use Thelia\Model\Coupon;
|
||||
|
||||
/**
|
||||
* Occurring when a Coupon is created or updated
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
/** @var ConditionCollection Array of ConditionInterface */
|
||||
protected $conditions = null;
|
||||
|
||||
/** @var string Coupon code (ex: XMAS) */
|
||||
protected $code = null;
|
||||
|
||||
/** @var string Coupon title (ex: Coupon for XMAS) */
|
||||
protected $title = null;
|
||||
|
||||
/** @var string Coupon short description */
|
||||
protected $shortDescription = null;
|
||||
|
||||
/** @var string Coupon description */
|
||||
protected $description = null;
|
||||
|
||||
/** @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;
|
||||
|
||||
/** @var bool if Coupon is cumulative */
|
||||
protected $isCumulative = false;
|
||||
|
||||
/** @var bool if Coupon is removing postage */
|
||||
protected $isRemovingPostage = false;
|
||||
|
||||
/** @var float Amount that will be removed from the Checkout (Coupon Effect) */
|
||||
protected $amount = 0;
|
||||
|
||||
/** @var array Effects ready to be serialized */
|
||||
protected $effects = array();
|
||||
|
||||
/** @var int Max time a Coupon can be used (-1 = unlimited) */
|
||||
protected $maxUsage = -1;
|
||||
|
||||
/** @var bool if Coupon is available for Products already on special offers */
|
||||
protected $isAvailableOnSpecialOffers = false;
|
||||
|
||||
/** @var Coupon Coupon model */
|
||||
protected $couponModel = null;
|
||||
|
||||
/** @var string Coupon Service id */
|
||||
protected $serviceId;
|
||||
|
||||
/** @var string Language code ISO (ex: fr_FR) */
|
||||
protected $locale = null;
|
||||
|
||||
/** @var array ID of Countries to which shipping is free */
|
||||
protected $freeShippingForCountries;
|
||||
|
||||
/** @var array ID of Shipping modules for which shipping is free */
|
||||
protected $freeShippingForMethods;
|
||||
|
||||
/** @var true if usage count is per customer only */
|
||||
protected $perCustomerUsageCount;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $code Coupon Code
|
||||
* @param string $serviceId Coupon Service id
|
||||
* @param string $title Coupon title
|
||||
* @param array $effects Coupon effects ready to be serialized
|
||||
* 'amount' key is mandatory and reflects
|
||||
* the amount deduced from the cart
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param bool $isEnabled Enable/Disable
|
||||
* @param \DateTime $expirationDate Coupon expiration date
|
||||
* @param boolean $isAvailableOnSpecialOffers Is available on special offers
|
||||
* @param boolean $isCumulative Is cumulative
|
||||
* @param boolean $isRemovingPostage Is removing Postage
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
* @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,
|
||||
\DateTime $startDate = null
|
||||
) {
|
||||
$this->code = $code;
|
||||
$this->description = $description;
|
||||
$this->expirationDate = $expirationDate;
|
||||
$this->isAvailableOnSpecialOffers = $isAvailableOnSpecialOffers;
|
||||
$this->isCumulative = $isCumulative;
|
||||
$this->isEnabled = $isEnabled;
|
||||
$this->isRemovingPostage = $isRemovingPostage;
|
||||
$this->maxUsage = $maxUsage;
|
||||
$this->shortDescription = $shortDescription;
|
||||
$this->title = $title;
|
||||
$this->serviceId = $serviceId;
|
||||
$this->locale = $locale;
|
||||
$this->setEffects($effects);
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
$this->startDate = $startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param true $perCustomerUsageCount
|
||||
*/
|
||||
public function setPerCustomerUsageCount($perCustomerUsageCount)
|
||||
{
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*/
|
||||
public function getPerCustomerUsageCount()
|
||||
{
|
||||
return $this->perCustomerUsageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $freeShippingForCountries
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreeShippingForCountries($freeShippingForCountries)
|
||||
{
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeShippingForCountries()
|
||||
{
|
||||
return $this->freeShippingForCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $freeShippingForMethods
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreeShippingForMethods($freeShippingForMethods)
|
||||
{
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeShippingForMethods()
|
||||
{
|
||||
return $this->freeShippingForMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon code (ex: XMAS)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon title (ex: Coupon for XMAS)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon short description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShortDescription()
|
||||
{
|
||||
return $this->shortDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* If Coupon is cumulative or prevent any accumulation
|
||||
* If is cumulative you can sum Coupon effects
|
||||
* If not cancel all other Coupon and take the last given
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCumulative()
|
||||
{
|
||||
return $this->isCumulative;
|
||||
}
|
||||
|
||||
/**
|
||||
* If Coupon is removing Checkout Postage
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isRemovingPostage()
|
||||
{
|
||||
return $this->isRemovingPostage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return effects generated by the coupon
|
||||
*
|
||||
* @return float Amount removed from the Total Checkout
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getExpirationDate()
|
||||
{
|
||||
return clone $this->expirationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* If Coupon is available on special offers
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAvailableOnSpecialOffers()
|
||||
{
|
||||
return $this->isAvailableOnSpecialOffers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if Coupon is enabled or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return $this->isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how many time the Coupon can be used again
|
||||
* Ex : -1 unlimited
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxUsage()
|
||||
{
|
||||
return $this->maxUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon Service id (Type)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceId()
|
||||
{
|
||||
return $this->serviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coupon Language code ISO (ex: fr_FR)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set effects ready to be serialized
|
||||
*
|
||||
* @param array $effects Effect ready to be serialized
|
||||
* Needs at least the key 'amount'
|
||||
* with the amount removed from the cart
|
||||
* @throws \Thelia\Model\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function setEffects(array $effects)
|
||||
{
|
||||
// Amount is now optionnal.
|
||||
$this->amount = isset($effects['amount']) ? $effects['amount'] : 0;
|
||||
|
||||
$this->effects = $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get effects ready to be serialized
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEffects()
|
||||
{
|
||||
return $this->effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the Coupon will be available on special offers or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsAvailableOnSpecialOffers()
|
||||
{
|
||||
return $this->isAvailableOnSpecialOffers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the Coupon effect cancel other Coupon effects
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsCumulative()
|
||||
{
|
||||
return $this->isCumulative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if Coupon is enabled or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsEnabled()
|
||||
{
|
||||
return $this->isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsRemovingPostage()
|
||||
{
|
||||
return $this->isRemovingPostage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon Model
|
||||
*
|
||||
* @param Coupon $couponModel Coupon Model
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCouponModel(Coupon $couponModel)
|
||||
{
|
||||
$this->couponModel = $couponModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon Model
|
||||
*
|
||||
* @return \Thelia\Model\Coupon
|
||||
*/
|
||||
public function getCouponModel()
|
||||
{
|
||||
return $this->couponModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Conditions
|
||||
*
|
||||
* @return null|ConditionCollection Array of ConditionInterface
|
||||
*/
|
||||
public function getConditions()
|
||||
{
|
||||
return $this->conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Conditions
|
||||
*
|
||||
* @param ConditionCollection $conditions Array of ConditionInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConditions(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $conditions;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/Currency/CurrencyChangeEvent.php
Normal file
52
core/lib/Thelia/Core/Event/Currency/CurrencyChangeEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\HttpFoundation\Request;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
/**
|
||||
* Class CurrencyChangeEvent
|
||||
* @package Thelia\Core\Event\Currency
|
||||
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
|
||||
*/
|
||||
class CurrencyChangeEvent extends CurrencyEvent
|
||||
{
|
||||
/** @var Request $request */
|
||||
protected $request;
|
||||
|
||||
public function __construct(Currency $currency = null, Request $request = null)
|
||||
{
|
||||
parent::__construct($currency);
|
||||
$this->setRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
}
|
||||
96
core/lib/Thelia/Core/Event/Currency/CurrencyCreateEvent.php
Normal file
96
core/lib/Thelia/Core/Event/Currency/CurrencyCreateEvent.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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;
|
||||
|
||||
class CurrencyCreateEvent extends CurrencyEvent
|
||||
{
|
||||
protected $currency_name;
|
||||
protected $locale;
|
||||
protected $symbol;
|
||||
protected $format;
|
||||
protected $code;
|
||||
protected $rate;
|
||||
|
||||
// Use currency_name to prevent conflict with Event::name property.
|
||||
public function getCurrencyName()
|
||||
{
|
||||
return $this->currency_name;
|
||||
}
|
||||
|
||||
public function setCurrencyName($currency_name)
|
||||
{
|
||||
$this->currency_name = $currency_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSymbol()
|
||||
{
|
||||
return $this->symbol;
|
||||
}
|
||||
|
||||
public function setSymbol($symbol)
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
public function setFormat($format)
|
||||
{
|
||||
$this->format = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRate()
|
||||
{
|
||||
return $this->rate;
|
||||
}
|
||||
|
||||
public function setRate($rate)
|
||||
{
|
||||
$this->rate = $rate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
24
core/lib/Thelia/Core/Event/Currency/CurrencyDeleteEvent.php
Normal file
24
core/lib/Thelia/Core/Event/Currency/CurrencyDeleteEvent.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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;
|
||||
|
||||
class CurrencyDeleteEvent extends CurrencyEvent
|
||||
{
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*/
|
||||
public function __construct($currencyId)
|
||||
{
|
||||
$this->setCurrencyId($currencyId);
|
||||
}
|
||||
}
|
||||
74
core/lib/Thelia/Core/Event/Currency/CurrencyEvent.php
Normal file
74
core/lib/Thelia/Core/Event/Currency/CurrencyEvent.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Currency/CurrencyUpdateEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Currency/CurrencyUpdateEvent.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\Currency;
|
||||
|
||||
class CurrencyUpdateEvent extends CurrencyCreateEvent
|
||||
{
|
||||
/** @var int */
|
||||
protected $is_default;
|
||||
|
||||
|
||||
/** @var int */
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*/
|
||||
public function __construct($currencyId)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
<?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\Customer;
|
||||
|
||||
/**
|
||||
* Class CustomerCreateOrUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CustomerCreateOrUpdateEvent extends CustomerEvent
|
||||
{
|
||||
//base parameters for creating new customer
|
||||
protected $title;
|
||||
protected $firstname;
|
||||
protected $lastname;
|
||||
protected $address1;
|
||||
protected $address2;
|
||||
protected $address3;
|
||||
protected $phone;
|
||||
protected $cellphone;
|
||||
protected $zipcode;
|
||||
protected $city;
|
||||
protected $country;
|
||||
protected $state;
|
||||
protected $email;
|
||||
protected $password;
|
||||
protected $langId;
|
||||
protected $reseller;
|
||||
protected $sponsor;
|
||||
protected $discount;
|
||||
protected $company;
|
||||
protected $ref;
|
||||
protected $emailUpdateAllowed;
|
||||
protected $notifyCustomerOfAccountCreation;
|
||||
|
||||
/**
|
||||
* @param int $title the title customer id
|
||||
* @param string $firstname
|
||||
* @param string $lastname
|
||||
* @param string $address1
|
||||
* @param string $address2
|
||||
* @param string $address3
|
||||
* @param string $phone
|
||||
* @param string $cellphone
|
||||
* @param string $zipcode
|
||||
* @param string $city
|
||||
* @param int $country the country id
|
||||
* @param string $email
|
||||
* @param string $password plain password, don't put hash password, it will hashes again
|
||||
* @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,
|
||||
$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->langId = $langId;
|
||||
$this->lastname = $lastname;
|
||||
$this->password = $password;
|
||||
$this->phone = $phone;
|
||||
$this->cellphone = $cellphone;
|
||||
$this->title = $title;
|
||||
$this->zipcode = $zipcode;
|
||||
$this->city = $city;
|
||||
$this->reseller = $reseller;
|
||||
$this->sponsor = $sponsor;
|
||||
$this->discount = $discount;
|
||||
$this->company = $company;
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress1()
|
||||
{
|
||||
return $this->address1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress2()
|
||||
{
|
||||
return $this->address2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress3()
|
||||
{
|
||||
return $this->address3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstname()
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLangId()
|
||||
{
|
||||
return $this->langId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastname()
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone()
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCellphone()
|
||||
{
|
||||
return $this->cellphone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getZipcode()
|
||||
{
|
||||
return $this->zipcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCity()
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount()
|
||||
{
|
||||
return $this->discount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getReseller()
|
||||
{
|
||||
return $this->reseller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSponsor()
|
||||
{
|
||||
return $this->sponsor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/Customer/CustomerEvent.php
Normal file
54
core/lib/Thelia/Core/Event/Customer/CustomerEvent.php
Normal file
@@ -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\Event\Customer;
|
||||
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CustomerEvent extends ActionEvent
|
||||
{
|
||||
/** @var null|Customer */
|
||||
public $customer = null;
|
||||
|
||||
public function __construct(Customer $customer = null)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Customer $customer
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomer(Customer $customer)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Customer
|
||||
*/
|
||||
public function getCustomer()
|
||||
{
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCustomer()
|
||||
{
|
||||
return $this->customer != null;
|
||||
}
|
||||
}
|
||||
18
core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php
Normal file
18
core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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\Customer;
|
||||
|
||||
class CustomerLoginEvent extends CustomerEvent
|
||||
{
|
||||
// Nothing specific :)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user