/** * Write a navigation property * * @param ResourceType $resourceType Resource type * @param array $associationTypesInResourceTypeNamespace Collection * of association types for the given resource types * array(ResourceAssociatedType) * @param ResourceProperty $navigationProperty Navigation * property * * @throws InvalidOperationException * @return nothing */ private function _writeNavigationProperty(ResourceType $resourceType, $associationTypesInResourceTypeNamespace, ResourceProperty $navigationProperty) { $associationTypeLookupName = $resourceType->getName() . '_' . $navigationProperty->getName(); if (!array_key_exists($associationTypeLookupName, $associationTypesInResourceTypeNamespace)) { throw new InvalidOperationException(Messages::metadataWriterNoResourceAssociationSetForNavigationProperty($navigationProperty->getName(), $resourceType->getName())); } $associationType = $associationTypesInResourceTypeNamespace[$associationTypeLookupName]; $thisEnd = $associationType->getResourceAssociationTypeEnd($resourceType, $navigationProperty); $relatedEnd = $associationType->getRelatedResourceAssociationSetEnd($resourceType, $navigationProperty); $this->_iOdataWriter->startElement(ODataConstants::NAVIGATION_PROPERTY); $this->_iOdataWriter->writeAttribute(ODataConstants::NAME, $navigationProperty->getName()); $this->_iOdataWriter->writeAttribute(ODataConstants::RELATIONSHIP, $associationType->getFullName()); $this->_iOdataWriter->writeAttribute(ODataConstants::FROM_ROLE, $thisEnd->getName()); $this->_iOdataWriter->writeAttribute(ODataConstants::TO_ROLE, $relatedEnd->getName()); $this->_iOdataWriter->endElement(); }