|
- <?php
-
- namespace common\components;
-
- use common\logic\Config\TaxRate\TaxRateContainer;
- use common\logic\Distribution\Distribution\DistributionContainer;
- use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionContainer;
- use common\logic\Distribution\ProductDistribution\ProductDistributionContainer;
- use common\logic\Document\Document\DocumentContainer;
- use common\logic\Order\Order\OrderContainer;
- use common\logic\Order\Order\OrderManager;
- use common\logic\Order\OrderStatusHistory\OrderStatusHistoryContainer;
- use common\logic\Order\ProductOrder\ProductOrderContainer;
- use common\logic\PointSale\PointSale\PointSaleContainer;
- use common\logic\Producer\Producer\ProducerContainer;
- use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeContainer;
- use common\logic\Product\Product\ProductContainer;
- use common\logic\Product\ProductCategory\ProductCategoryContainer;
- use common\logic\Product\ProductPointSale\ProductPointSaleContainer;
- use common\logic\Product\ProductPrice\ProductPriceContainer;
- use common\logic\Subscription\ProductSubscription\ProductSubscriptionContainer;
- use common\logic\Subscription\Subscription\SubscriptionContainer;
- use common\logic\User\CreditHistory\CreditHistoryContainer;
- use common\logic\User\User\UserContainer;
- use common\logic\User\UserGroup\UserGroupContainer;
- use common\logic\User\UserProducer\UserProducerContainer;
- use common\logic\User\UserUserGroup\UserUserGroupContainer;
- use yii\base\ErrorException;
-
- class BusinessLogic
- {
- use BusinessLogicContainerTrait;
-
- public function getContainers()
- {
- return [
- $this->getTaxRateContainer(),
- $this->getUserUserGroupContainer(),
- $this->getUserGroupContainer(),
- $this->getDocumentContainer(),
- $this->getCreditHistoryContainer(),
- $this->getProducerPriceRangeContainer(),
- $this->getUserProducerContainer(),
- $this->getOrderSatusHistoryContainer(),
- $this->getPointSaleDistributionContainer(),
- $this->getProductDistributionContainer(),
- $this->getProductCategoryContainer(),
- $this->getProductPointSaleContainer(),
- $this->getProductOrderContainer(),
- $this->getProductPriceContainer(),
- $this->getProductSubscriptionContainer(),
- $this->getUserPointSaleContainer(),
- $this->getPointSaleContainer(),
- $this->getUserContainer(),
- $this->getSubscriptionContainer(),
- $this->getProductContainer(),
- $this->getDistributionContainer(),
- $this->getProducerContainer(),
- $this->getOrderContainer(),
- ];
- }
-
- /*
- * Hiérarchie des apps
- */
-
- public function getContainerLevelHierarchyByService($serviceClass): int
- {
- $containersArray = $this->getContainers();
- $entityFqcnService = $this->getEntityFqcnByService($serviceClass);
-
- foreach($containersArray as $key => $container) {
- if($container->getEntityFqcn() == $entityFqcnService) {
- return $key;
- }
- }
- }
-
- public function getEntityFqcnByService(string $serviceClass): string
- {
- $containersArray = $this->getContainers();
-
- foreach($containersArray as $container) {
- if(in_array($serviceClass, $container->getServices())) {
- return $container->getEntityFqcn();
- }
- }
-
- throw new ErrorException('Service '.$serviceClass.' introuvable dans le container.');
- }
- }
|