Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/jsonapi/src/Query/EntityConditionGroup.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\jsonapi\Query; | |
4 | |
5 /** | |
6 * A condition group for the EntityQuery. | |
7 * | |
8 * @internal JSON:API maintains no PHP API since its API is the HTTP API. This | |
9 * class may change at any time and this will break any dependencies on it. | |
10 * | |
11 * @see https://www.drupal.org/project/jsonapi/issues/3032787 | |
12 * @see jsonapi.api.php | |
13 */ | |
14 class EntityConditionGroup { | |
15 | |
16 /** | |
17 * The AND conjunction value. | |
18 * | |
19 * @var array | |
20 */ | |
21 protected static $allowedConjunctions = ['AND', 'OR']; | |
22 | |
23 /** | |
24 * The conjunction. | |
25 * | |
26 * @var string | |
27 */ | |
28 protected $conjunction; | |
29 | |
30 /** | |
31 * The members of the condition group. | |
32 * | |
33 * @var \Drupal\jsonapi\Query\EntityCondition[] | |
34 */ | |
35 protected $members; | |
36 | |
37 /** | |
38 * Constructs a new condition group object. | |
39 * | |
40 * @param string $conjunction | |
41 * The group conjunction to use. | |
42 * @param array $members | |
43 * (optional) The group conjunction to use. | |
44 */ | |
45 public function __construct($conjunction, array $members = []) { | |
46 if (!in_array($conjunction, self::$allowedConjunctions)) { | |
47 throw new \InvalidArgumentException('Allowed conjunctions: AND, OR.'); | |
48 } | |
49 $this->conjunction = $conjunction; | |
50 $this->members = $members; | |
51 } | |
52 | |
53 /** | |
54 * The condition group conjunction. | |
55 * | |
56 * @return string | |
57 * The condition group conjunction. | |
58 */ | |
59 public function conjunction() { | |
60 return $this->conjunction; | |
61 } | |
62 | |
63 /** | |
64 * The members which belong to the the condition group. | |
65 * | |
66 * @return \Drupal\jsonapi\Query\EntityCondition[] | |
67 * The member conditions of this condition group. | |
68 */ | |
69 public function members() { | |
70 return $this->members; | |
71 } | |
72 | |
73 } |