Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

297 lines
11KB

  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(string $settingName)
  88. {
  89. return $this->getSettingValue($this->getMerchantCurrent(), $settingName);
  90. }
  91. public function getSectionSettingCurrent(string $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->getVisitorContainer()->getResolver()->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(
  110. $this->getUserCurrent(),
  111. $this->getMerchantCurrent()
  112. );
  113. }
  114. public function getMerchantUserCurrent(): MerchantInterface
  115. {
  116. return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent());
  117. }
  118. public function getSectionCurrent(): SectionInterface
  119. {
  120. return $this->get(SectionResolver::class)->getCurrent();
  121. }
  122. public function getCartCurrent(): OrderShopInterface
  123. {
  124. return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
  125. $this->getSectionCurrent(),
  126. $this->getUserCurrent(),
  127. $this->getVisitorCurrent()
  128. );
  129. }
  130. public function getPriceSolver(): PriceSolver
  131. {
  132. return $this->get(PriceSolver::class);
  133. }
  134. public function getOrderShopContainer(): OrderShopContainer
  135. {
  136. return $this->get(OrderShopContainer::class);
  137. }
  138. public function getAddressContainer(): AddressContainer
  139. {
  140. return $this->get(AddressContainer::class);
  141. }
  142. public function getTaxRateContainer(): TaxRateContainer
  143. {
  144. return $this->get(TaxRateContainer::class);
  145. }
  146. public function getUnitContainer(): UnitContainer
  147. {
  148. return $this->get(UnitContainer::class);
  149. }
  150. public function getCreditHistoryContainer(): CreditHistoryContainer
  151. {
  152. return $this->get(CreditHistoryContainer::class);
  153. }
  154. public function getDocumentContainer(): DocumentContainer
  155. {
  156. return $this->get(DocumentContainer::class);
  157. }
  158. public function getMerchantContainer(): MerchantContainer
  159. {
  160. return $this->get(MerchantContainer::class);
  161. }
  162. public function getOrderPaymentContainer(): OrderPaymentContainer
  163. {
  164. return $this->get(OrderPaymentContainer::class);
  165. }
  166. public function getOrderProductContainer(): OrderProductContainer
  167. {
  168. return $this->get(OrderProductContainer::class);
  169. }
  170. public function getOrderProductReductionCatalogContainer(): OrderProductReductionCatalogContainer
  171. {
  172. return $this->get(OrderProductReductionCatalogContainer::class);
  173. }
  174. public function getOrderProductRefundContainer(): OrderProductRefundContainer
  175. {
  176. return $this->get(OrderProductRefundContainer::class);
  177. }
  178. public function getOrderReductionCartContainer(): OrderReductionCartContainer
  179. {
  180. return $this->get(OrderReductionCartContainer::class);
  181. }
  182. public function getOrderReductionCreditContainer(): OrderReductionCreditContainer
  183. {
  184. return $this->get(OrderReductionCreditContainer::class);
  185. }
  186. public function getOrderRefundContainer(): OrderRefundContainer
  187. {
  188. return $this->get(OrderRefundContainer::class);
  189. }
  190. public function getOrderStatusContainer(): OrderStatusContainer
  191. {
  192. return $this->get(OrderStatusContainer::class);
  193. }
  194. public function getOrderStatusHistoryContainer(): OrderStatusHistoryContainer
  195. {
  196. return $this->get(OrderStatusHistoryContainer::class);
  197. }
  198. public function getPointSaleContainer(): PointSaleContainer
  199. {
  200. return $this->get(PointSaleContainer::class);
  201. }
  202. public function getProductCategoryContainer(): ProductCategoryContainer
  203. {
  204. return $this->get(ProductCategoryContainer::class);
  205. }
  206. public function getProductContainer(): ProductContainer
  207. {
  208. return $this->get(ProductContainer::class);
  209. }
  210. public function getProductFamilyContainer(): ProductFamilyContainer
  211. {
  212. return $this->get(ProductFamilyContainer::class);
  213. }
  214. public function getReductionCartContainer(): ReductionCartContainer
  215. {
  216. return $this->get(ReductionCartContainer::class);
  217. }
  218. public function getReductionCatalogContainer(): ReductionCatalogContainer
  219. {
  220. return $this->get(ReductionCatalogContainer::class);
  221. }
  222. public function getReductionCreditContainer(): ReductionCreditContainer
  223. {
  224. return $this->get(ReductionCreditContainer::class);
  225. }
  226. public function getOpeningContainer(): OpeningContainer
  227. {
  228. return $this->get(OpeningContainer::class);
  229. }
  230. public function getSectionContainer(): SectionContainer
  231. {
  232. return $this->get(SectionContainer::class);
  233. }
  234. public function getMerchantSettingContainer(): MerchantSettingContainer
  235. {
  236. return $this->get(MerchantSettingContainer::class);
  237. }
  238. public function getSectionSettingContainer(): SectionSettingContainer
  239. {
  240. return $this->get(SectionSettingContainer::class);
  241. }
  242. public function getUserMerchantContainer(): UserMerchantContainer
  243. {
  244. return $this->get(UserMerchantContainer::class);
  245. }
  246. public function getUserPointSaleContainer(): UserPointSaleContainer
  247. {
  248. return $this->get(UserPointSaleContainer::class);
  249. }
  250. public function getVisitorContainer(): VisitorContainer
  251. {
  252. return $this->get(VisitorContainer::class);
  253. }
  254. }