public static function resolveByRef(ResourceReference $ref, Gedcomx $document)
 {
     if ($ref->getResource() == null) {
         return null;
     }
     return GedcomxLocalReferenceResolver::resolveByString($ref->getResource(), $document);
 }
Пример #2
0
 /**
  * Writes the contents of this Relationship to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->type) {
         $writer->writeAttribute('type', $this->type);
     }
     parent::writeXmlContents($writer);
     if ($this->person1) {
         $writer->startElementNs('gx', 'person1', null);
         $this->person1->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->person2) {
         $writer->startElementNs('gx', 'person2', null);
         $this->person2->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->facts) {
         foreach ($this->facts as $i => $x) {
             $writer->startElementNs('gx', 'fact', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Пример #3
0
 /**
  * Writes the contents of this ChangeInfo to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents($writer)
 {
     if ($this->objectModifier) {
         $writer->writeAttribute('objectModifier', $this->objectModifier);
     }
     if ($this->operation) {
         $writer->writeAttribute('operation', $this->operation);
     }
     if ($this->reason) {
         $writer->writeAttribute('reason', $this->reason);
     }
     if ($this->objectType) {
         $writer->writeAttribute('objectType', $this->objectType);
     }
     if ($this->original) {
         $writer->startElementNs('fs', 'original', null);
         $this->original->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->parent) {
         $writer->startElementNs('fs', 'parent', null);
         $this->parent->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->removed) {
         $writer->startElementNs('fs', 'removed', null);
         $this->removed->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->resulting) {
         $writer->startElementNs('fs', 'resulting', null);
         $this->resulting->writeXmlContents($writer);
         $writer->endElement();
     }
 }
 /**
  * Writes the contents of this ChildAndParentsRelationship to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     parent::writeXmlContents($writer);
     if ($this->father) {
         $writer->startElementNs('fs', 'father', null);
         $this->father->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->mother) {
         $writer->startElementNs('fs', 'mother', null);
         $this->mother->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->child) {
         $writer->startElementNs('fs', 'child', null);
         $this->child->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->fatherFacts) {
         foreach ($this->fatherFacts as $i => $x) {
             $writer->startElementNs('fs', 'fatherFact', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->motherFacts) {
         foreach ($this->motherFacts as $i => $x) {
             $writer->startElementNs('fs', 'motherFact', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Пример #5
0
 /**
  * Writes the contents of this MergeAnalysis to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents($writer)
 {
     if ($this->survivorResources) {
         foreach ($this->survivorResources as $i => $x) {
             $writer->startElementNs('fs', 'survivorResource', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->duplicateResources) {
         foreach ($this->duplicateResources as $i => $x) {
             $writer->startElementNs('fs', 'duplicateResource', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->conflictingResources) {
         foreach ($this->conflictingResources as $i => $x) {
             $writer->startElementNs('fs', 'conflictingResource', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->survivor) {
         $writer->startElementNs('fs', 'survivor', null);
         $this->survivor->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->duplicate) {
         $writer->startElementNs('fs', 'duplicate', null);
         $this->duplicate->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Пример #6
0
 /**
  * Writes the contents of this Conclusion to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->confidence) {
         $writer->writeAttribute('confidence', $this->confidence);
     }
     if ($this->lang) {
         $writer->writeAttribute('xml:lang', $this->lang);
     }
     parent::writeXmlContents($writer);
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sources) {
         foreach ($this->sources as $i => $x) {
             $writer->startElementNs('gx', 'source', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->analysis) {
         $writer->startElementNs('gx', 'analysis', null);
         $this->analysis->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->notes) {
         foreach ($this->notes as $i => $x) {
             $writer->startElementNs('gx', 'note', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Пример #7
0
 /**
  * Writes the contents of this Agent to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     parent::writeXmlContents($writer);
     if ($this->accounts) {
         foreach ($this->accounts as $i => $x) {
             $writer->startElementNs('gx', 'account', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->addresses) {
         foreach ($this->addresses as $i => $x) {
             $writer->startElementNs('gx', 'address', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->emails) {
         foreach ($this->emails as $i => $x) {
             $writer->startElementNs('gx', 'email', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->homepage) {
         $writer->startElementNs('gx', 'homepage', null);
         $this->homepage->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->identifiers) {
         foreach ($this->identifiers as $i => $x) {
             $writer->startElementNs('gx', 'identifier', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->names) {
         foreach ($this->names as $i => $x) {
             $writer->startElementNs('gx', 'name', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->openid) {
         $writer->startElementNs('gx', 'openid', null);
         $this->openid->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->phones) {
         foreach ($this->phones as $i => $x) {
             $writer->startElementNs('gx', 'phone', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Пример #8
0
 /**
  * Writes the contents of this MergeConflict to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents($writer)
 {
     if ($this->survivorResource) {
         $writer->startElementNs('fs', 'survivorResource', null);
         $this->survivorResource->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->duplicateResource) {
         $writer->startElementNs('fs', 'duplicateResource', null);
         $this->duplicateResource->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Пример #9
0
 /**
  * Writes the contents of this OnlineAccount to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     parent::writeXmlContents($writer);
     if ($this->accountName) {
         $writer->startElementNs('gx', 'accountName', null);
         $writer->text($this->accountName);
         $writer->endElement();
     }
     if ($this->serviceHomepage) {
         $writer->startElementNs('gx', 'serviceHomepage', null);
         $this->serviceHomepage->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Пример #10
0
 /**
  * Writes the contents of this EventRole to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->type) {
         $writer->writeAttribute('type', $this->type);
     }
     parent::writeXmlContents($writer);
     if ($this->person) {
         $writer->startElementNs('gx', 'person', null);
         $this->person->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->details) {
         $writer->startElementNs('gx', 'details', null);
         $writer->text($this->details);
         $writer->endElement();
     }
 }
Пример #11
0
 /**
  * Writes the contents of this PlaceDescription to an XML writer. The startElement is expected to be already
  * provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->type) {
         $writer->writeAttribute('type', $this->type);
     }
     parent::writeXmlContents($writer);
     if ($this->names) {
         foreach ($this->names as $i => $x) {
             $writer->startElementNs('gx', 'name', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->temporalDescription) {
         $writer->startElementNs('gx', 'temporalDescription', null);
         $this->temporalDescription->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->latitude) {
         $writer->startElementNs('gx', 'latitude', null);
         $writer->text($this->latitude);
         $writer->endElement();
     }
     if ($this->longitude) {
         $writer->startElementNs('gx', 'longitude', null);
         $writer->text($this->longitude);
         $writer->endElement();
     }
     if ($this->spatialDescription) {
         $writer->startElementNs('gx', 'spatialDescription', null);
         $this->spatialDescription->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->jurisdiction) {
         $writer->startElementNs('gx', 'jurisdiction', null);
         $this->jurisdiction->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->displayExtension) {
         $writer->startElementNs('gx', 'display', null);
         $this->displayExtension->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Пример #12
0
 /**
  * Writes the contents of this Comment to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     parent::writeXmlContents($writer);
     if ($this->text) {
         $writer->startElementNs('fs', 'text', null);
         $writer->text($this->text);
         $writer->endElement();
     }
     if ($this->created) {
         $writer->startElementNs('fs', 'created', null);
         $writer->text($this->created);
         $writer->endElement();
     }
     if ($this->contributor) {
         $writer->startElementNs('fs', 'contributor', null);
         $this->contributor->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Пример #13
0
 /**
  * Writes the contents of this Discussion to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     parent::writeXmlContents($writer);
     if ($this->title) {
         $writer->startElementNs('fs', 'title', null);
         $writer->text($this->title);
         $writer->endElement();
     }
     if ($this->details) {
         $writer->startElementNs('fs', 'details', null);
         $writer->text($this->details);
         $writer->endElement();
     }
     if ($this->created) {
         $writer->startElementNs('fs', 'created', null);
         $writer->text($this->created);
         $writer->endElement();
     }
     if ($this->contributor) {
         $writer->startElementNs('fs', 'contributor', null);
         $this->contributor->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->modified) {
         $writer->startElementNs('fs', 'modified', null);
         $writer->text($this->modified);
         $writer->endElement();
     }
     if ($this->numberOfComments) {
         $writer->startElementNs('fs', 'numberOfComments', null);
         $writer->text($this->numberOfComments);
         $writer->endElement();
     }
     if ($this->comments) {
         foreach ($this->comments as $i => $x) {
             $writer->startElementNs('fs', 'comment', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Пример #14
0
 /**
  * Writes the contents of this SourceCitation to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->lang) {
         $writer->writeAttribute('xml:lang', $this->lang);
     }
     parent::writeXmlContents($writer);
     if ($this->citationTemplate) {
         $writer->startElementNs('gx', 'citationTemplate', null);
         $this->citationTemplate->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->value) {
         $writer->startElementNs('gx', 'value', null);
         $writer->text($this->value);
         $writer->endElement();
     }
 }
Пример #15
0
 /**
  * Check a resource reference to see if its URI is the same as this person.
  *
  * @param ResourceReference|null $ref
  *
  * @return bool
  */
 protected function refersToMe(ResourceReference $ref = null)
 {
     return $ref != null && $ref->getResource() != null && $ref->getResource() == "#" . $this->getLocalSelfId();
 }
Пример #16
0
 /**
  * Writes the contents of this SourceDescription to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->about) {
         $writer->writeAttribute('about', $this->about);
     }
     if ($this->mediaType) {
         $writer->writeAttribute('mediaType', $this->mediaType);
     }
     if ($this->resourceType) {
         $writer->writeAttribute('resourceType', $this->resourceType);
     }
     parent::writeXmlContents($writer);
     if ($this->citations) {
         foreach ($this->citations as $i => $x) {
             $writer->startElementNs('gx', 'citation', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->mediator) {
         $writer->startElementNs('gx', 'mediator', null);
         $this->mediator->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sources) {
         foreach ($this->sources as $i => $x) {
             $writer->startElementNs('gx', 'source', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->analysis) {
         $writer->startElementNs('gx', 'analysis', null);
         $this->analysis->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->componentOf) {
         $writer->startElementNs('gx', 'componentOf', null);
         $this->componentOf->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->titles) {
         foreach ($this->titles as $i => $x) {
             $writer->startElementNs('gx', 'title', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->titleLabel) {
         $writer->startElementNs('gx', 'titleLabel', null);
         $this->titleLabel->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->notes) {
         foreach ($this->notes as $i => $x) {
             $writer->startElementNs('gx', 'note', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sortKey) {
         $writer->startElementNs('gx', 'sortKey', null);
         $writer->text($this->sortKey);
         $writer->endElement();
     }
     if ($this->descriptions) {
         foreach ($this->descriptions as $i => $x) {
             $writer->startElementNs('gx', 'description', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->identifiers) {
         foreach ($this->identifiers as $i => $x) {
             $writer->startElementNs('gx', 'identifier', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->created) {
         $writer->startElementNs('gx', 'created', null);
         $writer->text($this->created);
         $writer->endElement();
     }
     if ($this->modified) {
         $writer->startElementNs('gx', 'modified', null);
         $writer->text($this->modified);
         $writer->endElement();
     }
     if ($this->coverage) {
         foreach ($this->coverage as $i => $x) {
             $writer->startElementNs('gx', 'coverage', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->rights) {
         foreach ($this->rights as $i => $x) {
             $writer->startElementNs('gx', 'rights', null);
             $writer->text($x);
             $writer->endElement();
         }
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->repository) {
         $writer->startElementNs('gx', 'repository', null);
         $this->repository->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->descriptorRef) {
         $writer->startElementNs('gx', 'descriptor', null);
         $this->descriptorRef->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Пример #17
0
 /**
  * @link https://familysearch.org/developers/docs/api/sources/Move_Sources_to_a_User-Defined_Collection_usecase
  */
 public function testMoveSourcesToAUserDefinedCollection()
 {
     $factory = new FamilySearchStateFactory();
     /** @var FamilySearchCollectionState $collection */
     $collection = $this->collectionState($factory, "https://sandbox.familysearch.org/platform/collections/sources");
     $sd = new SourceDescription();
     $citation = new SourceCitation();
     $citation->setValue("\"United States Census, 1900.\" database and digital images, FamilySearch (https://familysearch.org/: accessed 17 Mar 2012), Ethel Hollivet, 1900; citing United States Census Office, Washington, D.C., 1900 Population Census Schedules, Los Angeles, California, population schedule, Los Angeles Ward 6, Enumeration District 58, p. 20B, dwelling 470, family 501, FHL microfilm 1,240,090; citing NARA microfilm publication T623, roll 90.");
     $sd->setCitations(array($citation));
     $title = new TextValue();
     $title->setValue("1900 US Census, Ethel Hollivet");
     $sd->setTitles(array($title));
     $note = new Note();
     $note->setText("Ethel Hollivet (line 75) with husband Albert Hollivet (line 74); also in the dwelling: step-father Joseph E Watkins (line 72), mother Lina Watkins (line 73), and grandmother -- Lina's mother -- Mary Sasnett (line 76).  Albert's mother and brother also appear on this page -- Emma Hollivet (line 68), and Eddie (line 69).");
     $sd->setNotes(array($note));
     $attribution = new Attribution();
     $contributor = new ResourceReference();
     $contributor->setResource("https://familysearch.org/platform/users/agents/MM6M-8QJ");
     $contributor->setResourceId("MM6M-8QJ");
     $attribution->setContributor($contributor);
     $attribution->setModified(time());
     $attribution->setChangeMessage("This is the change message");
     $sd->SetAttribution($attribution);
     /** @var FamilySearchSourceDescriptionState $description */
     $description = $collection->addSourceDescription($sd);
     $this->queueForDelete($description);
     $this->assertEquals(HttpStatus::CREATED, $description->getResponse()->getStatusCode());
     $description = $description->get();
     $this->assertEquals(HttpStatus::OK, $description->getResponse()->getStatusCode());
     /** @var CollectionState $subcollection */
     $c = new Collection();
     $c->setTitle($this->faker->sha1);
     $subcollection = $collection->addCollection($c)->get();
     $this->queueForDelete($subcollection);
     /** @var FamilySearchSourceDescriptionState $state */
     $state = $description->moveToCollection($subcollection);
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals(HttpStatus::NO_CONTENT, $state->getResponse()->getStatusCode());
     // Ensure it doesn't exist in the old collection
     $rootCollection = $this->getRootCollection($collection);
     $found = $this->findInCollection($description->getSourceDescription(), $rootCollection->readSourceDescriptions()->getEntity()->getSourceDescriptions());
     $this->assertFalse($found);
     // Ensure it exists in the new collection
     $found = $this->findInCollection($description->getSourceDescription(), $subcollection->readSourceDescriptions()->getEntity()->getSourceDescriptions());
     $this->assertTrue($found);
 }
Пример #18
0
 /**
  * @return \Gedcomx\Source\SourceDescription
  */
 private function createSourceDescription()
 {
     $sd = new SourceDescription();
     $citation = new SourceCitation();
     $citation->setValue("\"United States Census, 1900.\" database and digital images, FamilySearch (https://familysearch.org/: accessed 17 Mar 2012), Ethel Hollivet, 1900; citing United States Census Office, Washington, D.C., 1900 Population Census Schedules, Los Angeles, California, population schedule, Los Angeles Ward 6, Enumeration District 58, p. 20B, dwelling 470, family 501, FHL microfilm 1,240,090; citing NARA microfilm publication T623, roll 90.");
     $sd->setCitations(array($citation));
     $title = new TextValue();
     $title->setValue("1900 US Census, Ethel Hollivet");
     $sd->setTitles(array($title));
     $note = new Note();
     $note->setText("Ethel Hollivet (line 75) with husband Albert Hollivet (line 74); also in the dwelling: step-father Joseph E Watkins (line 72), mother Lina Watkins (line 73), and grandmother -- Lina's mother -- Mary Sasnett (line 76).  Albert's mother and brother also appear on this page -- Emma Hollivet (line 68), and Eddie (line 69).");
     $sd->setNotes(array($note));
     $attribution = new Attribution();
     $rr = new ResourceReference();
     $rr->setResource("https://familysearch.org/platform/users/agents/MM6M-8QJ");
     $rr->setResourceId("MM6M-8QJ");
     $attribution->setContributor($rr);
     $attribution->setModified(time());
     $attribution->setChangeMessage("This is the change message");
     $sd->setAttribution($attribution);
     return $sd;
 }
Пример #19
0
 /**
  * Reads the contributor for the specified resource reference.
  *
  * @param \Gedcomx\Common\ResourceReference                $contributor
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return \Gedcomx\Rs\Client\AgentState|null
  */
 public function readReferenceContributor(ResourceReference $contributor, StateTransitionOption $option = null)
 {
     if ($contributor == null || $contributor->getResource() == null) {
         return null;
     }
     $request = $this->createAuthenticatedGedcomxRequest('GET', $contributor->getResource());
     return $this->stateFactory->createState('AgentState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }