Пример #1
0
 /**
  * Register a class for an identifier
  *
  * @param  ObjectIdentifier|string $identifier An ObjectIdentifier, identifier string
  * @param string                   $class      The class
  * @return ObjectRegistry
  */
 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);
 }
Пример #2
0
 /**
  * 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;
 }