Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

85 Zeilen
2.8KB

  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 getContainers()
  9. {
  10. return [
  11. $this->getTaxRateContainer(),
  12. $this->getUserUserGroupContainer(),
  13. $this->getUserGroupContainer(),
  14. $this->getCreditHistoryContainer(),
  15. $this->getProducerPriceRangeContainer(),
  16. $this->getUserProducerContainer(),
  17. $this->getUserPointSaleContainer(),
  18. $this->getUserContainer(),
  19. $this->getOrderSatusHistoryContainer(),
  20. $this->getPointSaleDistributionContainer(),
  21. $this->getProductDistributionContainer(),
  22. $this->getProductCategoryContainer(),
  23. $this->getProductPointSaleContainer(),
  24. $this->getProductOrderContainer(),
  25. $this->getProductPriceContainer(),
  26. $this->getProductSubscriptionContainer(),
  27. $this->getTicketUserContainer(),
  28. $this->getTicketMessageContainer(),
  29. $this->getTicketContainer(),
  30. $this->getQuotationContainer(),
  31. $this->getInvoiceContainer(),
  32. $this->getDeliveryNoteContainer(),
  33. $this->getDocumentContainer(),
  34. $this->getPointSaleContainer(),
  35. $this->getSubscriptionContainer(),
  36. $this->getProductContainer(),
  37. $this->getDistributionContainer(),
  38. $this->getProducerContainer(),
  39. $this->getOrderContainer(),
  40. ];
  41. }
  42. public function setProducerContext(Producer $producer)
  43. {
  44. foreach($this->getContainers() as $container) {
  45. foreach($container->getServices() as $serviceClass) {
  46. $instanceService = $serviceClass::getInstance();
  47. $instanceService->setProducerContext($producer);
  48. }
  49. }
  50. }
  51. /*
  52. * Hiérarchie des apps
  53. */
  54. public function getContainerLevelHierarchyByService($serviceClass): int
  55. {
  56. $containersArray = $this->getContainers();
  57. $entityFqcnService = $this->getEntityFqcnByService($serviceClass);
  58. foreach($containersArray as $key => $container) {
  59. if($container->getEntityFqcn() == $entityFqcnService) {
  60. return $key;
  61. }
  62. }
  63. }
  64. public function getEntityFqcnByService(string $serviceClass): string
  65. {
  66. $containersArray = $this->getContainers();
  67. foreach($containersArray as $container) {
  68. if(in_array($serviceClass, $container->getServices())) {
  69. return $container->getEntityFqcn();
  70. }
  71. }
  72. throw new ErrorException('Service '.$serviceClass.' introuvable dans les containers.');
  73. }
  74. }