From 7f948bdc215ca4fd5dae0a8c773357eefd700c91 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 24 Jul 2024 08:51:21 +0200 Subject: [PATCH] OP-440: Remove unnecessary traits and move methods to existing traits --- src/Entity/Block.php | 4 --- src/Entity/Trait/BlockProductAwareTrait.php | 31 ------------------- src/Entity/Trait/BlockTaxonAwareTrait.php | 21 ------------- src/Entity/Trait/ProductsAwareTrait.php | 5 +++ .../Trait/ProductsInTaxonsAwareTrait.php | 11 +++++++ src/Entity/Trait/TaxonAwareTrait.php | 5 +++ 6 files changed, 21 insertions(+), 56 deletions(-) delete mode 100644 src/Entity/Trait/BlockProductAwareTrait.php delete mode 100644 src/Entity/Trait/BlockTaxonAwareTrait.php diff --git a/src/Entity/Block.php b/src/Entity/Block.php index 3457c357..072cddcf 100755 --- a/src/Entity/Block.php +++ b/src/Entity/Block.php @@ -10,8 +10,6 @@ namespace BitBag\SyliusCmsPlugin\Entity; -use BitBag\SyliusCmsPlugin\Entity\Trait\BlockProductAwareTrait; -use BitBag\SyliusCmsPlugin\Entity\Trait\BlockTaxonAwareTrait; use BitBag\SyliusCmsPlugin\Entity\Trait\ChannelsAwareTrait; use BitBag\SyliusCmsPlugin\Entity\Trait\CollectibleTrait; use BitBag\SyliusCmsPlugin\Entity\Trait\ContentConfigurationAwareTrait; @@ -31,8 +29,6 @@ class Block implements BlockInterface use ProductsAwareTrait; use TaxonAwareTrait; use ProductsInTaxonsAwareTrait; - use BlockTaxonAwareTrait; - use BlockProductAwareTrait; public function __construct() { diff --git a/src/Entity/Trait/BlockProductAwareTrait.php b/src/Entity/Trait/BlockProductAwareTrait.php deleted file mode 100644 index 27c13ab8..00000000 --- a/src/Entity/Trait/BlockProductAwareTrait.php +++ /dev/null @@ -1,31 +0,0 @@ -hasProduct($product); - } - - public function canBeDisplayedForProductInTaxon(ProductInterface $product): bool - { - $taxon = $product->getMainTaxon(); - if (null === $taxon) { - return false; - } - - return $this->hasProductsInTaxon($taxon); - } -} diff --git a/src/Entity/Trait/BlockTaxonAwareTrait.php b/src/Entity/Trait/BlockTaxonAwareTrait.php deleted file mode 100644 index c84cd24c..00000000 --- a/src/Entity/Trait/BlockTaxonAwareTrait.php +++ /dev/null @@ -1,21 +0,0 @@ -hasTaxon($taxon); - } -} diff --git a/src/Entity/Trait/ProductsAwareTrait.php b/src/Entity/Trait/ProductsAwareTrait.php index 57c35f55..c91f8017 100755 --- a/src/Entity/Trait/ProductsAwareTrait.php +++ b/src/Entity/Trait/ProductsAwareTrait.php @@ -47,4 +47,9 @@ public function removeProduct(ProductInterface $product): void $this->products->removeElement($product); } } + + public function canBeDisplayedForProduct(ProductInterface $product): bool + { + return $this->hasProduct($product); + } } diff --git a/src/Entity/Trait/ProductsInTaxonsAwareTrait.php b/src/Entity/Trait/ProductsInTaxonsAwareTrait.php index f95dea5a..3374808f 100644 --- a/src/Entity/Trait/ProductsInTaxonsAwareTrait.php +++ b/src/Entity/Trait/ProductsInTaxonsAwareTrait.php @@ -12,6 +12,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\TaxonInterface; trait ProductsInTaxonsAwareTrait @@ -47,4 +48,14 @@ public function removeProductsInTaxon(TaxonInterface $taxon): void $this->productsInTaxons->removeElement($taxon); } } + + public function canBeDisplayedForProductInTaxon(ProductInterface $product): bool + { + $taxon = $product->getMainTaxon(); + if (null === $taxon) { + return false; + } + + return $this->hasProductsInTaxon($taxon); + } } diff --git a/src/Entity/Trait/TaxonAwareTrait.php b/src/Entity/Trait/TaxonAwareTrait.php index 6679e493..2a5af43b 100644 --- a/src/Entity/Trait/TaxonAwareTrait.php +++ b/src/Entity/Trait/TaxonAwareTrait.php @@ -47,4 +47,9 @@ public function removeTaxon(TaxonInterface $taxon): void $this->taxons->removeElement($taxon); } } + + public function canBeDisplayedForTaxon(TaxonInterface $taxon): bool + { + return $this->hasTaxon($taxon); + } }