No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

BusinessLogic.php 2.6KB

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