| @@ 303-332 (lines=30) @@ | ||
| 300 | * @return ContentCollection |
|
| 301 | * @throws \Exception |
|
| 302 | */ |
|
| 303 | protected function matchContents($action) |
|
| 304 | { |
|
| 305 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 306 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 307 | } |
|
| 308 | ||
| 309 | // Backwards compat |
|
| 310 | if (!isset($this->dsl['match'])) { |
|
| 311 | if (isset($this->dsl['object_id'])) { |
|
| 312 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 313 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 314 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 315 | } |
|
| 316 | } |
|
| 317 | ||
| 318 | $match = $this->dsl['match']; |
|
| 319 | ||
| 320 | // convert the references passed in the match |
|
| 321 | foreach ($match as $condition => $values) { |
|
| 322 | if (is_array($values)) { |
|
| 323 | foreach ($values as $position => $value) { |
|
| 324 | $match[$condition][$position] = $this->referenceResolver->resolveReference($value); |
|
| 325 | } |
|
| 326 | } else { |
|
| 327 | $match[$condition] = $this->referenceResolver->resolveReference($values); |
|
| 328 | } |
|
| 329 | } |
|
| 330 | ||
| 331 | return $this->contentMatcher->match($match); |
|
| 332 | } |
|
| 333 | ||
| 334 | /** |
|
| 335 | * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings. |
|
| @@ 248-277 (lines=30) @@ | ||
| 245 | * @return ContentCollection |
|
| 246 | * @throws \Exception |
|
| 247 | */ |
|
| 248 | protected function matchContents($action) |
|
| 249 | { |
|
| 250 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 251 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 252 | } |
|
| 253 | ||
| 254 | // Backwards compat |
|
| 255 | if (!isset($this->dsl['match'])) { |
|
| 256 | if (isset($this->dsl['object_id'])) { |
|
| 257 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 258 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 259 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 260 | } |
|
| 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->contentMatcher->matchContent($match); |
|
| 277 | } |
|
| 278 | ||
| 279 | /** |
|
| 280 | * @param $newValue |
|