You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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