| @@ 334-356 (lines=23) @@ | ||
| 331 | * @return ContentCollection |
|
| 332 | * @throws \Exception |
|
| 333 | */ |
|
| 334 | protected function matchContents($action, $step) |
|
| 335 | { |
|
| 336 | if (!isset($step->dsl['object_id']) && !isset($step->dsl['remote_id']) && !isset($step->dsl['match'])) { |
|
| 337 | throw new \Exception("The id or remote id of an object or a match condition is required to $action a content"); |
|
| 338 | } |
|
| 339 | ||
| 340 | // Backwards compat |
|
| 341 | ||
| 342 | if (isset($step->dsl['match'])) { |
|
| 343 | $match = $step->dsl['match']; |
|
| 344 | } else { |
|
| 345 | if (isset($step->dsl['object_id'])) { |
|
| 346 | $match = array('content_id' => $step->dsl['object_id']); |
|
| 347 | } elseif (isset($step->dsl['remote_id'])) { |
|
| 348 | $match = array('content_remote_id' => $step->dsl['remote_id']); |
|
| 349 | } |
|
| 350 | } |
|
| 351 | ||
| 352 | // convert the references passed in the match |
|
| 353 | $match = $this->resolveReferencesRecursively($match); |
|
| 354 | ||
| 355 | return $this->contentMatcher->match($match); |
|
| 356 | } |
|
| 357 | ||
| 358 | /** |
|
| 359 | * @param Content $content |
|
| @@ 178-200 (lines=23) @@ | ||
| 175 | * @return UserGroupCollection |
|
| 176 | * @throws \Exception |
|
| 177 | */ |
|
| 178 | protected function matchUserGroups($action, $step) |
|
| 179 | { |
|
| 180 | if (!isset($step->dsl['id']) && !isset($step->dsl['group']) && !isset($step->dsl['match'])) { |
|
| 181 | throw new \Exception("The id of a user group or a match condition is required to $action it"); |
|
| 182 | } |
|
| 183 | ||
| 184 | // Backwards compat |
|
| 185 | if (isset($step->dsl['match'])) { |
|
| 186 | $match = $step->dsl['match']; |
|
| 187 | } else { |
|
| 188 | if (isset($step->dsl['id'])) { |
|
| 189 | $match = array('id' => $step->dsl['id']); |
|
| 190 | } |
|
| 191 | if (isset($step->dsl['group'])) { |
|
| 192 | $match = array('id' => $step->dsl['group']); |
|
| 193 | } |
|
| 194 | } |
|
| 195 | ||
| 196 | // convert the references passed in the match |
|
| 197 | $match = $this->resolveReferencesRecursively($match); |
|
| 198 | ||
| 199 | return $this->userGroupMatcher->match($match); |
|
| 200 | } |
|
| 201 | ||
| 202 | /** |
|
| 203 | * @param UserGroup $userGroup |
|