} | } | ||||
} | } | ||||
public function getQuantityLabelInherited() | |||||
{ | |||||
$quantity = $this->getQuantityInherited() ; | |||||
$unit = $this->getUnitInherited() ; | |||||
return $quantity.$unit->getWordingShort() ; | |||||
} | |||||
public function getAvailableQuantityInherited() | public function getAvailableQuantityInherited() | ||||
{ | { | ||||
if($this->productFamily->getBehaviorCountStock()) { | if($this->productFamily->getBehaviorCountStock()) { |
return $this; | return $this; | ||||
} | } | ||||
public function hasProductsWithVariousWeight() | |||||
{ | |||||
if($this->getActiveProducts()) { | |||||
$arrayCountProducts = [] ; | |||||
$products = $this->getProducts() ; | |||||
foreach($products as $product) { | |||||
$titleProduct = $product->getTitleInherited() ; | |||||
if(!isset($arrayCountProducts[$titleProduct])) { | |||||
$arrayCountProducts[$titleProduct] = [] ; | |||||
} | |||||
if(!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) { | |||||
$arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited() ; | |||||
} | |||||
if(count($arrayCountProducts[$titleProduct]) > 1) { | |||||
return true ; | |||||
} | |||||
} | |||||
} | |||||
return false ; | |||||
} | |||||
public function getProductsGroupByTitle() | |||||
{ | |||||
$arrayProductsGroupByTitle = [] ; | |||||
$products = $this->getProducts() ; | |||||
foreach($products as $product) { | |||||
$titleProduct = $product->getTitleInherited() ; | |||||
if(!isset($arrayProductsGroupByTitle[$titleProduct])) { | |||||
$arrayProductsGroupByTitle[$titleProduct] = [] ; | |||||
} | |||||
$arrayProductsGroupByTitle[$titleProduct][] = $product ; | |||||
} | |||||
return $arrayProductsGroupByTitle ; | |||||
} | |||||
} | } |
namespace Lc\ShopBundle\Services; | namespace Lc\ShopBundle\Services; | ||||
use Cocur\Slugify\Slugify; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\PageInterface; | use Lc\ShopBundle\Context\PageInterface; | ||||
use Lc\ShopBundle\Context\TaxRateInterface; | use Lc\ShopBundle\Context\TaxRateInterface; | ||||
return $text; | return $text; | ||||
} | } | ||||
public function slugify($string) | |||||
{ | |||||
$slugify = new Slugify(); | |||||
return $slugify->slugify($string) ; | |||||
} | |||||
} | } |
use Lc\ShopBundle\Form\Frontend\NewsletterType; | use Lc\ShopBundle\Form\Frontend\NewsletterType; | ||||
use Lc\ShopBundle\Services\Utils; | use Lc\ShopBundle\Services\Utils; | ||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFilter; | |||||
use Twig\TwigFunction; | use Twig\TwigFunction; | ||||
class BridgeTwigExtension extends AbstractExtension | class BridgeTwigExtension extends AbstractExtension | ||||
public function getFilters() | public function getFilters() | ||||
{ | { | ||||
return [ | return [ | ||||
new TwigFilter('slugify', [$this, 'slugify']), | |||||
]; | ]; | ||||
} | } | ||||
{ | { | ||||
return $this->utils->getElementByDevAlias($devAlias, $class) ; | return $this->utils->getElementByDevAlias($devAlias, $class) ; | ||||
} | } | ||||
public function slugify($string) | |||||
{ | |||||
return $this->utils->slugify($string) ; | |||||
} | |||||
} | } |
use App\Repository\HubRepository; | use App\Repository\HubRepository; | ||||
use App\Services\GlobalParam; | use App\Services\GlobalParam; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\GlobalParamInterface; | |||||
use Lc\ShopBundle\Context\MerchantInterface; | |||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||||
use Lc\ShopBundle\Form\Frontend\NewsletterType; | use Lc\ShopBundle\Form\Frontend\NewsletterType; | ||||
use Lc\ShopBundle\Repository\ProductCategoryRepository; | use Lc\ShopBundle\Repository\ProductCategoryRepository; | ||||
use Symfony\Component\Form\FormFactoryInterface; | use Symfony\Component\Form\FormFactoryInterface; | ||||
protected $security ; | protected $security ; | ||||
protected $globalParam ; | protected $globalParam ; | ||||
protected $formFactory ; | protected $formFactory ; | ||||
protected $productCategoryRepository ; | |||||
protected $hubRepository ; | |||||
protected $requestStack ; | protected $requestStack ; | ||||
protected $productCategoryRepository ; | |||||
protected $merchantRepository ; | |||||
protected $productFamilyRepository ; | |||||
public function __construct(EntityManagerInterface $em, Security $security, ProductCategoryRepository $productCategoryRepository, | |||||
GlobalParam $globalParam, FormFactoryInterface $formFactory, HubRepository $hubRepository, RequestStack $requestStack) | |||||
public function __construct(EntityManagerInterface $em, Security $security, GlobalParamInterface $globalParam, | |||||
FormFactoryInterface $formFactory, RequestStack $requestStack) | |||||
{ | { | ||||
$this->em = $em ; | $this->em = $em ; | ||||
$this->security = $security ; | $this->security = $security ; | ||||
$this->productCategoryRepository = $productCategoryRepository ; | |||||
$this->hubRepository = $hubRepository ; | |||||
$this->globalParam = $globalParam ; | $this->globalParam = $globalParam ; | ||||
$this->formFactory = $formFactory ; | $this->formFactory = $formFactory ; | ||||
$this->requestStack = $requestStack ; | $this->requestStack = $requestStack ; | ||||
$this->productCategoryRepository = $this->em->getRepository($this->em->getClassMetadata(ProductCategoryInterface::class)->getName()) ; | |||||
$this->merchantRepository = $this->em->getRepository($this->em->getClassMetadata(MerchantInterface::class)->getName()) ; | |||||
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName()) ; | |||||
} | } | ||||
public function getFunctions() | public function getFunctions() | ||||
public function getMerchants() | public function getMerchants() | ||||
{ | { | ||||
return $this->hubRepository->findAll() ; | |||||
return $this->merchantRepository->findAll() ; | |||||
} | } | ||||
} | } |