| @@ 244-273 (lines=30) @@ | ||
| 241 | * @return ContentCollection |
|
| 242 | * @throws \Exception |
|
| 243 | */ |
|
| 244 | protected function matchContents($action) |
|
| 245 | { |
|
| 246 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 247 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 248 | } |
|
| 249 | ||
| 250 | // Backwards compat |
|
| 251 | if (!isset($this->dsl['match'])) { |
|
| 252 | if (isset($this->dsl['object_id'])) { |
|
| 253 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 254 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 255 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 256 | } |
|
| 257 | } |
|
| 258 | ||
| 259 | $match = $this->dsl['match']; |
|
| 260 | ||
| 261 | // convert the references passed in the match |
|
| 262 | foreach ($match as $condition => $values) { |
|
| 263 | if (is_array($values)) { |
|
| 264 | foreach ($values as $position => $value) { |
|
| 265 | $match[$condition][$position] = $this->referenceResolver->resolveReference($value); |
|
| 266 | } |
|
| 267 | } else { |
|
| 268 | $match[$condition] = $this->referenceResolver->resolveReference($values); |
|
| 269 | } |
|
| 270 | } |
|
| 271 | ||
| 272 | return $this->contentMatcher->matchContent($match); |
|
| 273 | } |
|
| 274 | ||
| 275 | public function getSortField($newValue, $currentValue = null) |
|
| 276 | { |
|
| @@ 296-325 (lines=30) @@ | ||
| 293 | * @return ContentCollection |
|
| 294 | * @throws \Exception |
|
| 295 | */ |
|
| 296 | protected function matchContents($action) |
|
| 297 | { |
|
| 298 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 299 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 300 | } |
|
| 301 | ||
| 302 | // Backwards compat |
|
| 303 | if (!isset($this->dsl['match'])) { |
|
| 304 | if (isset($this->dsl['object_id'])) { |
|
| 305 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 306 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 307 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 308 | } |
|
| 309 | } |
|
| 310 | ||
| 311 | $match = $this->dsl['match']; |
|
| 312 | ||
| 313 | // convert the references passed in the match |
|
| 314 | foreach ($match as $condition => $values) { |
|
| 315 | if (is_array($values)) { |
|
| 316 | foreach ($values as $position => $value) { |
|
| 317 | $match[$condition][$position] = $this->referenceResolver->resolveReference($value); |
|
| 318 | } |
|
| 319 | } else { |
|
| 320 | $match[$condition] = $this->referenceResolver->resolveReference($values); |
|
| 321 | } |
|
| 322 | } |
|
| 323 | ||
| 324 | return $this->contentMatcher->match($match); |
|
| 325 | } |
|
| 326 | ||
| 327 | /** |
|
| 328 | * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings. |
|