|
- <?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\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
- {
- 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->getUserContainer(),
- $this->getSubscriptionContainer(),
- $this->getProductContainer(),
- $this->getDistributionContainer(),
- $this->getProducerContainer(),
- $this->getOrderContainer(),
- ];
- }
-
- public function getUserContainer(): UserContainer
- {
- return new UserContainer();
- }
-
- public function getProducerContainer(): ProducerContainer
- {
- return new ProducerContainer();
- }
-
- public function getProducerPriceRangeContainer(): ProducerPriceRangeContainer
- {
- return new ProducerPriceRangeContainer();
- }
-
- public function getUserProducerContainer(): UserProducerContainer
- {
- return new UserProducerContainer();
- }
-
- public function getCreditHistoryContainer(): CreditHistoryContainer
- {
- return new CreditHistoryContainer();
- }
-
- public function getDocumentContainer(): DocumentContainer
- {
- return new DocumentContainer();
- }
-
- public function getUserGroupContainer(): UserGroupContainer
- {
- return new UserGroupContainer();
- }
-
- public function getUserUserGroupContainer(): UserUserGroupContainer
- {
- return new UserUserGroupContainer();
- }
-
- public function getDistributionContainer(): DistributionContainer
- {
- return new DistributionContainer();
- }
-
- public function getTaxRateContainer(): TaxRateContainer
- {
- return new TaxRateContainer();
- }
-
- public function getOrderContainer(): OrderContainer
- {
- return new OrderContainer();
- }
-
- public function getOrderSatusHistoryContainer(): OrderStatusHistoryContainer
- {
- return new OrderStatusHistoryContainer();
- }
-
- public function getPointSaleContainer(): PointSaleContainer
- {
- return new PointSaleContainer();
- }
-
- public function getProductOrderContainer(): ProductOrderContainer
- {
- return new ProductOrderContainer();
- }
-
- public function getProductContainer(): ProductContainer
- {
- return new ProductContainer();
- }
-
- public function getProductCategoryContainer(): ProductCategoryContainer
- {
- return new ProductCategoryContainer();
- }
-
- public function getProductPointSaleContainer(): ProductPointSaleContainer
- {
- return new ProductPointSaleContainer();
- }
-
- public function getProductPriceContainer(): ProductPriceContainer
- {
- return new ProductPriceContainer();
- }
-
- public function getSubscriptionContainer(): SubscriptionContainer
- {
- return new SubscriptionContainer();
- }
-
- public function getProductSubscriptionContainer(): ProductSubscriptionContainer
- {
- return new ProductSubscriptionContainer();
- }
-
- public function getPointSaleDistributionContainer(): PointSaleDistributionContainer
- {
- return new PointSaleDistributionContainer();
- }
-
- public function getProductDistributionContainer(): ProductDistributionContainer
- {
- return new ProductDistributionContainer();
- }
-
- /*
- * 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.');
- }
- }
|