forked from ezsystems/ezpublish-kernel
/
ContentTypeId.php
57 lines (50 loc) · 1.9 KB
/
ContentTypeId.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* File containing the eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\Specifications;
/**
* A criterion that matches content based on its ContentType id.
*
* Supported operators:
* - IN: will match from a list of ContentTypeId
* - EQ: will match against one ContentTypeId
*/
class ContentTypeId extends Criterion
{
/**
* Creates a new ContentType criterion.
*
* Content will be matched if it matches one of the contentTypeId in $value
*
* @param int|int[] $value One or more content type Id that must be matched
*
* @throws \InvalidArgumentException if a non numeric id is given
* @throws \InvalidArgumentException if the value type doesn't match the operator
*/
public function __construct($value)
{
parent::__construct(null, null, $value);
}
public function getSpecifications()
{
$types = Specifications::TYPE_INTEGER | Specifications::TYPE_STRING;
return array(
new Specifications(Operator::IN, Specifications::FORMAT_ARRAY, $types),
new Specifications(Operator::EQ, Specifications::FORMAT_SINGLE, $types),
);
}
/**
* @deprecated since 7.2, will be removed in 8.0. Use the constructor directly instead.
*/
public static function createFromQueryBuilder($target, $operator, $value)
{
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 7.2 and will be removed in 8.0.', E_USER_DEPRECATED);
return new self($value);
}
}