| @@ 189-222 (lines=34) @@ | ||
| 186 | * @return ContentCollection |
|
| 187 | * @throws \Exception |
|
| 188 | */ |
|
| 189 | protected function matchContents($action) |
|
| 190 | { |
|
| 191 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 192 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 193 | } |
|
| 194 | ||
| 195 | // Backwards compat |
|
| 196 | if (!isset($this->dsl['match'])) { |
|
| 197 | if (isset($this->dsl['object_id'])) { |
|
| 198 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 199 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 200 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 201 | } |
|
| 202 | } |
|
| 203 | ||
| 204 | $match = $this->dsl['match']; |
|
| 205 | ||
| 206 | // convert the references passed in the match |
|
| 207 | foreach ($match as $condition => $values) { |
|
| 208 | if (is_array($values)) { |
|
| 209 | foreach ($values as $position => $value) { |
|
| 210 | if ($this->referenceResolver->isReference($value)) { |
|
| 211 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 212 | } |
|
| 213 | } |
|
| 214 | } else { |
|
| 215 | if ($this->referenceResolver->isReference($values)) { |
|
| 216 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 217 | } |
|
| 218 | } |
|
| 219 | } |
|
| 220 | ||
| 221 | return $this->contentMatcher->match($match); |
|
| 222 | } |
|
| 223 | ||
| 224 | /** |
|
| 225 | * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings. |
|
| @@ 215-248 (lines=34) @@ | ||
| 212 | * @return ContentCollection |
|
| 213 | * @throws \Exception |
|
| 214 | */ |
|
| 215 | protected function matchContents($action) |
|
| 216 | { |
|
| 217 | if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) { |
|
| 218 | throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location."); |
|
| 219 | } |
|
| 220 | ||
| 221 | // Backwards compat |
|
| 222 | if (!isset($this->dsl['match'])) { |
|
| 223 | if (isset($this->dsl['object_id'])) { |
|
| 224 | $this->dsl['match'] = array('content_id' => $this->dsl['object_id']); |
|
| 225 | } elseif (isset($this->dsl['remote_id'])) { |
|
| 226 | $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']); |
|
| 227 | } |
|
| 228 | } |
|
| 229 | ||
| 230 | $match = $this->dsl['match']; |
|
| 231 | ||
| 232 | // convert the references passed in the match |
|
| 233 | foreach ($match as $condition => $values) { |
|
| 234 | if (is_array($values)) { |
|
| 235 | foreach ($values as $position => $value) { |
|
| 236 | if ($this->referenceResolver->isReference($value)) { |
|
| 237 | $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value); |
|
| 238 | } |
|
| 239 | } |
|
| 240 | } else { |
|
| 241 | if ($this->referenceResolver->isReference($values)) { |
|
| 242 | $match[$condition] = $this->referenceResolver->getReferenceValue($values); |
|
| 243 | } |
|
| 244 | } |
|
| 245 | } |
|
| 246 | ||
| 247 | return $this->contentMatcher->matchContent($match); |
|
| 248 | } |
|
| 249 | ||
| 250 | protected function getSortField($currentValue = null) |
|
| 251 | { |
|