| @@ 217-250 (lines=34) @@ | ||
| 214 | * @return ContentCollection |
|
| 215 | * @throws \Exception |
|
| 216 | */ |
|
| 217 | protected function matchContents($action) |
|
| 218 | { |
|
| 219 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 220 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 221 | } |
|
| 222 | ||
| 223 | // Backwards compat |
|
| 224 | if (!isset($this->dsl['match'])) { |
|
| 225 | if (isset($this->dsl['object_id'])) { |
|
| 226 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 227 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 228 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 229 | } |
|
| 230 | } |
|
| 231 | ||
| 232 | $match = $this->dsl['match']; |
|
| 233 | ||
| 234 | // convert the references passed in the match |
|
| 235 | foreach ($match as $condition => $values) { |
|
| 236 | if (is_array($values)) { |
|
| 237 | foreach ($values as $position => $value) { |
|
| 238 | if ($this->referenceResolver->isReference($value)) { |
|
| 239 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 240 | } |
|
| 241 | } |
|
| 242 | } else { |
|
| 243 | if ($this->referenceResolver->isReference($values)) { |
|
| 244 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 245 | } |
|
| 246 | } |
|
| 247 | } |
|
| 248 | ||
| 249 | return $this->contentMatcher->match($match); |
|
| 250 | } |
|
| 251 | ||
| 252 | /** |
|
| 253 | * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings. |
|
| @@ 237-270 (lines=34) @@ | ||
| 234 | * @return ContentCollection |
|
| 235 | * @throws \Exception |
|
| 236 | */ |
|
| 237 | protected function matchContents($action) |
|
| 238 | { |
|
| 239 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 240 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 241 | } |
|
| 242 | ||
| 243 | // Backwards compat |
|
| 244 | if (!isset($this->dsl['match'])) { |
|
| 245 | if (isset($this->dsl['object_id'])) { |
|
| 246 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 247 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 248 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 249 | } |
|
| 250 | } |
|
| 251 | ||
| 252 | $match = $this->dsl['match']; |
|
| 253 | ||
| 254 | // convert the references passed in the match |
|
| 255 | foreach ($match as $condition => $values) { |
|
| 256 | if (is_array($values)) { |
|
| 257 | foreach ($values as $position => $value) { |
|
| 258 | if ($this->referenceResolver->isReference($value)) { |
|
| 259 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 260 | } |
|
| 261 | } |
|
| 262 | } else { |
|
| 263 | if ($this->referenceResolver->isReference($values)) { |
|
| 264 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 265 | } |
|
| 266 | } |
|
| 267 | } |
|
| 268 | ||
| 269 | return $this->contentMatcher->matchContent($match); |
|
| 270 | } |
|
| 271 | ||
| 272 | protected function getSortField($newValue, $currentValue = null) |
|
| 273 | { |
|