Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

3 роки тому
3 роки тому
3 роки тому
3 роки тому
3 роки тому
3 роки тому
3 роки тому
3 роки тому
3 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller;
  3. use Lc\CaracoleBundle\Container\Address\AddressContainer;
  4. use Lc\CaracoleBundle\Container\Config\TaxRateContainer;
  5. use Lc\CaracoleBundle\Container\Config\UnitContainer;
  6. use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer;
  7. use Lc\CaracoleBundle\Container\File\DocumentContainer;
  8. use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
  9. use Lc\CaracoleBundle\Container\Order\OrderPaymentContainer;
  10. use Lc\CaracoleBundle\Container\Order\OrderProductContainer;
  11. use Lc\CaracoleBundle\Container\Order\OrderProductReductionCatalogContainer;
  12. use Lc\CaracoleBundle\Container\Order\OrderProductRefundContainer;
  13. use Lc\CaracoleBundle\Container\Order\OrderReductionCartContainer;
  14. use Lc\CaracoleBundle\Container\Order\OrderReductionCreditContainer;
  15. use Lc\CaracoleBundle\Container\Order\OrderRefundContainer;
  16. use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
  17. use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
  18. use Lc\CaracoleBundle\Container\Order\OrderStatusHistoryContainer;
  19. use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
  20. use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
  21. use Lc\CaracoleBundle\Container\Product\ProductContainer;
  22. use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
  23. use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
  24. use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer;
  25. use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
  26. use Lc\CaracoleBundle\Container\Section\OpeningContainer;
  27. use Lc\CaracoleBundle\Container\Section\SectionContainer;
  28. use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer;
  29. use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer;
  30. use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
  31. use Lc\CaracoleBundle\Container\User\UserPointSaleContainer;
  32. use Lc\CaracoleBundle\Container\User\VisitorContainer;
  33. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  34. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  35. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  36. use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
  37. use Lc\CaracoleBundle\Model\User\VisitorInterface;
  38. use Lc\CaracoleBundle\Resolver\MerchantResolver;
  39. use Lc\CaracoleBundle\Resolver\SectionResolver;
  40. use Lc\CaracoleBundle\Resolver\VisitorResolver;
  41. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  42. use Lc\SovBundle\Model\User\UserInterface;
  43. use Symfony\Component\Security\Core\Security;
  44. trait ControllerTrait
  45. {
  46. public static function getSubscribedServices()
  47. {
  48. return array_merge(
  49. parent::getSubscribedServices(),
  50. [
  51. PriceSolver::class => PriceSolver::class,
  52. MerchantResolver::class => MerchantResolver::class,
  53. SectionResolver::class=> SectionResolver::class,
  54. OrderShopContainer::class => OrderShopContainer::class,
  55. AddressContainer::class => AddressContainer::class,
  56. TaxRateContainer::class => TaxRateContainer::class,
  57. UnitContainer::class => UnitContainer::class,
  58. CreditHistoryContainer::class => CreditHistoryContainer::class,
  59. DocumentContainer::class => DocumentContainer::class,
  60. MerchantContainer::class => MerchantContainer::class,
  61. OrderPaymentContainer::class => OrderPaymentContainer::class,
  62. OrderProductContainer::class => OrderProductContainer::class,
  63. OrderProductReductionCatalogContainer::class => OrderProductReductionCatalogContainer::class,
  64. OrderProductRefundContainer::class => OrderProductRefundContainer::class,
  65. OrderReductionCartContainer::class => OrderReductionCartContainer::class,
  66. OrderReductionCreditContainer::class => OrderReductionCreditContainer::class,
  67. OrderRefundContainer::class => OrderRefundContainer::class,
  68. OrderStatusContainer::class => OrderStatusContainer::class,
  69. OrderStatusHistoryContainer::class => OrderStatusHistoryContainer::class,
  70. PointSaleContainer::class => PointSaleContainer::class,
  71. ProductCategoryContainer::class => ProductCategoryContainer::class,
  72. ProductContainer::class => ProductContainer::class,
  73. ProductFamilyContainer::class => ProductFamilyContainer::class,
  74. ReductionCartContainer::class => ReductionCartContainer::class,
  75. ReductionCatalogContainer::class => ReductionCatalogContainer::class,
  76. ReductionCreditContainer::class => ReductionCreditContainer::class,
  77. OpeningContainer::class => OpeningContainer::class,
  78. SectionContainer::class => SectionContainer::class,
  79. MerchantSettingContainer::class => MerchantSettingContainer::class,
  80. SectionSettingContainer::class => SectionSettingContainer::class,
  81. UserMerchantContainer::class => UserMerchantContainer::class,
  82. UserPointSaleContainer::class => UserPointSaleContainer::class,
  83. VisitorContainer::class => VisitorContainer::class,
  84. ]
  85. );
  86. }
  87. public function getMerchantSettingCurrent($settingName)
  88. {
  89. return $this->getSettingValue($this->getMerchantCurrent(), $settingName);
  90. }
  91. public function getSectionSettingCurrent($settingName)
  92. {
  93. return $this->getSettingValue($this->getCurrentSection(), $settingName);
  94. }
  95. public function getUserCurrent(): ?UserInterface
  96. {
  97. return $this->get(Security::class)->getUser();
  98. }
  99. public function getVisitorCurrent(): VisitorInterface
  100. {
  101. return $this->get(VisitorResolver::class)->getCurrent();
  102. }
  103. public function getMerchantCurrent(): MerchantInterface
  104. {
  105. return $this->get(MerchantResolver::class)->getCurrent();
  106. }
  107. public function getUserMerchantCurrent(): UserMerchantInterface
  108. {
  109. return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist($this->getUserCurrent(), $this->getMerchantCurrent());
  110. }
  111. public function getMerchantUserCurrent(): MerchantInterface
  112. {
  113. return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent());
  114. }
  115. public function getSectionCurrent(): SectionInterface
  116. {
  117. return $this->get(SectionResolver::class)->getCurrent();
  118. }
  119. public function getCartCurrent(): OrderShopInterface
  120. {
  121. return $this->getOrderShopContainer()->getStore()
  122. ->setSection($this->getSectionCurrent())
  123. ->getOneCartCurrent();
  124. }
  125. public function getPriceSolver(): PriceSolver
  126. {
  127. return $this->get(PriceSolver::class);
  128. }
  129. public function getOrderShopContainer(): OrderShopContainer
  130. {
  131. return $this->get(OrderShopContainer::class);
  132. }
  133. public function getAddressContainer(): AddressContainer
  134. {
  135. return $this->get(AddressContainer::class);
  136. }
  137. public function getTaxRateContainer(): TaxRateContainer
  138. {
  139. return $this->get(TaxRateContainer::class);
  140. }
  141. public function getUnitContainer(): UnitContainer
  142. {
  143. return $this->get(UnitContainer::class);
  144. }
  145. public function getCreditHistoryContainer(): CreditHistoryContainer
  146. {
  147. return $this->get(CreditHistoryContainer::class);
  148. }
  149. public function getDocumentContainer(): DocumentContainer
  150. {
  151. return $this->get(DocumentContainer::class);
  152. }
  153. public function getMerchantContainer(): MerchantContainer
  154. {
  155. return $this->get(MerchantContainer::class);
  156. }
  157. public function getOrderPaymentContainer(): OrderPaymentContainer
  158. {
  159. return $this->get(OrderPaymentContainer::class);
  160. }
  161. public function getOrderProductContainer(): OrderProductContainer
  162. {
  163. return $this->get(OrderProductContainer::class);
  164. }
  165. public function getOrderProductReductionCatalogContainer(): OrderProductReductionCatalogContainer
  166. {
  167. return $this->get(OrderProductReductionCatalogContainer::class);
  168. }
  169. public function getOrderProductRefundContainer(): OrderProductRefundContainer
  170. {
  171. return $this->get(OrderProductRefundContainer::class);
  172. }
  173. public function getOrderReductionCartContainer(): OrderReductionCartContainer
  174. {
  175. return $this->get(OrderReductionCartContainer::class);
  176. }
  177. public function getOrderReductionCreditContainer(): OrderReductionCreditContainer
  178. {
  179. return $this->get(OrderReductionCreditContainer::class);
  180. }
  181. public function getOrderRefundContainer(): OrderRefundContainer
  182. {
  183. return $this->get(OrderRefundContainer::class);
  184. }
  185. public function getOrderStatusContainer(): OrderStatusContainer
  186. {
  187. return $this->get(OrderStatusContainer::class);
  188. }
  189. public function getOrderStatusHistoryContainer(): OrderStatusHistoryContainer
  190. {
  191. return $this->get(OrderStatusHistoryContainer::class);
  192. }
  193. public function getPointSaleContainer(): PointSaleContainer
  194. {
  195. return $this->get(PointSaleContainer::class);
  196. }
  197. public function getProductCategoryContainer(): ProductCategoryContainer
  198. {
  199. return $this->get(ProductCategoryContainer::class);
  200. }
  201. public function getProductContainer(): ProductContainer
  202. {
  203. return $this->get(ProductContainer::class);
  204. }
  205. public function getProductFamilyContainer(): ProductFamilyContainer
  206. {
  207. return $this->get(ProductFamilyContainer::class);
  208. }
  209. public function getReductionCartContainer(): ReductionCartContainer
  210. {
  211. return $this->get(ReductionCartContainer::class);
  212. }
  213. public function getReductionCatalogContainer(): ReductionCatalogContainer
  214. {
  215. return $this->get(ReductionCatalogContainer::class);
  216. }
  217. public function getReductionCreditContainer(): ReductionCreditContainer
  218. {
  219. return $this->get(ReductionCreditContainer::class);
  220. }
  221. public function getOpeningContainer(): OpeningContainer
  222. {
  223. return $this->get(OpeningContainer::class);
  224. }
  225. public function getSectionContainer(): SectionContainer
  226. {
  227. return $this->get(SectionContainer::class);
  228. }
  229. public function getMerchantSettingContainer(): MerchantSettingContainer
  230. {
  231. return $this->get(MerchantSettingContainer::class);
  232. }
  233. public function getSectionSettingContainer(): SectionSettingContainer
  234. {
  235. return $this->get(SectionSettingContainer::class);
  236. }
  237. public function getUserMerchantContainer(): UserMerchantContainer
  238. {
  239. return $this->get(UserMerchantContainer::class);
  240. }
  241. public function getUserPointSaleContainer(): UserPointSaleContainer
  242. {
  243. return $this->get(UserPointSaleContainer::class);
  244. }
  245. public function getVisitorContainer(): VisitorContainer
  246. {
  247. return $this->get(VisitorContainer::class);
  248. }
  249. }