Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

102 rindas
3.1KB

  1. <?php
  2. namespace common\components;
  3. use domain\Producer\Producer\Producer;
  4. use yii\base\ErrorException;
  5. class BusinessLogic
  6. {
  7. protected ?Producer $producerContext = null;
  8. use BusinessLogicTrait;
  9. public function getModules()
  10. {
  11. return [
  12. $this->getSettingModule(),
  13. $this->getFeatureModule(),
  14. $this->getFeatureProducerModule(),
  15. $this->getUnitModule(),
  16. $this->getTaxRateModule(),
  17. $this->getUserUserGroupModule(),
  18. $this->getUserGroupModule(),
  19. $this->getPaymentModule(),
  20. $this->getProducerPriceRangeModule(),
  21. $this->getUserProducerModule(),
  22. $this->getUserPointSaleModule(),
  23. $this->getUserModule(),
  24. $this->getUserMessageModule(),
  25. $this->getPointSaleDistributionModule(),
  26. $this->getAccessoryModule(),
  27. $this->getProductDistributionModule(),
  28. $this->getProductCategoryModule(),
  29. $this->getProductPointSaleModule(),
  30. $this->getProductPriceModule(),
  31. $this->getProductSubscriptionModule(),
  32. $this->getTicketUserModule(),
  33. $this->getTicketMessageModule(),
  34. $this->getTicketModule(),
  35. $this->getPointSaleModule(),
  36. $this->getSharedPointSaleModule(),
  37. $this->getProductModule(),
  38. $this->getProductOrderModule(),
  39. $this->getOrderStatusModule(),
  40. $this->getOrderStatusHistoryModule(),
  41. $this->getQuotationModule(),
  42. $this->getInvoiceModule(),
  43. $this->getDeliveryNoteModule(),
  44. $this->getDocumentModule(),
  45. $this->getSubscriptionModule(),
  46. $this->getDistributionModule(),
  47. $this->getProducerModule(),
  48. $this->getOrderModule(),
  49. ];
  50. }
  51. public function getProducerContext(): ?Producer
  52. {
  53. return $this->producerContext;
  54. }
  55. public function setProducerContext(Producer $producer = null)
  56. {
  57. $this->producerContext = $producer;
  58. foreach($this->getModules() as $module) {
  59. foreach($module->getServices() as $serviceClass) {
  60. $instanceService = $serviceClass::getInstance();
  61. $instanceService->setProducerContext($producer);
  62. }
  63. }
  64. }
  65. /*
  66. * Hiérarchie des apps
  67. */
  68. public function getModuleLevelHierarchyByService($serviceClass): int
  69. {
  70. $modulesArray = $this->getModules();
  71. $entityFqcnService = $this->getEntityFqcnByService($serviceClass);
  72. foreach($modulesArray as $key => $module) {
  73. if($module->getEntityFqcn() == $entityFqcnService) {
  74. return $key;
  75. }
  76. }
  77. }
  78. public function getEntityFqcnByService(string $serviceClass): string
  79. {
  80. $modulesArray = $this->getModules();
  81. foreach($modulesArray as $module) {
  82. if(in_array($serviceClass, $module->getServices())) {
  83. return $module->getEntityFqcn();
  84. }
  85. }
  86. throw new ErrorException('Service '.$serviceClass.' introuvable dans les modules.');
  87. }
  88. }