Skip to content

Instantly share code, notes, and snippets.

@matej21
Created November 11, 2015 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matej21/a11747da8582549944db to your computer and use it in GitHub Desktop.
Save matej21/a11747da8582549944db to your computer and use it in GitHub Desktop.
<?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