TaxRateUtils.php 1.2KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Lc\ShopBundle\Services ;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\ShopBundle\Context\MerchantUtilsInterface;
  5. use Lc\ShopBundle\Context\TaxRateInterface;
  6. class TaxRateUtils
  7. {
  8. protected $em ;
  9. protected $merchantUtils ;
  10. public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils)
  11. {
  12. $this->em = $em ;
  13. $this->merchantUtils = $merchantUtils ;
  14. }
  15. public function getTaxRatesList()
  16. {
  17. $taxRatesList =array();
  18. $taxRates = $this->em->getRepository(TaxRateInterface::class)->findAll();
  19. foreach ($taxRates as $taxRate){
  20. $taxRatesList[$taxRate->getId()]['title'] = $taxRate->getTitle();
  21. $taxRatesList[$taxRate->getId()]['value'] = $taxRate->getValue();
  22. }
  23. $taxRatesList['default']['title'] = $this->merchantUtils->getMerchantCurrentTaxRate()->getTitle();
  24. $taxRatesList['default']['value'] = $this->merchantUtils->getMerchantCurrentTaxRate()->getValue();
  25. return $taxRatesList;
  26. }
  27. }