Skip to content

Commit

Permalink
OP-440: Remove unnecessary traits and move methods to existing traits
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Jul 24, 2024
1 parent a5144b2 commit 7f948bd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 56 deletions.
4 changes: 0 additions & 4 deletions src/Entity/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,8 +29,6 @@ class Block implements BlockInterface
use ProductsAwareTrait;
use TaxonAwareTrait;
use ProductsInTaxonsAwareTrait;
use BlockTaxonAwareTrait;
use BlockProductAwareTrait;

public function __construct()
{
Expand Down
31 changes: 0 additions & 31 deletions src/Entity/Trait/BlockProductAwareTrait.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Entity/Trait/BlockTaxonAwareTrait.php

This file was deleted.

5 changes: 5 additions & 0 deletions src/Entity/Trait/ProductsAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public function removeProduct(ProductInterface $product): void
$this->products->removeElement($product);
}
}

public function canBeDisplayedForProduct(ProductInterface $product): bool
{
return $this->hasProduct($product);
}
}
11 changes: 11 additions & 0 deletions src/Entity/Trait/ProductsInTaxonsAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
5 changes: 5 additions & 0 deletions src/Entity/Trait/TaxonAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public function removeTaxon(TaxonInterface $taxon): void
$this->taxons->removeElement($taxon);
}
}

public function canBeDisplayedForTaxon(TaxonInterface $taxon): bool
{
return $this->hasTaxon($taxon);
}
}

0 comments on commit 7f948bd

Please sign in to comment.