Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

96 lines
3.2KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Twig;
  3. use Lc\CaracoleBundle\Repository\Config\TaxRateStore;
  4. use Lc\CaracoleBundle\Repository\Config\UnitStore;
  5. use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
  6. use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
  7. use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
  8. use Lc\CaracoleBundle\Repository\Section\SectionRepository;
  9. use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
  10. use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery;
  11. use Lc\CaracoleBundle\Repository\Section\SectionStore;
  12. use Lc\CaracoleBundle\Resolver\MerchantResolver;
  13. use Lc\CaracoleBundle\Resolver\SectionResolver;
  14. use Lc\ShopBundle\Context\UnitInterface;
  15. use Twig\Extension\AbstractExtension;
  16. use Twig\TwigFunction;
  17. class StoreTwigExtension extends AbstractExtension
  18. {
  19. protected MerchantStore $merchantStore;
  20. protected SectionStore $sectionStore;
  21. protected ReminderStore $reminderStore;
  22. protected MerchantResolver $merchantResolver;
  23. protected SectionResolver $sectionResolver;
  24. protected UnitStore $unitStore;
  25. protected TaxRateStore $taxRateStore;
  26. public function __construct(
  27. MerchantResolver $merchantResolver,
  28. SectionResolver $sectionResolver,
  29. MerchantStore $merchantStore,
  30. SectionStore $sectionStore,
  31. ReminderStore $reminderStore,
  32. UnitStore $unitStore,
  33. TaxRateStore $taxRateStore
  34. ) {
  35. $this->merchantResolver = $merchantResolver;
  36. $this->sectionResolver = $sectionResolver;
  37. $this->merchantStore = $merchantStore;
  38. $this->sectionStore = $sectionStore;
  39. $this->reminderStore = $reminderStore;
  40. $this->unitStore = $unitStore;
  41. $this->taxRateStore = $taxRateStore;
  42. }
  43. public function getFunctions()
  44. {
  45. return array(
  46. new TwigFunction('carac_sections', [$this, 'getSections']),
  47. new TwigFunction('carac_merchants', [$this, 'getMerchants']),
  48. new TwigFunction('carac_reminders', [$this, 'getReminders']),
  49. new TwigFunction('carac_units', [$this, 'getUnits']),
  50. new TwigFunction('carac_tax_rates', [$this, 'getTaxRates']),
  51. new TwigFunction('carac_reduction_cart_codes', [$this, 'getTaxRates']),
  52. );
  53. }
  54. public function getSections()
  55. {
  56. return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline();
  57. }
  58. public function getMerchants()
  59. {
  60. return $this->merchantStore->getOnline();
  61. }
  62. public function getReminders($params = [])
  63. {
  64. return $this->reminderStore
  65. ->setMerchant($this->merchantResolver->getCurrent())
  66. ->setSection($this->sectionResolver->getCurrent())
  67. ->get($params);
  68. }
  69. public function getUnits()
  70. {
  71. return $this->unitStore->getAsArray();
  72. }
  73. public function getTaxRates()
  74. {
  75. return $this->taxRateStore->setMerchant($this->merchantResolver->getCurrent())->getAsArray();
  76. }
  77. public function getReductionCartCodes()
  78. {
  79. //TODO mettre à jour une fois les repo fait
  80. return array();
  81. }
  82. }