/** * Returns the rendition document using the provides OperationContext if the rendition is a stand-alone document. * * @param OperationContextInterface|null $context * @return DocumentInterface|null the rendition document or <code>null</code> if there is no rendition document */ public function getRenditionDocument(OperationContextInterface $context = null) { $renditionDocumentId = $this->getRenditionDocumentId(); if (empty($renditionDocumentId)) { return null; } if ($context === null) { $context = $this->session->getDefaultContext(); } $document = $this->session->getObject($this->session->createObjectId($renditionDocumentId), $context); return $document instanceof DocumentInterface ? $document : null; }
/** * @param SessionInterface $session * @param ObjectDataInterface $objectData */ public function __construct(SessionInterface $session, ObjectDataInterface $objectData) { $objectFactory = $session->getObjectFactory(); $properties = $objectData->getProperties(); // handle properties if (!empty($properties)) { $queryProperties = $objectFactory->convertQueryProperties($properties); foreach ($queryProperties as $queryProperty) { if ($queryProperty->getId() !== null) { $this->propertiesById[$queryProperty->getId()] = $queryProperty; } if ($queryProperty->getQueryName() !== null) { $this->propertiesByQueryName[$queryProperty->getQueryName()] = $queryProperty; } } } // handle allowable actions $allowableActions = $objectData->getAllowableActions(); if ($allowableActions !== null) { $this->allowableActions = $allowableActions; } // handle relationships $relationshipsObjectData = $objectData->getRelationships(); foreach ($relationshipsObjectData as $relationshipObjectData) { $relationship = $objectFactory->convertObject($relationshipObjectData, $session->getDefaultContext()); if ($relationship instanceof RelationshipInterface) { $this->relationships[] = $relationship; } } // handle renditions $renditionsData = $objectData->getRenditions(); foreach ($renditionsData as $renditionData) { $rendition = $objectFactory->convertRendition($objectData->getId(), $renditionData); if ($rendition instanceof RenditionInterface) { $this->renditions[] = $rendition; } } }