1 | <?php |
||
13 | trait SpecificationRepositoryTrait |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $dqlAlias = 'e'; |
||
19 | |||
20 | /** |
||
21 | * @see SpecificationAware::match() |
||
22 | * |
||
23 | * @param SpecificationInterface $specification |
||
24 | * @param ModifierInterface|null $modifier |
||
25 | * |
||
26 | * @return Query |
||
27 | * @throws LogicException |
||
28 | */ |
||
29 | public function match(SpecificationInterface $specification, ModifierInterface $modifier = null) |
||
43 | |||
44 | /** |
||
45 | * Modifies the QueryBuilder according to the passed Specification. |
||
46 | * Will also set the condition for this query if needed. |
||
47 | * |
||
48 | * @param QueryBuilder $queryBuilder |
||
49 | * @param SpecificationInterface $specification |
||
50 | * |
||
51 | * @internal param string $dqlAlias |
||
52 | */ |
||
53 | private function modifyQueryBuilder(QueryBuilder $queryBuilder, SpecificationInterface $specification) |
||
63 | |||
64 | /** |
||
65 | * Modifies and returns a Query object according to the (optional) result modifier. |
||
66 | * |
||
67 | * @param QueryBuilder $queryBuilder |
||
68 | * @param ModifierInterface|null $modifier |
||
69 | * |
||
70 | * @return Query |
||
71 | */ |
||
72 | private function modifyQuery(QueryBuilder $queryBuilder, ModifierInterface $modifier = null) |
||
82 | } |
||
83 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.