|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?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.');
- }
- }
|