Created
November 11, 2015 14:12
-
-
Save matej21/a11747da8582549944db to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class CategorySpecification | |
{ | |
private $category; | |
public function __construct($category) | |
{ | |
$this->category = $category; | |
} | |
public function __invoke($qb) | |
{ | |
$qb->andWhere(..); | |
} | |
} | |
class ArticleQuery extends QueryObject | |
{ | |
private $specifications = []; | |
public function addSpecification($spec) | |
{ | |
$this->specifications[] = $spec; | |
} | |
protected function doCreateQuery($queryable) | |
{ | |
$qb = ...; | |
foreach ($this->specifications as $spec) { | |
$spec($qb); | |
} | |
return $qb; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment