/** * Add a new relationship to the collection * * @param \Gedcomx\Conclusion\Relationship $relationship * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return \Gedcomx\Rs\Client\RelationshipState|null * @throws GedcomxApplicationException */ public function addRelationship(Relationship $relationship, StateTransitionOption $option = null) { if ($relationship->getKnownType() == RelationshipType::PARENTCHILD) { throw new GedcomxApplicationException("FamilySearch Family Tree doesn't support adding parent-child relationships. You must instead add a child-and-parents relationship."); } return parent::addRelationship($relationship); }
/** * Read the relative given by a specific relationship definition * * @param \Gedcomx\Conclusion\Relationship $relationship * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... * * @return \Gedcomx\Rs\Client\PersonState|null */ public function readRelative(Relationship $relationship, StateTransitionOption $option = null) { $reference = null; if ($this->refersToMe($relationship->getPerson1())) { $reference = $relationship->getPerson2(); } elseif ($this->refersToMe($relationship->getPerson2())) { $reference = $relationship->getPerson1(); } if ($reference == null || $reference->getResource() == null) { return null; } $request = $this->createAuthenticatedGedcomxRequest('GET', $reference->getResource()); return $this->stateFactory->createState('PersonState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Creates a parent child relationship for the specified persons. * * * @param \Gedcomx\Conclusion\Person $parent * @param \Gedcomx\Conclusion\Person $child * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $options * * @return mixed */ public function addParentChildRelationship(Person $parent, Person $child, StateTransitionOption $options = null) { $relationship = new Relationship(); $relationship->setPerson1(new ResourceReference($parent->getSelfUri())); $relationship->setPerson2(new ResourceReference($child->getSelfUri())); $relationship->setKnownType(RelationshipType::COUPLE); return $this->addRelationship($relationship, $options); }
/** * Removes the specified relationship. * * @param \Gedcomx\Conclusion\Relationship $relationship * @param \Gedcomx\Rs\Client\Options\StateTransitionOption|null $option,... * * @return \Gedcomx\Rs\Client\RelationshipState * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException */ public function removeRelationship(Relationship $relationship, StateTransitionOption $option = null) { $link = $relationship->getLink(Rel::RELATIONSHIP); if ($link == null) { $link = $relationship->getLink(Rel::SELF); } if ($link == null || $link->getHref() == null) { throw new GedcomxApplicationException("Unable to remove relationship: missing link."); } $request = $this->createAuthenticatedGedcomxRequest('DELETE', $link->getHref()); return $this->stateFactory->createState("RelationshipState", $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }
/** * Adds a parent child relationship between the two persons and applies the specified fact. * * @param PersonState $parent * @param PersonState $child * @param Fact $fact * @param StateTransitionOption $option,... * * @return RelationshipState|null */ public function AddParentChildRelationship(PersonState $parent, PersonState $child, Fact $fact = null, StateTransitionOption $option = null) { $relationship = new Relationship(); $relationship->setPerson1(new ResourceReference($parent->getSelfUri())); $relationship->setPerson2(new ResourceReference($child->getSelfUri())); $relationship->setKnownType(RelationshipType::PARENTCHILD); if ($fact != null) { $relationship->addFact($fact); } return $this->passOptionsTo('addRelationship', array($relationship), func_get_args()); }
/** * Instantiates a new relationship and only sets the relationship ID to the current relationship's ID. * @return \Gedcomx\Conclusion\Relationship */ protected function createEmptySelf() { $relationship = new Relationship(); $relationship->setId($this->getLocalSelfId()); return $relationship; }