/** * Register a class for an identifier * * @param KObjectIdentifier|string $identifier An ObjectIdentifier, identifier string * @param string $class The class * @return KObjectRegistry */ public function setClass($identifier, $class) { $identifier = (string) $identifier; if (parent::offsetExists($identifier)) { $data = array('identifier' => parent::offsetGet($identifier), 'class' => $class); apc_store($this->getNamespace() . '-object_' . $identifier, $data); } return parent::setClass($identifier, $class); }
/** * Get an instance of a class based on a class identifier * * @param KObjectIdentifier $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(KObjectIdentifier $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 ($class !== false) { //Set loader basepath if we are locating inside an application if ($this->isRegistered('object.bootstrapper')) { if ($path = $this->getObject('object.bootstrapper')->getApplicationPath($identifier->domain)) { $this->getClassLoader()->setBasePath($path); } } if (empty($class)) { $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 KObjectInterface) { $this->__registry->setClass($identifier, $class); } } } } return $class; }