diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2020-02-22 10:44:56 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2020-02-22 17:47:19 +0000 |
| commit | 62b528492872caeb9d5163134f093b6a4f132a89 (patch) | |
| tree | 98acf8ab83d9e537c8234b587009906093a44eda /app/Fact.php | |
| parent | cbc90a9374adadb0cd722132cd1a399748184c7f (diff) | |
| download | webtrees-62b528492872caeb9d5163134f093b6a4f132a89.tar.gz webtrees-62b528492872caeb9d5163134f093b6a4f132a89.tar.bz2 webtrees-62b528492872caeb9d5163134f093b6a4f132a89.zip | |
Use specific class
Diffstat (limited to 'app/Fact.php')
| -rw-r--r-- | app/Fact.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/Fact.php b/app/Fact.php index 92a5ab296b..7326d11472 100644 --- a/app/Fact.php +++ b/app/Fact.php @@ -219,19 +219,30 @@ class Fact /** * Get the record to which this fact links * - * @return Individual|Family|Source|Repository|Media|Note|GedcomRecord|null + * @return Individual|Family|Source|Submitter|Repository|Media|Note|GedcomRecord|null */ public function target() { - $xref = trim($this->value(), '@'); + if (!preg_match('/^@(' . Gedcom::REGEX_XREF . ')@$/', $this->value(), $match)) { + return null; + } + + $xref = $match[1]; + switch ($this->tag) { case 'FAMC': case 'FAMS': return Family::getInstance($xref, $this->record()->tree()); case 'HUSB': case 'WIFE': + case 'ALIA': case 'CHIL': + case '_ASSO': return Individual::getInstance($xref, $this->record()->tree()); + case 'ASSO': + return + Individual::getInstance($xref, $this->record()->tree()) ?? + Submitter::getInstance($xref, $this->record()->tree()); case 'SOUR': return Source::getInstance($xref, $this->record()->tree()); case 'OBJE': @@ -240,6 +251,8 @@ class Fact return Repository::getInstance($xref, $this->record()->tree()); case 'NOTE': return Note::getInstance($xref, $this->record()->tree()); + case 'ANCI': + case 'DESI': case 'SUBM': return Submitter::getInstance($xref, $this->record()->tree()); default: |
