| @@ 137-162 (lines=26) @@ | ||
| 134 | * @return RoleCollection |
|
| 135 | * @throws \Exception |
|
| 136 | */ |
|
| 137 | protected function matchRoles($action) |
|
| 138 | { |
|
| 139 | if (!isset($this->dsl['name']) && !isset($this->dsl['match'])) { |
|
| 140 | throw new \Exception("The name of a role or a match condition is required to $action it."); |
|
| 141 | } |
|
| 142 | ||
| 143 | // Backwards compat |
|
| 144 | if (!isset($this->dsl['match'])) { |
|
| 145 | $this->dsl['match'] = array('identifier' => $this->dsl['name']); |
|
| 146 | } |
|
| 147 | ||
| 148 | $match = $this->dsl['match']; |
|
| 149 | ||
| 150 | // convert the references passed in the match |
|
| 151 | foreach ($match as $condition => $values) { |
|
| 152 | if (is_array($values)) { |
|
| 153 | foreach ($values as $position => $value) { |
|
| 154 | $match[$condition][$position] = $this->referenceResolver->resolveReference($value); |
|
| 155 | } |
|
| 156 | } else { |
|
| 157 | $match[$condition] = $this->referenceResolver->resolveReference($values); |
|
| 158 | } |
|
| 159 | } |
|
| 160 | ||
| 161 | return $this->roleMatcher->match($match); |
|
| 162 | } |
|
| 163 | ||
| 164 | /** |
|
| 165 | * Set references to object attributes to be retrieved later. |
|
| @@ 252-277 (lines=26) @@ | ||
| 249 | * @return ContentTypeCollection |
|
| 250 | * @throws \Exception |
|
| 251 | */ |
|
| 252 | protected function matchContentTypes($action) |
|
| 253 | { |
|
| 254 | if (!isset($this->dsl['identifier']) && !isset($this->dsl['match'])) { |
|
| 255 | throw new \Exception("The identifier of a contenttype or a match condition is required to $action it."); |
|
| 256 | } |
|
| 257 | ||
| 258 | // Backwards compat |
|
| 259 | if (!isset($this->dsl['match'])) { |
|
| 260 | $this->dsl['match'] = array('identifier' => $this->dsl['identifier']); |
|
| 261 | } |
|
| 262 | ||
| 263 | $match = $this->dsl['match']; |
|
| 264 | ||
| 265 | // convert the references passed in the match |
|
| 266 | foreach ($match as $condition => $values) { |
|
| 267 | if (is_array($values)) { |
|
| 268 | foreach ($values as $position => $value) { |
|
| 269 | $match[$condition][$position] = $this->referenceResolver->resolveReference($value); |
|
| 270 | } |
|
| 271 | } else { |
|
| 272 | $match[$condition] = $this->referenceResolver->resolveReference($values); |
|
| 273 | } |
|
| 274 | } |
|
| 275 | ||
| 276 | return $this->contentTypeMatcher->match($match); |
|
| 277 | } |
|
| 278 | ||
| 279 | /** |
|
| 280 | * Sets references to object attributes |
|
| @@ 218-243 (lines=26) @@ | ||
| 215 | * @return LocationCollection |
|
| 216 | * @throws \Exception |
|
| 217 | */ |
|
| 218 | protected function matchLocations($action) |
|
| 219 | { |
|
| 220 | if (!isset($this->dsl['location_id']) && !isset($this->dsl['match'])) { |
|
| 221 | throw new \Exception("The ID or a Match Condition is required to $action a location."); |
|
| 222 | } |
|
| 223 | ||
| 224 | // Backwards compat |
|
| 225 | if (!isset($this->dsl['match'])) { |
|
| 226 | $this->dsl['match'] = array('location_id' => $this->dsl['location_id']); |
|
| 227 | } |
|
| 228 | ||
| 229 | $match = $this->dsl['match']; |
|
| 230 | ||
| 231 | // convert the references passed in the match |
|
| 232 | foreach ($match as $condition => $values) { |
|
| 233 | if (is_array($values)) { |
|
| 234 | foreach ($values as $position => $value) { |
|
| 235 | $match[$condition][$position] = $this->referenceResolver->resolveReference($value); |
|
| 236 | } |
|
| 237 | } else { |
|
| 238 | $match[$condition] = $this->referenceResolver->resolveReference($values); |
|
| 239 | } |
|
| 240 | } |
|
| 241 | ||
| 242 | return $this->locationMatcher->match($match); |
|
| 243 | } |
|
| 244 | ||
| 245 | /** |
|
| 246 | * @param int|string|array $locationKey |
|