Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ControllerTrait.php 13KB

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