1 | <?php |
||
13 | trait SpecificationRepositoryTrait |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $dqlAlias = 'e'; |
||
19 | |||
20 | /** |
||
21 | * @see SpecificationAwareInterface::match() |
||
22 | * |
||
23 | * @param SpecificationInterface $specification |
||
24 | * @param ModifierInterface|null $modifier |
||
25 | * |
||
26 | * @throws LogicException |
||
27 | * |
||
28 | * @return Query |
||
29 | */ |
||
30 | public function match(SpecificationInterface $specification, ModifierInterface $modifier = null) |
||
44 | |||
45 | /** |
||
46 | * Modifies the QueryBuilder according to the passed Specification. |
||
47 | * Will also set the condition for this query if needed. |
||
48 | * |
||
49 | * @param QueryBuilder $queryBuilder |
||
50 | * @param SpecificationInterface $specification |
||
51 | * |
||
52 | * @internal param string $dqlAlias |
||
53 | */ |
||
54 | private function modifyQueryBuilder(QueryBuilder $queryBuilder, SpecificationInterface $specification) |
||
64 | |||
65 | /** |
||
66 | * Modifies and returns a Query object according to the (optional) result modifier. |
||
67 | * |
||
68 | * @param QueryBuilder $queryBuilder |
||
69 | * @param ModifierInterface|null $modifier |
||
70 | * |
||
71 | * @return Query |
||
72 | */ |
||
73 | private function modifyQuery(QueryBuilder $queryBuilder, ModifierInterface $modifier = null) |
||
83 | } |
||
84 |
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.