/** * Gets the ResourceAssociationSet instance for the given source * association end. * * @param ResourceSet $resourceSet Resource set of the source * association end * @param ResourceType $resourceType Resource type of the source * association end * @param ResourceProperty $resourceProperty Resource property of the source * association end * * @return ResourceAssociationSet */ public function getResourceAssociationSet(ResourceSet $sourceResourceSet, ResourceType $sourceResourceType, ResourceProperty $targetResourceProperty) { //e.g. //ResourceSet => Representing 'Customers' entity set //ResourceType => Representing'Customer' entity type //ResourceProperty => Representing 'Orders' property //We have created ResourceAssoicationSet while adding //ResourceSetReference or ResourceReference //and kept in $this->associationSets //$metadata->addResourceSetReferenceProperty( // $customersEntityType, // 'Orders', // $ordersResourceSet // ); $targetResourceSet = $targetResourceProperty->getResourceType()->getCustomState(); if (is_null($targetResourceSet)) { throw new InvalidOperationException('Failed to retrieve the custom state from ' . $resourceProperty->getResourceType()->getName()); } //Customer_Orders_Orders, Order_Customer_Customers $key = $sourceResourceType->getName() . '_' . $targetResourceProperty->getName() . '_' . $targetResourceSet->getName(); if (array_key_exists($key, $this->associationSets)) { return $this->associationSets[$key]; } return null; }