Skip to content

FamilyTree::getLocation

James Cobban edited this page Jan 4, 2021 · 3 revisions

$tree->getLocation($idir)

Up: class FamilyTree

This is a factory method to get an instance of class Location. It takes one parameter:

parameter description
$idlr the value of field 'idlr' or 'location'

This returns a shared instance of class Location which is identified by the value of 'idlr' or 'location'. This differs from new Location(array('idlr' => $idlr)) or new Location(array('location' => $idlr)) in that if the current application process has previously created an instance of class Location for that value of 'idlr' or 'location' by calling $tree->getLocation($idlr) then $tree->getLocation($idlr) returns that existing instance rather than creating a new instance.

This has two advantages:

  1. If the current thread has previously created an instance then this is much faster than creating a new entry, which would, among other things, require reading the record from the database again.
  2. If all parts of the application use $tree->getLocation($idlr) then all parts of the application will be using the same copy of the object and all changes made by any part of the application will be reflected when the instance is saved.

This method invokes the static class function Location::getLocation($idlr).

Next: $tree->getFamily($idmr)

Clone this wiki locally