| @@ 322-346 (lines=25) @@ | ||
| 319 | * |
|
| 320 | * @todo add support for other attributes: contentTypeId, contentTypeIdentifier, section, etc... |
|
| 321 | */ |
|
| 322 | protected function setReferences($content) |
|
| 323 | { |
|
| 324 | if (!array_key_exists('references', $this->dsl)) { |
|
| 325 | return false; |
|
| 326 | } |
|
| 327 | ||
| 328 | foreach ($this->dsl['references'] as $reference) { |
|
| 329 | ||
| 330 | switch ($reference['attribute']) { |
|
| 331 | case 'object_id': |
|
| 332 | case 'id': |
|
| 333 | $value = $content->id; |
|
| 334 | break; |
|
| 335 | case 'location_id': |
|
| 336 | $value = $content->contentInfo->mainLocationId; |
|
| 337 | break; |
|
| 338 | default: |
|
| 339 | throw new \InvalidArgumentException('Content Manager does not support setting references for attribute ' . $reference['attribute']); |
|
| 340 | } |
|
| 341 | ||
| 342 | $this->referenceResolver->addReference($reference['identifier'], $value); |
|
| 343 | } |
|
| 344 | ||
| 345 | return true; |
|
| 346 | } |
|
| 347 | } |
|
| 348 | ||
| @@ 202-224 (lines=23) @@ | ||
| 199 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
|
| 200 | * @return boolean |
|
| 201 | */ |
|
| 202 | protected function setReferences($contentType) |
|
| 203 | { |
|
| 204 | if (!array_key_exists('references', $this->dsl)) { |
|
| 205 | return false; |
|
| 206 | } |
|
| 207 | ||
| 208 | foreach ($this->dsl['references'] as $reference) { |
|
| 209 | switch ($reference['attribute']) { |
|
| 210 | case 'content_type_id': |
|
| 211 | case 'id': |
|
| 212 | $value = $contentType->id; |
|
| 213 | break; |
|
| 214 | case 'content_type_identifier': |
|
| 215 | case 'identifier': |
|
| 216 | $value = $contentType->identifier; |
|
| 217 | break; |
|
| 218 | default: |
|
| 219 | throw new \InvalidArgumentException('Content Type Manager does not support setting references for attribute ' . $reference['attribute']); |
|
| 220 | } |
|
| 221 | ||
| 222 | $this->referenceResolver->addReference($reference['identifier'], $value); |
|
| 223 | } |
|
| 224 | } |
|
| 225 | ||
| 226 | /** |
|
| 227 | * Helper function to create field definitions based to be added to a new/existing content type. |
|