| @@ 299-323 (lines=25) @@ | ||
| 296 | * |
|
| 297 | * @todo add support for other attributes: contentTypeId, contentTypeIdentifier, section, etc... |
|
| 298 | */ |
|
| 299 | protected function setReferences($content) |
|
| 300 | { |
|
| 301 | if (!array_key_exists('references', $this->dsl)) { |
|
| 302 | return false; |
|
| 303 | } |
|
| 304 | ||
| 305 | foreach ($this->dsl['references'] as $reference) { |
|
| 306 | ||
| 307 | switch ($reference['attribute']) { |
|
| 308 | case 'object_id': |
|
| 309 | case 'id': |
|
| 310 | $value = $content->id; |
|
| 311 | break; |
|
| 312 | case 'location_id': |
|
| 313 | $value = $content->contentInfo->mainLocationId; |
|
| 314 | break; |
|
| 315 | default: |
|
| 316 | throw new \InvalidArgumentException('Content Manager does not support setting references for attribute ' . $reference['attribute']); |
|
| 317 | } |
|
| 318 | ||
| 319 | $this->referenceResolver->addReference($reference['identifier'], $value); |
|
| 320 | } |
|
| 321 | ||
| 322 | return true; |
|
| 323 | } |
|
| 324 | } |
|
| 325 | ||
| @@ 212-234 (lines=23) @@ | ||
| 209 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
|
| 210 | * @return boolean |
|
| 211 | */ |
|
| 212 | protected function setReferences($contentType) |
|
| 213 | { |
|
| 214 | if (!array_key_exists('references', $this->dsl)) { |
|
| 215 | return false; |
|
| 216 | } |
|
| 217 | ||
| 218 | foreach ($this->dsl['references'] as $reference) { |
|
| 219 | switch ($reference['attribute']) { |
|
| 220 | case 'content_type_id': |
|
| 221 | case 'id': |
|
| 222 | $value = $contentType->id; |
|
| 223 | break; |
|
| 224 | case 'content_type_identifier': |
|
| 225 | case 'identifier': |
|
| 226 | $value = $contentType->identifier; |
|
| 227 | break; |
|
| 228 | default: |
|
| 229 | throw new \InvalidArgumentException('Content Type Manager does not support setting references for attribute ' . $reference['attribute']); |
|
| 230 | } |
|
| 231 | ||
| 232 | $this->referenceResolver->addReference($reference['identifier'], $value); |
|
| 233 | } |
|
| 234 | } |
|
| 235 | ||
| 236 | /** |
|
| 237 | * Helper function to create field definitions based to be added to a new/existing content type. |
|