/** * Creates a relationship between the persons specified in the relationship parameter. * * @param \Gedcomx\Conclusion\Relationship $relationship * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $options,... * * @return RelationshipState */ public function addRelationship(Relationship $relationship, StateTransitionOption $options = null) { $entity = new Gedcomx(); $entity->addRelationship($relationship); $request = $this->createAuthenticatedGedcomxRequest('POST', $this->getSelfUri(), [], null, $entity->toJson()); return $this->stateFactory->createState('RelationshipState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Adds relationship to the collection. * * @param Relationship|Gedcomx $relationship * @param StateTransitionOption $option,... * * @throws GedcomxApplicationException * @return RelationshipState|null */ public function addRelationship(Relationship $relationship, StateTransitionOption $option = null) { $link = $this->getLink(Rel::RELATIONSHIPS); if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException(sprintf("Collection at %s doesn't support adding relationships.", $this->getUri())); } $entity = new Gedcomx(); $entity->addRelationship($relationship); $request = $this->createAuthenticatedGedcomxRequest('POST', $link->getHref(), [], null, $entity->toJson()); return $this->stateFactory->createState('RelationshipState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }