diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-01-08 19:59:07 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-01-08 19:59:07 +0000 |
| commit | 886b77daa151baff5435671d4ed5ba22ff96b9d6 (patch) | |
| tree | d3a1666b71f59d85da1d21ca0e8c4f8de538fd50 /app/Family.php | |
| parent | fa17fb661badda9494ff1a7acdc88293a3ff4572 (diff) | |
| download | webtrees-886b77daa151baff5435671d4ed5ba22ff96b9d6.tar.gz webtrees-886b77daa151baff5435671d4ed5ba22ff96b9d6.tar.bz2 webtrees-886b77daa151baff5435671d4ed5ba22ff96b9d6.zip | |
Use closures to DRY up code
Diffstat (limited to 'app/Family.php')
| -rw-r--r-- | app/Family.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/Family.php b/app/Family.php index 7e469b0b5a..0f740f35de 100644 --- a/app/Family.php +++ b/app/Family.php @@ -17,7 +17,9 @@ declare(strict_types=1); namespace Fisharebest\Webtrees; +use Closure; use Illuminate\Database\Capsule\Manager as DB; +use stdClass; /** * A GEDCOM family (FAM) object. @@ -61,6 +63,20 @@ class Family extends GedcomRecord } /** + * A closure which will create a record from a database row. + * + * @param Tree $tree + * + * @return Closure + */ + public static function rowMapper(Tree $tree): Closure + { + return function (stdClass $row) use ($tree): Family { + return Family::getInstance($row->f_id, $tree, $row->f_gedcom); + }; + } + + /** * Get an instance of a family object. For single records, * we just receive the XREF. For bulk records (such as lists * and search results) we can receive the GEDCOM data as well. |
