| @@ 15-47 (lines=33) @@ | ||
| 12 | * | |
| 13 | * @author gbprod <[email protected]> | |
| 14 | */ | |
| 15 | class AndXFactory implements Factory | |
| 16 | { | |
| 17 | /** | |
| 18 | * @var Registry | |
| 19 | */ | |
| 20 | private $registry; | |
| 21 | ||
| 22 | /** | |
| 23 | * @param Registry $registry | |
| 24 | */ | |
| 25 | public function __construct(Registry $registry) | |
| 26 |     { | |
| 27 | $this->registry = $registry; | |
| 28 | } | |
| 29 | ||
| 30 | /** | |
| 31 |      * {inheritdoc} | |
| 32 | */ | |
| 33 | public function create(Specification $spec, QueryBuilder $qb) | |
| 34 |     { | |
| 35 |         if (!$spec instanceof AndX) { | |
| 36 | throw new \InvalidArgumentException(); | |
| 37 | } | |
| 38 | ||
| 39 | $firstPartFactory = $this->registry->getFactory($spec->getFirstPart()); | |
| 40 | $secondPartFactory = $this->registry->getFactory($spec->getSecondPart()); | |
| 41 | ||
| 42 | return $qb->expr()->andx( | |
| 43 | $firstPartFactory->create($spec->getFirstPart(), $qb), | |
| 44 | $secondPartFactory->create($spec->getSecondPart(), $qb) | |
| 45 | ); | |
| 46 | } | |
| 47 | } | |
| 48 | ||
| @@ 15-47 (lines=33) @@ | ||
| 12 | * | |
| 13 | * @author gbprod <[email protected]> | |
| 14 | */ | |
| 15 | class OrXFactory implements Factory | |
| 16 | { | |
| 17 | /** | |
| 18 | * @var Registry | |
| 19 | */ | |
| 20 | private $registry; | |
| 21 | ||
| 22 | /** | |
| 23 | * @param Registry $registry | |
| 24 | */ | |
| 25 | public function __construct(Registry $registry) | |
| 26 |     { | |
| 27 | $this->registry = $registry; | |
| 28 | } | |
| 29 | ||
| 30 | /** | |
| 31 |      * {inheritdoc} | |
| 32 | */ | |
| 33 | public function create(Specification $spec, QueryBuilder $qb) | |
| 34 |     { | |
| 35 |         if (!$spec instanceof OrX) { | |
| 36 | throw new \InvalidArgumentException(); | |
| 37 | } | |
| 38 | ||
| 39 | $firstPartFactory = $this->registry->getFactory($spec->getFirstPart()); | |
| 40 | $secondPartFactory = $this->registry->getFactory($spec->getSecondPart()); | |
| 41 | ||
| 42 | return $qb->expr()->orx( | |
| 43 | $firstPartFactory->create($spec->getFirstPart(), $qb), | |
| 44 | $secondPartFactory->create($spec->getSecondPart(), $qb) | |
| 45 | ); | |
| 46 | } | |
| 47 | } | |
| 48 | ||