Ejemplo n.º 1
0
 /**
  * Adds the array of relationships to the collection.
  *
  * @param array                 $relationships
  * @param StateTransitionOption $option,...
  *
  * @return RelationshipState
  * @throws GedcomxApplicationException
  */
 public function addRelationships(array $relationships, StateTransitionOption $option = null)
 {
     $link = $this->getLink(Rel::RELATIONSHIPS);
     if (link == null || link . getHref() == null) {
         throw new GedcomxApplicationException(String . format("Collection at %s doesn't support adding relationships.", getUri()));
     }
     $entity = new Gedcomx();
     $entity->setRelationships($relationships);
     $request = $this->createAuthenticatedGedcomxRequest('POST', $link->getHref());
     return $this->stateFactory->createState('RelationshipsState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
Ejemplo n.º 2
0
 /**
  * Updates the specified relationship.
  *
  * @param \Gedcomx\Conclusion\Relationship                 $relationship
  * @param                                                  $rel
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return mixed
  */
 protected function updateRelationship(Relationship $relationship, $rel, StateTransitionOption $option = null)
 {
     $target = $this->getSelfUri();
     $link = $this->getLink($rel);
     if ($link != null && $link->getHref() != null) {
         $target = $link->getHref();
     }
     $gx = new Gedcomx();
     $gx->setRelationships(array($relationship));
     /** @var $request EntityEnclosingRequest */
     $request = $this->createAuthenticatedGedcomxRequest('POST', $target, [], null, $gx->toJson());
     return $this->stateFactory->createState('RelationshipState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }