-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #511 from BitBagCommerce/feature/OP-440
OP-440: Conditional block rendering
- Loading branch information
Showing
34 changed files
with
520 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
use Sylius\Component\Core\Model\ProductInterface; | ||
|
||
interface BlockProductAwareInterface | ||
{ | ||
public function canBeDisplayedForProduct(ProductInterface $product): bool; | ||
|
||
public function canBeDisplayedForProductInTaxon(ProductInterface $product): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
use Sylius\Component\Core\Model\TaxonInterface; | ||
|
||
interface BlockTaxonAwareInterface | ||
{ | ||
public function canBeDisplayedForTaxon(TaxonInterface $taxon): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Sylius\Component\Core\Model\TaxonInterface; | ||
|
||
interface ProductsInTaxonsAwareInterface | ||
{ | ||
public function initializeProductsInTaxonsCollection(): void; | ||
|
||
/** | ||
* @return Collection|TaxonInterface[] | ||
*/ | ||
public function getProductsInTaxons(): Collection; | ||
|
||
public function hasProductsInTaxon(TaxonInterface $taxon): bool; | ||
|
||
public function addProductsInTaxon(TaxonInterface $taxon): void; | ||
|
||
public function removeProductsInTaxon(TaxonInterface $taxon): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity\Trait; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Sylius\Component\Core\Model\ProductInterface; | ||
use Sylius\Component\Core\Model\TaxonInterface; | ||
|
||
trait ProductsInTaxonsAwareTrait | ||
{ | ||
/** @var Collection|TaxonInterface[] */ | ||
protected Collection $productsInTaxons; | ||
|
||
public function initializeProductsInTaxonsCollection(): void | ||
{ | ||
$this->productsInTaxons = new ArrayCollection(); | ||
} | ||
|
||
public function getProductsInTaxons(): Collection | ||
{ | ||
return $this->productsInTaxons; | ||
} | ||
|
||
public function hasProductsInTaxon(TaxonInterface $taxon): bool | ||
{ | ||
return $this->productsInTaxons->contains($taxon); | ||
} | ||
|
||
public function addProductsInTaxon(TaxonInterface $taxon): void | ||
{ | ||
if (false === $this->hasProductsInTaxon($taxon)) { | ||
$this->productsInTaxons->add($taxon); | ||
} | ||
} | ||
|
||
public function removeProductsInTaxon(TaxonInterface $taxon): void | ||
{ | ||
if (true === $this->hasProductsInTaxon($taxon)) { | ||
$this->productsInTaxons->removeElement($taxon); | ||
} | ||
} | ||
|
||
public function canBeDisplayedForProductInTaxon(ProductInterface $product): bool | ||
{ | ||
$taxon = $product->getMainTaxon(); | ||
if (null === $taxon) { | ||
return false; | ||
} | ||
|
||
return $this->hasProductsInTaxon($taxon); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.