| @@ 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 |
|
| @@ 163-185 (lines=23) @@ | ||
| 160 | * @return UserGroupCollection |
|
| 161 | * @throws \Exception |
|
| 162 | */ |
|
| 163 | protected function matchUserGroups($action, $step) |
|
| 164 | { |
|
| 165 | if (!isset($step->dsl['id']) && !isset($step->dsl['group']) && !isset($step->dsl['match'])) { |
|
| 166 | throw new \Exception("The id of a user group or a match condition is required to $action it"); |
|
| 167 | } |
|
| 168 | ||
| 169 | // Backwards compat |
|
| 170 | if (isset($step->dsl['match'])) { |
|
| 171 | $match = $step->dsl['match']; |
|
| 172 | } else { |
|
| 173 | if (isset($step->dsl['id'])) { |
|
| 174 | $match = array('id' => $step->dsl['id']); |
|
| 175 | } |
|
| 176 | if (isset($step->dsl['group'])) { |
|
| 177 | $match = array('id' => $step->dsl['group']); |
|
| 178 | } |
|
| 179 | } |
|
| 180 | ||
| 181 | // convert the references passed in the match |
|
| 182 | $match = $this->resolveReferencesRecursively($match); |
|
| 183 | ||
| 184 | return $this->userGroupMatcher->match($match); |
|
| 185 | } |
|
| 186 | ||
| 187 | /** |
|
| 188 | * @param UserGroup $userGroup |
|