Exemple #1
0
 public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
 {
     $identifier = $config->object_identifier->toArray();
     $koowa_component = false;
     if ($config->data) {
         // package comes from the controller add action
         if ($config->data->entity_package) {
             $identifier['package'] = $config->data->entity_package;
         } elseif ($config->data->identifier) {
             try {
                 $temporary = new KObjectIdentifier($config->data->identifier);
                 if ($temporary->type === 'com') {
                     $identifier['package'] = $temporary->package;
                 }
             } catch (KObjectExceptionInvalidIdentifier $e) {
             }
         } elseif ($config->data->dependency) {
             $type = (string) $config->data->dependency['type'];
             if ($type === 'koowa-component') {
                 $koowa_component = true;
             }
         }
         if ($koowa_component || $config->data->type === 'koowa-component') {
             $koowa_component = true;
             $identifier['path'][] = 'extension';
             $identifier['name'] = 'koowa';
         }
     }
     $class = $manager->getClass($identifier);
     if ($class === 'KModelEntityDefault' || !class_exists($class)) {
         $class = $koowa_component ? 'ComExtmanModelEntityExtensionKoowa' : 'ComExtmanModelEntityExtension';
     }
     $instance = new $class($config);
     return $instance;
 }
 /**
  * Create filter and decorate it with KFilterIterator if the filter implements KFilterTraversable
  *
  * @param   KObjectConfigInterface  $config    Configuration options
  * @param   KObjectManagerInterface $manager A KObjectManagerInterface object
  * @return KFilterInterface
  * @see KFilterTraversable
  */
 public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
 {
     //Create the singleton
     $class = $manager->getClass($config->object_identifier);
     $instance = new $class($config);
     if ($instance instanceof KFilterTraversable) {
         $instance = $instance->decorate('lib:filter.iterator');
     }
     return $instance;
 }
Exemple #3
0
 /**
  * Force creation of a singleton
  *
  * @param  KObjectConfigInterface  $config  Configuration options
  * @param  KObjectManagerInterface $manager A KObjectManagerInterface object
  * @return KDispatcherDefault
  */
 public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
 {
     //Merge alias configuration into the identifier
     $config->append($manager->getIdentifier('dispatcher')->getConfig());
     //Create the singleton
     $class = $manager->getClass($config->object_identifier);
     $instance = new $class($config);
     //Add the object alias to allow easy access to the singleton
     $manager->registerAlias($config->object_identifier, 'dispatcher');
     return $instance;
 }
 /**
  * Instantiate the object
  *
  * If the behavior is auto mixed also lazy mix it into related row objects.
  *
  * @param 	KObjectConfigInterface  $config	  A KObjectConfig object with configuration options
  * @param 	KObjectManagerInterface	$manager  A KObjectInterface object
  * @return  KDatabaseBehaviorAbstract
  */
 public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $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'] = KStringInflector::singularize($identifier['name']);
         $manager->registerMixin($identifier, $instance);
     }
     return $instance;
 }
 /**
  * Instantiate the translator and decorate with the cache decorator if cache is enabled.
  *
  * @param   KObjectConfigInterface  $config   A ObjectConfig object with configuration options
  * @param   KObjectManagerInterface	$manager  A ObjectInterface object
  * @return  KTemplateInterface
  */
 public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
 {
     $class = $manager->getClass($config->object_identifier);
     $instance = new $class($config);
     $config = $instance->getConfig();
     if ($config->cache) {
         $class = $manager->getClass('lib:template.cache');
         if (call_user_func(array($class, 'isSupported'))) {
             $instance = $instance->decorate('lib:template.cache');
             $instance->setNamespace($config->cache_namespace);
         }
     }
     return $instance;
 }
 /**
  * Prevent caching
  *
  * Do not decorate the translator with the cache.
  *
  * @param   KObjectConfigInterface  $config   A ObjectConfig object with configuration options
  * @param   KObjectManagerInterface	$manager  A ObjectInterface object
  * @return  $this
  * @see KFilterTraversable
  */
 public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
 {
     $class = $manager->getClass($config->object_identifier);
     return new $class($config);
 }