/** * Check if an object instance was registered for the identifier * * @param mixed $identifier An object that implements the ObjectInterface, an ObjectIdentifier or valid identifier string * @return boolean Returns TRUE on success or FALSE on failure. */ public function isRegistered($identifier) { try { $object = $this->_registry->get($this->getIdentifier($identifier)); //If the object implements ObjectInterface we have registered an object if ($object instanceof ObjectInterface) { $result = true; } else { $result = false; } } catch (ObjectExceptionInvalidIdentifier $e) { $result = false; } return $result; }
/** * Get an instance of a class based on a class identifier * * @param ObjectIdentifier $identifier * @param bool $fallback Use fallbacks when locating the class. Default is TRUE. * @return string Return the identifier class or FALSE on failure. */ protected function _locate(ObjectIdentifier $identifier, $fallback = true) { $class = $this->__registry->getClass($identifier); //If the class is FALSE we have tried to locate it already, do not locate it again. if (empty($class) && $class !== false) { $class = $this->_locators[$identifier->getType()]->locate($identifier, $fallback); //If we are falling back set the class in the registry if ($fallback) { if (!$this->__registry->get($identifier) instanceof ObjectInterface) { $this->__registry->setClass($identifier, $class); } } } return $class; }