|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the eZ\Publish\API\Repository\Values\Content\Query\Criterion\Visibility 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
|
|
|
use InvalidArgumentException; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* A criterion that matches content based on its visibility. |
|
17
|
|
|
* |
|
18
|
|
|
* Warning: This Criterion acts on all locations of a Content, so it will include hidden |
|
19
|
|
|
* content within the tree you are searching for if content has visible location elsewhere. |
|
20
|
|
|
* This is intentional and you should rather use LocationSearch if this is not the behaviour you want. |
|
21
|
|
|
*/ |
|
22
|
|
|
class Visibility extends Criterion |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Visibility constant: visible. |
|
26
|
|
|
*/ |
|
27
|
|
|
const VISIBLE = 0; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Visibility constant: hidden. |
|
31
|
|
|
*/ |
|
32
|
|
|
const HIDDEN = 1; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Creates a new Visibility criterion. |
|
36
|
|
|
* |
|
37
|
|
|
* @param int $value Visibility: self::VISIBLE, self::HIDDEN |
|
38
|
|
|
* |
|
39
|
|
|
* @throws \InvalidArgumentException |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct($value) |
|
42
|
|
|
{ |
|
43
|
|
|
if ($value !== self::VISIBLE && $value !== self::HIDDEN) { |
|
44
|
|
|
throw new InvalidArgumentException("Invalid visibility value $value"); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
parent::__construct(null, null, $value); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getSpecifications() |
|
51
|
|
|
{ |
|
52
|
|
|
return [ |
|
53
|
|
|
new Specifications( |
|
54
|
|
|
Operator::EQ, |
|
55
|
|
|
Specifications::FORMAT_SINGLE, |
|
56
|
|
|
Specifications::TYPE_INTEGER |
|
57
|
|
|
), |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|