| @@ 207-236 (lines=30) @@ | ||
| 204 | * @return RoleCollection |
|
| 205 | * @throws \Exception |
|
| 206 | */ |
|
| 207 | protected function matchContentTypes($action) |
|
| 208 | { |
|
| 209 | if (!isset($this->dsl['identifier']) && !isset($this->dsl['match'])) { |
|
| 210 | throw new \Exception("The identifier of a contenttype or a match condition is required to $action it."); |
|
| 211 | } |
|
| 212 | ||
| 213 | // Backwards compat |
|
| 214 | if (!isset($this->dsl['match'])) { |
|
| 215 | $this->dsl['match'] = array('identifier' => $this->dsl['identifier']); |
|
| 216 | } |
|
| 217 | ||
| 218 | $match = $this->dsl['match']; |
|
| 219 | ||
| 220 | // convert the references passed in the match |
|
| 221 | foreach ($match as $condition => $values) { |
|
| 222 | if (is_array($values)) { |
|
| 223 | foreach ($values as $position => $value) { |
|
| 224 | if ($this->referenceResolver->isReference($value)) { |
|
| 225 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 226 | } |
|
| 227 | } |
|
| 228 | } else { |
|
| 229 | if ($this->referenceResolver->isReference($values)) { |
|
| 230 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 231 | } |
|
| 232 | } |
|
| 233 | } |
|
| 234 | ||
| 235 | return $this->contentTypeMatcher->match($match); |
|
| 236 | } |
|
| 237 | ||
| 238 | /** |
|
| 239 | * Sets references to object attributes |
|
| @@ 138-167 (lines=30) @@ | ||
| 135 | * @return RoleCollection |
|
| 136 | * @throws \Exception |
|
| 137 | */ |
|
| 138 | protected function matchRoles($action) |
|
| 139 | { |
|
| 140 | if (!isset($this->dsl['name']) && !isset($this->dsl['match'])) { |
|
| 141 | throw new \Exception("The name of a role or a match condition is required to $action it."); |
|
| 142 | } |
|
| 143 | ||
| 144 | // Backwards compat |
|
| 145 | if (!isset($this->dsl['match'])) { |
|
| 146 | $this->dsl['match'] = array('identifier' => $this->dsl['name']); |
|
| 147 | } |
|
| 148 | ||
| 149 | $match = $this->dsl['match']; |
|
| 150 | ||
| 151 | // convert the references passed in the match |
|
| 152 | foreach ($match as $condition => $values) { |
|
| 153 | if (is_array($values)) { |
|
| 154 | foreach ($values as $position => $value) { |
|
| 155 | if ($this->referenceResolver->isReference($value)) { |
|
| 156 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 157 | } |
|
| 158 | } |
|
| 159 | } else { |
|
| 160 | if ($this->referenceResolver->isReference($values)) { |
|
| 161 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 162 | } |
|
| 163 | } |
|
| 164 | } |
|
| 165 | ||
| 166 | return $this->roleMatcher->match($match); |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * Set references to object attributes to be retrieved later. |
|
| @@ 199-228 (lines=30) @@ | ||
| 196 | * @return ContentCollection |
|
| 197 | * @throws \Exception |
|
| 198 | */ |
|
| 199 | protected function matchLocations($action) |
|
| 200 | { |
|
| 201 | if (!isset($this->dsl['location_id'])&& !isset($this->dsl['match'])) { |
|
| 202 | throw new \Exception("The ID or a Match Condition is required to $action a location."); |
|
| 203 | } |
|
| 204 | ||
| 205 | // Backwards compat |
|
| 206 | if (!isset($this->dsl['match'])) { |
|
| 207 | $this->dsl['match'] = array('location_id' => $this->dsl['location_id']); |
|
| 208 | } |
|
| 209 | ||
| 210 | $match = $this->dsl['match']; |
|
| 211 | ||
| 212 | // convert the references passed in the match |
|
| 213 | foreach ($match as $condition => $values) { |
|
| 214 | if (is_array($values)) { |
|
| 215 | foreach ($values as $position => $value) { |
|
| 216 | if ($this->referenceResolver->isReference($value)) { |
|
| 217 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 218 | } |
|
| 219 | } |
|
| 220 | } else { |
|
| 221 | if ($this->referenceResolver->isReference($values)) { |
|
| 222 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 223 | } |
|
| 224 | } |
|
| 225 | } |
|
| 226 | ||
| 227 | return $this->locationMatcher->match($match); |
|
| 228 | } |
|
| 229 | ||
| 230 | /** |
|
| 231 | * NB: weirdly enough, it returns contents, not locations |
|