您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

97 行
2.9KB

  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->getPointSaleDistributionModule(),
  25. $this->getProductDistributionModule(),
  26. $this->getProductCategoryModule(),
  27. $this->getProductPointSaleModule(),
  28. $this->getProductPriceModule(),
  29. $this->getProductSubscriptionModule(),
  30. $this->getTicketUserModule(),
  31. $this->getTicketMessageModule(),
  32. $this->getTicketModule(),
  33. $this->getPointSaleModule(),
  34. $this->getProductModule(),
  35. $this->getProductOrderModule(),
  36. $this->getQuotationModule(),
  37. $this->getInvoiceModule(),
  38. $this->getDeliveryNoteModule(),
  39. $this->getDocumentModule(),
  40. $this->getSubscriptionModule(),
  41. $this->getDistributionModule(),
  42. $this->getProducerModule(),
  43. $this->getOrderModule(),
  44. ];
  45. }
  46. public function getProducerContext(): ?Producer
  47. {
  48. return $this->producerContext;
  49. }
  50. public function setProducerContext(Producer $producer = null)
  51. {
  52. $this->producerContext = $producer;
  53. foreach($this->getModules() as $module) {
  54. foreach($module->getServices() as $serviceClass) {
  55. $instanceService = $serviceClass::getInstance();
  56. $instanceService->setProducerContext($producer);
  57. }
  58. }
  59. }
  60. /*
  61. * Hiérarchie des apps
  62. */
  63. public function getModuleLevelHierarchyByService($serviceClass): int
  64. {
  65. $modulesArray = $this->getModules();
  66. $entityFqcnService = $this->getEntityFqcnByService($serviceClass);
  67. foreach($modulesArray as $key => $module) {
  68. if($module->getEntityFqcn() == $entityFqcnService) {
  69. return $key;
  70. }
  71. }
  72. }
  73. public function getEntityFqcnByService(string $serviceClass): string
  74. {
  75. $modulesArray = $this->getModules();
  76. foreach($modulesArray as $module) {
  77. if(in_array($serviceClass, $module->getServices())) {
  78. return $module->getEntityFqcn();
  79. }
  80. }
  81. throw new ErrorException('Service '.$serviceClass.' introuvable dans les modules.');
  82. }
  83. }