예제 #1
0
 /**
  * Force creation of a singleton
  *
  * @param 	ObjectConfig            $config	  A ObjectConfig object with configuration options
  * @param 	ObjectManagerInterface	$manager  A ObjectInterface object
  * @return DispatcherRequest
  */
 public static function getInstance(ObjectConfig $config, ObjectManagerInterface $manager)
 {
     if (!$manager->isRegistered('user.session')) {
         $classname = $config->object_identifier->classname;
         $instance = new $classname($config);
         $manager->setObject($config->object_identifier, $instance);
         $manager->registerAlias('user.session', $config->object_identifier);
     }
     return $manager->getObject('user.session');
 }
예제 #2
0
 /**
  * Create filter and decorate it with FilterIterator if the filter implements FilterTraversable
  *
  * @param   ObjectConfigInterface  $config    Configuration options
  * @param   ObjectManagerInterface $manager A ObjectManagerInterface object
  * @return FilterInterface
  * @see FilterTraversable
  */
 public static function getInstance(ObjectConfigInterface $config, ObjectManagerInterface $manager)
 {
     //Create the singleton
     $class = $manager->getClass($config->object_identifier);
     $instance = new $class($config);
     if ($instance instanceof FilterTraversable) {
         $instance = $instance->decorate('lib:filter.iterator');
     }
     return $instance;
 }
예제 #3
0
 /**
  * Force creation of a singleton
  *
  * @param   ObjectConfig            $config   A ObjectConfig object with configuration options
  * @param   ObjectManagerInterface  $manager  A ObjectInterface object
  * @return  DispatcherInterface
  */
 public static function getInstance(ObjectConfigInterface $config, ObjectManagerInterface $manager)
 {
     //Add the object alias to allow easy access to the singleton
     $manager->registerAlias($config->object_identifier, 'dispatcher.fragment');
     //Merge alias configuration into the identifier
     $config->append($manager->getIdentifier('dispatcher.fragment')->getConfig());
     //Instantiate the class
     $instance = new static($config);
     return $instance;
 }
예제 #4
0
 /**
  * Force creation of a singleton
  *
  * @param 	ObjectConfig            $config	  A ObjectConfig object with configuration options
  * @param 	ObjectManagerInterface	$manager  A ObjectInterface object
  * @return DispatcherComponent
  */
 public static function getInstance(ObjectConfig $config, ObjectManagerInterface $manager)
 {
     if (!$manager->isRegistered($config->object_identifier)) {
         $classname = $config->object_identifier->classname;
         $instance = new $classname($config);
         $manager->setObject($config->object_identifier, $instance);
         //Add the service alias to allow easy access to the singleton
         $manager->registerAlias('component', $config->object_identifier);
     }
     return $manager->getObject($config->object_identifier);
 }
예제 #5
0
 /**
  * Instantiate the object
  *
  * If the behavior is auto mixed also lazy mix it into related row objects.
  *
  * @param 	ObjectConfig            $config	  A ObjectConfig object with configuration options
  * @param 	ObjectManagerInterface	$manager  A ObjectInterface object
  * @return  DatabaseBehaviorAbstract
  */
 public static function getInstance(ObjectConfig $config, ObjectManagerInterface $manager)
 {
     $classname = $config->object_identifier->classname;
     $instance = new $classname($config);
     //If the behavior is auto mixed also lazy mix it into related row objects.
     if ($config->auto_mixin) {
         $identifier = clone $instance->getMixer()->getIdentifier();
         $identifier->path = array('database', 'row');
         $identifier->name = StringInflector::singularize($identifier->name);
         $manager->registerMixin($identifier, $instance);
     }
     return $instance;
 }
예제 #6
0
 /**
  * Instantiate the object
  *
  * If the behavior is auto mixed also lazy mix it into related row objects.
  *
  * @param 	ObjectConfigInterface  $config	  A ObjectConfig object with configuration options
  * @param 	ObjectManagerInterface	$manager  A ObjectInterface object
  * @return  DatabaseBehaviorAbstract
  */
 public static function getInstance(ObjectConfigInterface $config, ObjectManagerInterface $manager)
 {
     $class = $manager->getClass($config->object_identifier);
     $instance = new $class($config);
     //Lazy mix behavior into related row objects. A supported behavior always has one is[Behaviorable] method.
     if ($instance->isSupported() && $instance->getMixer() && count($instance->getMixableMethods()) > 1) {
         $identifier = $instance->getMixer()->getIdentifier()->toArray();
         $identifier['path'] = array('database', 'row');
         $identifier['name'] = StringInflector::singularize($identifier['name']);
         $manager->registerMixin($identifier, $instance);
     }
     return $instance;
 }
예제 #7
0
 /**
  * Instantiate the translator and decorate with the cache decorator if cache is enabled.
  *
  * @param   ObjectConfigInterface  $config   A ObjectConfig object with configuration options
  * @param   ObjectManagerInterface	$manager  A ObjectInterface object
  * @return  TranslatorInterface
  */
 public static function getInstance(ObjectConfigInterface $config, ObjectManagerInterface $manager)
 {
     $class = $manager->getClass($config->object_identifier);
     $instance = new $class($config);
     $config = $instance->getConfig();
     if ($config->cache) {
         $class = $manager->getClass('lib:translator.cache');
         if (call_user_func(array($class, 'isSupported'))) {
             $instance = $instance->decorate('lib:translator.cache');
             $instance->setNamespace($config->cache_namespace);
         }
     }
     return $instance;
 }
예제 #8
0
 /**
  * Force creation of a singleton
  *
  * @param 	ObjectConfig            $config	  A ObjectConfig object with configuration options
  * @param 	ObjectManagerInterface	$manager  A ObjectInterface object
  * @return DispatcherRequest
  */
 public static function getInstance(ObjectConfig $config, ObjectManagerInterface $manager)
 {
     if (!$manager->isRegistered('dispatcher.response')) {
         //Create the singleton
         $classname = $config->object_identifier->classname;
         $instance = new $classname($config);
         $manager->setObject($config->object_identifier, $instance);
         //Add the object alias to allow easy access to the singleton
         $manager->registerAlias('dispatcher.response', $config->object_identifier);
         $manager->registerAlias('response', 'dispatcher.response');
     }
     return $manager->getObject('dispatcher.response');
 }
예제 #9
0
 /**
  * Create Url instance with specified parameters
  *
  * @param array $data
  * @return UrlInterface
  */
 public function create(array $data = [])
 {
     return $this->_objectManager->create($this->_instanceName, $data);
 }