|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
-
- namespace common\components;
-
- use domain\Producer\Producer\Producer;
- use yii\base\ErrorException;
-
- class BusinessLogic
- {
- protected ?Producer $producerContext = null;
-
- use BusinessLogicTrait;
-
- public function getModules()
- {
- return [
- $this->getSettingModule(),
- $this->getFeatureModule(),
- $this->getFeatureProducerModule(),
- $this->getUnitModule(),
- $this->getTaxRateModule(),
- $this->getUserUserGroupModule(),
- $this->getUserGroupModule(),
- $this->getPaymentModule(),
- $this->getProducerPriceRangeModule(),
- $this->getUserProducerModule(),
- $this->getUserPointSaleModule(),
- $this->getUserModule(),
- $this->getPointSaleDistributionModule(),
- $this->getProductDistributionModule(),
- $this->getProductCategoryModule(),
- $this->getProductPointSaleModule(),
- $this->getProductPriceModule(),
- $this->getProductSubscriptionModule(),
- $this->getTicketUserModule(),
- $this->getTicketMessageModule(),
- $this->getTicketModule(),
- $this->getPointSaleModule(),
- $this->getSharedPointSaleModule(),
- $this->getProductModule(),
- $this->getProductOrderModule(),
- $this->getOrderStatusModule(),
- $this->getOrderStatusHistoryModule(),
- $this->getQuotationModule(),
- $this->getInvoiceModule(),
- $this->getDeliveryNoteModule(),
- $this->getDocumentModule(),
- $this->getSubscriptionModule(),
- $this->getDistributionModule(),
- $this->getProducerModule(),
- $this->getOrderModule(),
- ];
- }
-
- public function getProducerContext(): ?Producer
- {
- return $this->producerContext;
- }
-
- public function setProducerContext(Producer $producer = null)
- {
- $this->producerContext = $producer;
-
- foreach($this->getModules() as $module) {
- foreach($module->getServices() as $serviceClass) {
- $instanceService = $serviceClass::getInstance();
- $instanceService->setProducerContext($producer);
- }
- }
- }
-
- /*
- * Hiérarchie des apps
- */
-
- public function getModuleLevelHierarchyByService($serviceClass): int
- {
- $modulesArray = $this->getModules();
- $entityFqcnService = $this->getEntityFqcnByService($serviceClass);
-
- foreach($modulesArray as $key => $module) {
- if($module->getEntityFqcn() == $entityFqcnService) {
- return $key;
- }
- }
- }
-
- public function getEntityFqcnByService(string $serviceClass): string
- {
- $modulesArray = $this->getModules();
-
- foreach($modulesArray as $module) {
- if(in_array($serviceClass, $module->getServices())) {
- return $module->getEntityFqcn();
- }
- }
-
- throw new ErrorException('Service '.$serviceClass.' introuvable dans les modules.');
- }
- }
|