<?php | |||||
namespace Lc\CaracoleBundle\Container\Product; | |||||
use Lc\CaracoleBundle\Factory\Product\QualityLabelFactory; | |||||
use Lc\CaracoleBundle\Repository\Product\QualityLabelRepositoryQuery; | |||||
use Lc\CaracoleBundle\Repository\Product\QualityLabelStore; | |||||
class QualityLabelContainer | |||||
{ | |||||
protected QualityLabelFactory $factory; | |||||
protected QualityLabelRepositoryQuery $repositoryQuery; | |||||
protected QualityLabelStore $store; | |||||
public function __construct( | |||||
QualityLabelFactory $factory, | |||||
QualityLabelRepositoryQuery $repositoryQuery, | |||||
QualityLabelStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): QualityLabelFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): QualityLabelRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): QualityLabelStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
use Lc\CaracoleBundle\Container\Product\ProductContainer; | use Lc\CaracoleBundle\Container\Product\ProductContainer; | ||||
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | ||||
use Lc\CaracoleBundle\Container\Product\ProductFamilySectionPropertyContainer; | use Lc\CaracoleBundle\Container\Product\ProductFamilySectionPropertyContainer; | ||||
use Lc\CaracoleBundle\Container\Product\QualityLabelContainer; | |||||
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | ||||
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; | use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; | ||||
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | ||||
VisitorContainer::class => VisitorContainer::class, | VisitorContainer::class => VisitorContainer::class, | ||||
DistributionContainer::class => DistributionContainer::class, | DistributionContainer::class => DistributionContainer::class, | ||||
ProductFamilySectionPropertyContainer::class => ProductFamilySectionPropertyContainer::class, | ProductFamilySectionPropertyContainer::class => ProductFamilySectionPropertyContainer::class, | ||||
QualityLabelContainer::class => QualityLabelContainer::class, | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
{ | { | ||||
return $this->get(VisitorContainer::class); | return $this->get(VisitorContainer::class); | ||||
} | } | ||||
public function getQualityLabelContainer(): QualityLabelContainer | |||||
{ | |||||
return $this->get(QualityLabelContainer::class); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Controller\Product; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Field\ImageManagerField; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
abstract class QualityLabelAdminController extends AbstractAdminController | |||||
{ | |||||
public function getRepositoryQuery() :RepositoryQueryInterface | |||||
{ | |||||
return $this->getQualityLabelContainer()->getRepositoryQuery(); | |||||
} | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getQualityLabelContainer()->getFactory()->create(); | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('title'), | |||||
ImageManagerField::new('image'), | |||||
TextField::new('devAlias'), | |||||
]; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Factory\Product; | |||||
use App\Entity\Product\QualityLabel; | |||||
use Lc\CaracoleBundle\Model\Product\QualityLabelInterface; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
class QualityLabelFactory extends AbstractFactory | |||||
{ | |||||
public function create(): QualityLabelInterface | |||||
{ | |||||
$qualityLabel = new QualityLabel(); | |||||
$qualityLabel->setStatus(1); | |||||
return $qualityLabel; | |||||
} | |||||
} |
use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface; | use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | |||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | ||||
use Lc\SovBundle\Model\File\FileInterface; | use Lc\SovBundle\Model\File\FileInterface; | ||||
const BEHAVIOR_PRICE_BY_PIECE = 'by-piece'; | const BEHAVIOR_PRICE_BY_PIECE = 'by-piece'; | ||||
const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit'; | const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit'; | ||||
const PROPERTY_ORGANIC_LABEL_AB = 'ab'; | |||||
const PROPERTY_ORGANIC_LABEL_NP = 'nature-progres'; | |||||
const PROPERTY_ORGANIC_LABEL_HVE = 'hve'; | |||||
const PROPERTY_ORGANIC_LABEL_TVVR = 'tvvr'; | |||||
const QUALITY_LABEL_AB = 'ab'; | |||||
const QUALITY_LABEL_NP = 'nature-progres'; | |||||
const QUALITY_LABEL_HVE = 'hve'; | |||||
const QUALITY_LABEL_TVVR = 'tvvr'; | |||||
const QUALITY_LABEL_AOC = 'aoc'; | |||||
const QUALITY_LABEL_AOP = 'aop'; | |||||
const QUALITY_LABEL_IGP = 'igp'; | |||||
static $organicLabels = [ | |||||
self::QUALITY_LABEL_AB, | |||||
self::QUALITY_LABEL_NP, | |||||
self::QUALITY_LABEL_HVE, | |||||
self::QUALITY_LABEL_TVVR | |||||
]; | |||||
static $geographicLabels = [ | |||||
self::QUALITY_LABEL_AOC, | |||||
self::QUALITY_LABEL_AOP, | |||||
self::QUALITY_LABEL_IGP, | |||||
]; | |||||
const TYPE_EXPIRATION_DATE_DLC = 'dlc'; | const TYPE_EXPIRATION_DATE_DLC = 'dlc'; | ||||
const TYPE_EXPIRATION_DATE_DDM = 'ddm'; | const TYPE_EXPIRATION_DATE_DDM = 'ddm'; | ||||
*/ | */ | ||||
protected $image; | protected $image; | ||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\QualityLabelInterface", fetch="EAGER") | |||||
*/ | |||||
protected $qualityLabels; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->productCategories = new ArrayCollection(); | $this->productCategories = new ArrayCollection(); | ||||
$this->products = new ArrayCollection(); | $this->products = new ArrayCollection(); | ||||
$this->qualityLabels = new ArrayCollection(); | |||||
} | } | ||||
public function __toString() | public function __toString() | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return Collection|QualityLabelInterface[] | |||||
*/ | |||||
public function getQualityLabels(): Collection | |||||
{ | |||||
return $this->qualityLabels; | |||||
} | |||||
public function addQualityLabel(QualityLabelInterface $qualityLabel): self | |||||
{ | |||||
if (!$this->qualityLabels->contains($qualityLabel)) { | |||||
$this->qualityLabels[] = $qualityLabel; | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeQualityLabel(QualityLabelInterface $qualityLabel): self | |||||
{ | |||||
$this->qualityLabels->removeElement($qualityLabel); | |||||
return $this; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Product; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\SortableInterface; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class QualityLabel extends AbstractFullEntity implements EntityInterface, SortableInterface, | |||||
QualityLabelInterface | |||||
{ | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $image; | |||||
public function __toString() | |||||
{ | |||||
return $this->getTitle(); | |||||
} | |||||
public function getImage(): ?FileInterface | |||||
{ | |||||
return $this->image; | |||||
} | |||||
public function setImage(?FileInterface $image): self | |||||
{ | |||||
$this->image = $image; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Model\Product; | |||||
interface QualityLabelInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Repository\Product; | |||||
use App\Entity\Product\QualityLabel; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
class QualityLabelRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, QualityLabel::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Repository\Product; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class QualityLabelRepositoryQuery extends AbstractRepositoryQuery | |||||
{ | |||||
public function __construct(QualityLabelRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
public function orderByDefault(): AbstractRepositoryQuery | |||||
{ | |||||
return $this->orderBy('position', 'ASC'); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Repository\Product; | |||||
use Lc\SovBundle\Repository\AbstractStore; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
class QualityLabelStore extends AbstractStore | |||||
{ | |||||
protected QualityLabelRepositoryQuery $query; | |||||
public function __construct(QualityLabelRepositoryQuery $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface | |||||
{ | |||||
return $query; | |||||
} | |||||
public function filtersDefault($query):RepositoryQueryInterface | |||||
{ | |||||
return $query; | |||||
} | |||||
public function relationsDefault($query):RepositoryQueryInterface | |||||
{ | |||||
return $query; | |||||
} | |||||
} |
fields: | fields: | ||||
priceWithTax: Prix de vente | priceWithTax: Prix de vente | ||||
sales: Historique des ventes | sales: Historique des ventes | ||||
propertyQualityLabelActive: Marquer le produit comme labellisé | |||||
QualityLabel: | |||||
label: Label de qualité | |||||
label_plurial: Labels de qualité | |||||
form: | form: | ||||
user_merchant: | user_merchant: |
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||||
class ProductFamilySolver | class ProductFamilySolver | ||||
{ | { | ||||
]; | ]; | ||||
} | } | ||||
public function getPropertyOrganicLabelChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_AB, | |||||
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_NP, | |||||
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_HVE, | |||||
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_TVVR, | |||||
]; | |||||
} | |||||
public function getTypeExpirationDateChoices(): array | public function getTypeExpirationDateChoices(): array | ||||
{ | { | ||||
return [ | return [ | ||||
return $productFamily->getPrice(); | return $productFamily->getPrice(); | ||||
} | } | ||||
public function getOrganicLabel(ProductFamilyInterface $productFamily) | |||||
{ | |||||
return $this->getQualityLabelByArray($productFamily, ProductFamilyModel::$organicLabels); | |||||
} | |||||
public function getGeographicLabel(ProductFamilyInterface $productFamily) | |||||
{ | |||||
return $this->getQualityLabelByArray($productFamily, ProductFamilyModel::$geographicLabels); | |||||
} | |||||
public function getQualityLabelByArray(ProductFamilyInterface $productFamily, array $labelArray) | |||||
{ | |||||
$qualityLabelArray = $productFamily->getQualityLabels(); | |||||
foreach($qualityLabelArray as $qualityLabel) { | |||||
if(in_array($qualityLabel->getDevAlias(), $labelArray)) { | |||||
return $qualityLabel; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
public function hasOrganicLabel(ProductFamilyInterface $productFamily) | |||||
{ | |||||
return $this->hasQualityLabelByArray($productFamily, ProductFamilyModel::$organicLabels); | |||||
} | |||||
public function hasGeographicLabel(ProductFamilyInterface $productFamily) | |||||
{ | |||||
return $this->hasQualityLabelByArray($productFamily, ProductFamilyModel::$geographicLabels); | |||||
} | |||||
public function hasQualityLabelByArray(ProductFamilyInterface $productFamily, array $labelArray) | |||||
{ | |||||
$qualityLabelArray = $productFamily->getQualityLabels(); | |||||
foreach($qualityLabelArray as $qualityLabel) { | |||||
if(in_array($qualityLabel->getDevAlias(), $labelArray)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} | } | ||||