src/Twig/ShopExtension.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Services\Shop\InformationsShop;
  4. use App\Tools\Shop\StatusCommissionTool;
  5. use Twig\Extension\AbstractExtension;
  6. use Twig\TwigFunction;
  7. use Twig\TwigFilter;
  8. use App\Services\Core\Core;
  9. use App\Services\Shop\Carts;
  10. class ShopExtension extends AbstractExtension
  11. {
  12.     public function __construct(Core $coreServiceCarts $cartsInformationsShop $is)
  13.     {
  14.         $this->core $coreService;
  15.         $this->carts $carts;
  16.         $this->is $is;
  17.     }
  18.     /**
  19.      * {@inheritdoc}
  20.      */
  21.     public function getFunctions(): array
  22.     {
  23.         return [
  24.             new  TwigFunction('getShopKmToM', [$this'getShopKmToM']),
  25.             new  TwigFunction('getCartView', [$this'getCartView']),
  26.             new  TwigFunction('getCountProductsCart', [$this'getCountProductsCart']),
  27.             new  TwigFunction('getUserInformations', [$this'getUserInformations']),
  28.             new  TwigFunction('getOrderProductsView', [$this'getOrderProductsView']),
  29.             new  TwigFunction('getShopMenuFooter', [$this'getShopMenuFooter']),
  30.             new  TwigFunction('getShopMenuLinksFooter', [$this'getShopMenuLinksFooter']),
  31.             new  TwigFunction('getShopCaracteristiquesProduct', [$this'getShopCaracteristiquesProduct']),
  32.             new  TwigFunction('getShopsCity', [$this'getShopsCity']),
  33.             new  TwigFunction('getProductsShop', [$this'getProductsShop']),
  34.             new  TwigFunction('getHomepageSlug', [$this'getHomepageSlug']),
  35.             new  TwigFunction('getCartDeliveryShop', [$this'getCartDeliveryShop']),
  36.             new  TwigFunction('getShopMontantTTC', [$this'getShopMontantTTC']),
  37.             new  TwigFunction('getShopCommissionSafe', [$this'getShopCommissionSafe']),
  38.             new  TwigFunction('getShopCommissionStatus', [$this'getShopCommissionStatus']),
  39.             new  TwigFunction('getShopProductPhotoDefault', [$this'getShopProductPhotoDefault']),
  40.             new  TwigFunction('getShopShopPhotoDefault', [$this'getShopShopPhotoDefault']),
  41.         ];
  42.     }
  43.     public function getShopShopPhotoDefault($shopID)
  44.     {
  45.         return $this->is->getShopID($shopID);
  46.     }
  47.     public function getShopProductPhotoDefault($productID)
  48.     {
  49.         return $this->is->getProductPhotoDefault($productID);
  50.     }
  51.     public function getShopCommissionStatus($status)
  52.     {
  53.         return StatusCommissionTool::getStatus($status);
  54.     }
  55.     public function getShopCommissionSafe($chs)
  56.     {
  57.         return $this->carts->getCommissionSafe($chs);
  58.     }
  59.     public function getShopMontantTTC($montantHT,$tvaPourcent)
  60.     {
  61.         return $this->carts->getMontantTTC($montantHT,$tvaPourcent);
  62.     }
  63.     public function getCartDeliveryShop($cartID,$shopID)
  64.     {
  65.         return $this->carts->getCartDeliveryShop($cartID,$shopID);
  66.     }
  67.     public function getHomepageSlug($chain,$city)
  68.     {
  69.         return $this->carts->homepageSlug($chain,$city);
  70.     }
  71.     /**
  72.      * Liste des produits d'une boutique
  73.      */
  74.     public function getProductsShop($shop)
  75.     {
  76.         return $this->carts->productsShop($shop);
  77.     }
  78.     /**
  79.      * Liste des boutiques d'une ville
  80.      */
  81.     public function getShopsCity($city)
  82.     {
  83.         return $this->carts->shopsCity($city);
  84.     }
  85.     /**
  86.      * Caractéristiques d'un produit
  87.      */
  88.     public function getShopCaracteristiquesProduct($productId)
  89.     {
  90.         return $this->carts->getCaracteristiquesProduct($productId);
  91.     }
  92.     /**
  93.      * Liens d'un footer
  94.      */
  95.     public function getShopMenuLinksFooter($menuFooter)
  96.     {
  97.         return $this->carts->getMenuLinks($menuFooter);
  98.     }
  99.     /**
  100.      * Catégories d'un footer
  101.      */
  102.     public function getShopMenuFooter()
  103.     {
  104.         return $this->carts->getMenu();
  105.     }
  106.     /**
  107.      * Visionenr les produits d'une boutique
  108.      */
  109.     public function getOrderProductsView($shopID)
  110.     {
  111.         return $this->carts->productsView($shopID);
  112.     }
  113.     /**
  114.      * Distance d'une boutique à l'utilisateur en kilometre
  115.      */
  116.     public function getShopKmToM($kilometers)
  117.     {
  118.         return $this->carts->KilometerToMeter($kilometers);
  119.     }
  120.     /**
  121.      * Visioonner le panier d'un utilisateur
  122.      */
  123.     public function getCartView($identifiant,$user null)
  124.     {
  125.         return $this->carts->viewcart($identifiant,$user);
  126.     }
  127.     /**
  128.      * Nombre de produits par panier
  129.      */
  130.     public function getCountProductsCart($cartID)
  131.     {
  132.         return $this->carts->getCountProductsCart($cartID);
  133.     }
  134.     /**
  135.      * Informations d'un utilisateur
  136.      */
  137.     public function getUserInformations($userID)
  138.     {
  139.         return $this->carts->getUserInformations($userID);
  140.     }
  141. }