<?php
namespace App\Twig;
use App\Services\Shop\InformationsShop;
use App\Tools\Shop\StatusCommissionTool;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
use App\Services\Core\Core;
use App\Services\Shop\Carts;
class ShopExtension extends AbstractExtension
{
public function __construct(Core $coreService, Carts $carts, InformationsShop $is)
{
$this->core = $coreService;
$this->carts = $carts;
$this->is = $is;
}
/**
* {@inheritdoc}
*/
public function getFunctions(): array
{
return [
new TwigFunction('getShopKmToM', [$this, 'getShopKmToM']),
new TwigFunction('getCartView', [$this, 'getCartView']),
new TwigFunction('getCountProductsCart', [$this, 'getCountProductsCart']),
new TwigFunction('getUserInformations', [$this, 'getUserInformations']),
new TwigFunction('getOrderProductsView', [$this, 'getOrderProductsView']),
new TwigFunction('getShopMenuFooter', [$this, 'getShopMenuFooter']),
new TwigFunction('getShopMenuLinksFooter', [$this, 'getShopMenuLinksFooter']),
new TwigFunction('getShopCaracteristiquesProduct', [$this, 'getShopCaracteristiquesProduct']),
new TwigFunction('getShopsCity', [$this, 'getShopsCity']),
new TwigFunction('getProductsShop', [$this, 'getProductsShop']),
new TwigFunction('getHomepageSlug', [$this, 'getHomepageSlug']),
new TwigFunction('getCartDeliveryShop', [$this, 'getCartDeliveryShop']),
new TwigFunction('getShopMontantTTC', [$this, 'getShopMontantTTC']),
new TwigFunction('getShopCommissionSafe', [$this, 'getShopCommissionSafe']),
new TwigFunction('getShopCommissionStatus', [$this, 'getShopCommissionStatus']),
new TwigFunction('getShopProductPhotoDefault', [$this, 'getShopProductPhotoDefault']),
new TwigFunction('getShopShopPhotoDefault', [$this, 'getShopShopPhotoDefault']),
];
}
public function getShopShopPhotoDefault($shopID)
{
return $this->is->getShopID($shopID);
}
public function getShopProductPhotoDefault($productID)
{
return $this->is->getProductPhotoDefault($productID);
}
public function getShopCommissionStatus($status)
{
return StatusCommissionTool::getStatus($status);
}
public function getShopCommissionSafe($chs)
{
return $this->carts->getCommissionSafe($chs);
}
public function getShopMontantTTC($montantHT,$tvaPourcent)
{
return $this->carts->getMontantTTC($montantHT,$tvaPourcent);
}
public function getCartDeliveryShop($cartID,$shopID)
{
return $this->carts->getCartDeliveryShop($cartID,$shopID);
}
public function getHomepageSlug($chain,$city)
{
return $this->carts->homepageSlug($chain,$city);
}
/**
* Liste des produits d'une boutique
*/
public function getProductsShop($shop)
{
return $this->carts->productsShop($shop);
}
/**
* Liste des boutiques d'une ville
*/
public function getShopsCity($city)
{
return $this->carts->shopsCity($city);
}
/**
* Caractéristiques d'un produit
*/
public function getShopCaracteristiquesProduct($productId)
{
return $this->carts->getCaracteristiquesProduct($productId);
}
/**
* Liens d'un footer
*/
public function getShopMenuLinksFooter($menuFooter)
{
return $this->carts->getMenuLinks($menuFooter);
}
/**
* Catégories d'un footer
*/
public function getShopMenuFooter()
{
return $this->carts->getMenu();
}
/**
* Visionenr les produits d'une boutique
*/
public function getOrderProductsView($shopID)
{
return $this->carts->productsView($shopID);
}
/**
* Distance d'une boutique à l'utilisateur en kilometre
*/
public function getShopKmToM($kilometers)
{
return $this->carts->KilometerToMeter($kilometers);
}
/**
* Visioonner le panier d'un utilisateur
*/
public function getCartView($identifiant,$user = null)
{
return $this->carts->viewcart($identifiant,$user);
}
/**
* Nombre de produits par panier
*/
public function getCountProductsCart($cartID)
{
return $this->carts->getCountProductsCart($cartID);
}
/**
* Informations d'un utilisateur
*/
public function getUserInformations($userID)
{
return $this->carts->getUserInformations($userID);
}
}