FamilyTree::getSource - jcobban/Genealogy GitHub Wiki

$tree->getSource($idsr)

Up: class FamilyTree

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

parameter description
$idsr the value of field "idsr"

This returns a shared instance of class Source which is identified by the value of "idsr". This differs from new Source(array('idsr' => $idsr)) in that if the current application process has previously created an instance of class Source for that value of $idsr by calling $tree->getSource($idsr) then $tree->getSource($idsr) 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->getSource($idsr) 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.

Next: $tree->getCitation($idsx)