Ejemplo n.º 1
0
 /**
  * Checks if $this or any parent have an instance of $abstract class, and returns
  * it if found, otherwise returns null.
  *
  * @param  string  $abstract
  * @return object|null
  */
 protected function getInstance($abstract)
 {
     // If an instance of the type is currently being managed as a singleton return it:
     if (isset($this->instances[$abstract])) {
         return $this->instances[$abstract];
     }
     // If not, try all parents:
     if ($this->parent) {
         return $this->parent->getInstance($abstract);
     }
     // Last parent will return null if none found it:
     return null;
 }