[11/06/2024] Les premières modifs + installation de quelques modules indispensables
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace OpenApi\Events;
|
||||
|
||||
use OpenApi\Model\Api\DeliveryModuleOption;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\Cart;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Model\State;
|
||||
|
||||
class DeliveryModuleOptionEvent extends ActionEvent
|
||||
{
|
||||
/** @var Module */
|
||||
protected $module;
|
||||
|
||||
/** @var Cart */
|
||||
protected $cart;
|
||||
|
||||
/** @var Address */
|
||||
protected $address;
|
||||
|
||||
/** @var Country */
|
||||
protected $country;
|
||||
|
||||
/** @var State */
|
||||
protected $state;
|
||||
|
||||
/** ------ */
|
||||
|
||||
/** @var array */
|
||||
protected $deliveryModuleOptions = [];
|
||||
|
||||
public function __construct(
|
||||
Module $module,
|
||||
Address $address,
|
||||
Cart $cart = null,
|
||||
Country $country = null,
|
||||
State $state = null
|
||||
) {
|
||||
$this->module = $module;
|
||||
$this->address = $address;
|
||||
$this->cart = $cart;
|
||||
$this->country = $country;
|
||||
$this->state = $state;
|
||||
|
||||
if (null === $this->module || null === $this->address) {
|
||||
throw new \Exception(Translator::getInstance()->trans('Not enough informations to retrieve module options'));
|
||||
}
|
||||
|
||||
if (!$module->isDeliveryModule()) {
|
||||
throw new \Exception(Translator::getInstance()->trans($module->getTitle().' is not a delivery module.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDeliveryModuleOptions()
|
||||
{
|
||||
return $this->deliveryModuleOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $deliveryModuleOptions
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function setDeliveryModuleOptions($deliveryModuleOptions)
|
||||
{
|
||||
$this->deliveryModuleOptions = $deliveryModuleOptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeliveryModuleOption $deliveryModuleOption
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function appendDeliveryModuleOptions($deliveryModuleOption)
|
||||
{
|
||||
$this->deliveryModuleOptions[] = $deliveryModuleOption;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Module
|
||||
*/
|
||||
public function getModule()
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Module $module
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function setModule($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cart
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function setCart($cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Address
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function setAddress($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Country
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Country $country
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function setCountry($country)
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return State
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param State $state
|
||||
*
|
||||
* @return DeliveryModuleOptionEvent
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
$this->state = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
101
domokits/local/modules/OpenApi/Events/ModelExtendDataEvent.php
Normal file
101
domokits/local/modules/OpenApi/Events/ModelExtendDataEvent.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace OpenApi\Events;
|
||||
|
||||
use OpenApi\Model\Api\BaseApiModel;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ModelExtendDataEvent extends ActionEvent
|
||||
{
|
||||
const ADD_EXTEND_DATA_PREFIX = 'add_extend_data_';
|
||||
|
||||
protected $data;
|
||||
|
||||
protected $locale;
|
||||
|
||||
/** @var BaseApiModel */
|
||||
protected $model;
|
||||
|
||||
protected $extendedData;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
*
|
||||
* @return ModelExtendDataEvent
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return ModelExtendDataEvent
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BaseApiModel
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BaseApiModel $model
|
||||
*
|
||||
* @return ModelExtendDataEvent
|
||||
*/
|
||||
public function setModel($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExtendData()
|
||||
{
|
||||
return $this->extendedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExtendDataKeyValue($key, $value)
|
||||
{
|
||||
$this->extendedData[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
123
domokits/local/modules/OpenApi/Events/ModelValidationEvent.php
Normal file
123
domokits/local/modules/OpenApi/Events/ModelValidationEvent.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace OpenApi\Events;
|
||||
|
||||
use OpenApi\Model\Api\BaseApiModel;
|
||||
use OpenApi\Model\Api\ModelFactory;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ModelValidationEvent extends ActionEvent
|
||||
{
|
||||
|
||||
const MODEL_VALIDATION_EVENT_PREFIX = 'open_api_model_validation_';
|
||||
|
||||
/** @var BaseApiModel $model */
|
||||
protected $model;
|
||||
|
||||
/** @var ModelFactory */
|
||||
protected $modelFactory;
|
||||
|
||||
protected $propertyPatchPrefix;
|
||||
|
||||
/** @var array $violations */
|
||||
protected $violations;
|
||||
|
||||
protected $groups;
|
||||
|
||||
/**
|
||||
* @param BaseApiModel $model
|
||||
* @param ModelFactory $modelFactory
|
||||
* @param $propertyPatchPrefix
|
||||
* @param array $violations
|
||||
*/
|
||||
public function __construct(BaseApiModel $model, ModelFactory $modelFactory, $groups, string $propertyPatchPrefix = "", array $violations = [])
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->modelFactory = $modelFactory;
|
||||
$this->propertyPatchPrefix = $propertyPatchPrefix;
|
||||
$this->violations = $violations;
|
||||
$this->groups = $groups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return BaseApiModel
|
||||
*/
|
||||
public function getModel(): BaseApiModel
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BaseApiModel $model
|
||||
*/
|
||||
public function setModel(BaseApiModel $model): void
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getViolations()
|
||||
{
|
||||
return $this->violations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $violations
|
||||
*/
|
||||
public function setViolations($violations): void
|
||||
{
|
||||
$this->violations = $violations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ModelFactory
|
||||
*/
|
||||
public function getModelFactory(): ModelFactory
|
||||
{
|
||||
return $this->modelFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ModelFactory $modelFactory
|
||||
*/
|
||||
public function setModelFactory(ModelFactory $modelFactory): void
|
||||
{
|
||||
$this->modelFactory = $modelFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPropertyPatchPrefix(): string
|
||||
{
|
||||
return $this->propertyPatchPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $propertyPatchPrefix
|
||||
*/
|
||||
public function setPropertyPatchPrefix(string $propertyPatchPrefix): void
|
||||
{
|
||||
$this->propertyPatchPrefix = $propertyPatchPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getGroups()
|
||||
{
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $groups
|
||||
*/
|
||||
public function setGroups($groups): void
|
||||
{
|
||||
$this->groups = $groups;
|
||||
}
|
||||
|
||||
}
|
||||
8
domokits/local/modules/OpenApi/Events/OpenApiEvents.php
Normal file
8
domokits/local/modules/OpenApi/Events/OpenApiEvents.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace OpenApi\Events;
|
||||
|
||||
class OpenApiEvents
|
||||
{
|
||||
const MODULE_DELIVERY_GET_OPTIONS = 'thelia.module.delivery.options';
|
||||
}
|
||||
Reference in New Issue
Block a user