選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

BusinessLogic.php 3.3KB

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