1 | <?php |
||
21 | abstract class Handler |
||
22 | { |
||
23 | /** |
||
24 | * DB handler to fetch additional field information. |
||
25 | * |
||
26 | * @var \eZ\Publish\Core\Persistence\Database\DatabaseHandler |
||
27 | */ |
||
28 | protected $dbHandler; |
||
29 | |||
30 | /** |
||
31 | * Map of criterion operators to the respective function names |
||
32 | * in the DoctrineDatabase DBAL. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $comparatorMap = array( |
||
37 | CriterionOperator::EQ => 'eq', |
||
38 | CriterionOperator::GT => 'gt', |
||
39 | CriterionOperator::GTE => 'gte', |
||
40 | CriterionOperator::LT => 'lt', |
||
41 | CriterionOperator::LTE => 'lte', |
||
42 | CriterionOperator::LIKE => 'like', |
||
43 | ); |
||
44 | |||
45 | /** |
||
46 | * Transformation processor. |
||
47 | * |
||
48 | * @var \eZ\Publish\Core\Persistence\TransformationProcessor |
||
49 | */ |
||
50 | protected $transformationProcessor; |
||
51 | |||
52 | /** |
||
53 | * Creates a new criterion handler. |
||
54 | * |
||
55 | * @param \eZ\Publish\Core\Persistence\Database\DatabaseHandler $dbHandler |
||
56 | * @param \eZ\Publish\Core\Persistence\TransformationProcessor $transformationProcessor |
||
57 | */ |
||
58 | public function __construct(DatabaseHandler $dbHandler, TransformationProcessor $transformationProcessor) |
||
63 | |||
64 | /** |
||
65 | * Generates query expression for operator and value of a Field Criterion. |
||
66 | * |
||
67 | * @throws \RuntimeException If operator is not handled. |
||
68 | * |
||
69 | * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query |
||
70 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion |
||
71 | * @param string $column |
||
72 | * |
||
73 | * @return \eZ\Publish\Core\Persistence\Database\Expression |
||
74 | */ |
||
75 | public function handle(SelectQuery $query, Criterion $criterion, $column) |
||
123 | |||
124 | /** |
||
125 | * Returns the given $string prepared for use in SQL LIKE clause. |
||
126 | * |
||
127 | * LIKE clause wildcards '%' and '_' contained in the given $string will be escaped. |
||
128 | * |
||
129 | * @param $string |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | protected function prepareLikeString($string) |
||
137 | |||
138 | /** |
||
139 | * Downcases a given string using string transformation processor. |
||
140 | * |
||
141 | * @param string $string |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | protected function lowerCase($string) |
||
149 | } |
||
150 |