|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the eZ\Publish\API\Repository\Values\Content\Query\Criterion\FieldRelation class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
|
12
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* A criterion that matches Content based on the relations in relation field. |
|
16
|
|
|
* This includes Relation and RelationList field types in standard installation, but also any |
|
17
|
|
|
* other field type storing {@link \eZ\Publish\API\Repository\Values\Content\Relation::FIELD} |
|
18
|
|
|
* type relation. |
|
19
|
|
|
* |
|
20
|
|
|
* Supported operators: |
|
21
|
|
|
* - IN: will match if Content relates to one or more of the given ids through given relation field |
|
22
|
|
|
* - CONTAINS: will match if Content relates to all of the given ids through given relation field |
|
23
|
|
|
*/ |
|
24
|
|
|
class FieldRelation extends Criterion |
|
25
|
|
|
{ |
|
26
|
|
|
public function getSpecifications() |
|
27
|
|
|
{ |
|
28
|
|
|
$types = Specifications::TYPE_INTEGER | Specifications::TYPE_STRING; |
|
29
|
|
|
|
|
30
|
|
|
return [ |
|
31
|
|
|
new Specifications(Operator::CONTAINS, Specifications::FORMAT_SINGLE | Specifications::FORMAT_ARRAY, $types), |
|
32
|
|
|
new Specifications(Operator::IN, Specifications::FORMAT_ARRAY, $types), |
|
33
|
|
|
]; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @deprecated since 7.2, will be removed in 8.0. Use the constructor directly instead. |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function createFromQueryBuilder($target, $operator, $value) |
|
40
|
|
|
{ |
|
41
|
|
|
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 7.2 and will be removed in 8.0.', E_USER_DEPRECATED); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
return new self($target, $operator, $value); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: