Example #1
0
 /**
  * Return an array of actor identifiers
  *
  * @return array
  */
 protected static function _findActorIdentifiers(KServiceInterface $container)
 {
     $components = $container->get('repos://admin/components.component')->getQuery()->enabled(true)->fetchSet();
     $components = array_unique($container->get('repos://admin/components.component')->fetchSet()->component);
     $identifiers = array();
     foreach ($components as $component) {
         $path = JPATH_SITE . '/components/' . $component . '/domains/entities';
         if (!file_exists($path)) {
             continue;
         }
         //get all the files
         $files = (array) JFolder::files($path);
         //convert com_<Component> to ['com','<Name>']
         $parts = explode('_', $component);
         $identifier = new KServiceIdentifier('com:' . substr($component, strpos($component, '_') + 1));
         $identifier->path = array('domain', 'entity');
         foreach ($files as $file) {
             $identifier->name = substr($file, 0, strpos($file, '.'));
             try {
                 if (is($identifier->classname, 'ComActorsDomainEntityActor')) {
                     $identifiers[] = clone $identifier;
                 }
             } catch (Exception $e) {
             }
         }
     }
     return $identifiers;
 }
 /**
  * Force creation of a singleton
  *
  * @param KConfigInterface 	$config    An optional KConfig object with configuration options
  * @param KServiceInterface	$container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $query = $container->get('repos://site/components.component')->getQuery();
         $registry = $container->get('application.registry');
         $cached = $registry->offsetExists('assignable-components');
         if ($cached) {
             $query->component($registry->offsetGet('assignable-components'));
         }
         //check the cache
         $container->get('repos://site/components.component')->getCommandChain()->disable();
         $components = $container->get('repos://site/components.component')->fetch($query, AnDomain::FETCH_ENTITY_LIST);
         $container->get('repos://site/components.component')->getCommandChain()->enable();
         if (!$cached) {
             $assignables = array();
             $names = array();
             foreach ($components as $component) {
                 if ($component->isAssignable()) {
                     $names[] = $component->component;
                     $assignables[] = $component;
                 }
             }
             $components = $assignables;
             $registry['assignable-components'] = $names;
         }
         $instance = $container->get('anahita:domain.entityset', array('data' => $components, 'repository' => 'repos://site/components.component'));
         $container->set($config->service_identifier, $instance);
     }
     return $container->get($config->service_identifier);
 }
 /**
  * Force creation of a singleton
  *
  * @param 	object 	An optional KConfig object with configuration options
  * @param 	object	A KServiceInterface object
  * @return ComDebugProfilerEvents
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $instance = new self($config);
         $container->set($config->service_identifier, $instance);
     }
     return $container->get($config->service_identifier);
 }
Example #4
0
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     // Singleton behavior.
     $identifier = $config->service_identifier;
     $classname = $identifier->classname;
     $instance = new $classname($config);
     $container->set($identifier, $instance);
     return $instance;
 }
Example #5
0
 /**
  * Return.
  *
  * @param KConfigInterface  $config    An optional KConfig object with configuration options
  * @param KServiceInterface $container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $identifier = self::_identifier($config->service_identifier);
         $instance = AnDomain::getRepository($identifier, $config->toArray());
         $container->set($config->service_identifier, $instance);
     }
     return $container->get($config->service_identifier);
 }
Example #6
0
 /**
  * Force creation of a singleton.
  *
  * @param KConfigInterface  $config    An optional KConfig object with configuration options
  * @param KServiceInterface $container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     JPluginHelper::importPlugin('storage');
     if (!$container->has($config->service_identifier)) {
         $classname = $config->service_identifier->classname;
         $instance = new PlgStorageLocal($config);
         $container->set($config->service_identifier, $instance);
     }
     return $container->get($config->service_identifier);
 }
Example #7
0
 /**
  * Force creation of a singleton.
  *
  * @param KConfigInterface  $config    An optional KConfig object with configuration options
  * @param KServiceInterface $container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $classname = $config->service_identifier->classname;
         $instance = new $classname($config);
         $container->set($config->service_identifier, $instance);
         $container->setAlias('application.dispatcher', $config->service_identifier);
     }
     return $container->get($config->service_identifier);
 }
Example #8
0
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         //Create the singleton
         $classname = $config->service_identifier->classname;
         $instance = new $classname($config);
         $container->set($config->service_identifier, $instance);
     }
     return $container->get($config->service_identifier);
 }
Example #9
0
 /**
  * Force creation of a singleton.
  *
  * @param KConfigInterface  $config    An optional KConfig object with configuration options
  * @param KServiceInterface $container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $classname = $config->service_identifier->classname;
         $instance = new $classname($config);
         $container->set($config->service_identifier, $instance);
         //Add the service alias to allow easy access to the singleton
         $container->setAlias('component.dispatcher', $config->service_identifier);
     }
     return $container->get($config->service_identifier);
 }
Example #10
0
 /**
  * Force creation of a singleton
  *
  * @param 	object 	An optional KConfig object with configuration options
  * @param 	object	A KServiceInterface object
  * @return KDispatcherDefault
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     // Check if an instance with this identifier already exists or not
     if (!$container->has($config->service_identifier)) {
         //Create the singleton
         $classname = $config->service_identifier->classname;
         $instance = new $classname($config);
         $container->set($config->service_identifier, $instance);
         //Add the factory map to allow easy access to the singleton
         $container->setAlias('dispatcher', $config->service_identifier);
     }
     return $container->get($config->service_identifier);
 }
 /**
  * Check for overrides of the helper
  *
  * @param 	object 	An optional KConfig object with configuration options
  * @param 	object	A KServiceInterface object
  * @return ComActivitiesTemplateHelperActivity
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     $identifier = clone $config->service_identifier;
     $identifier->package = $config->row->package;
     $identifier = $container->getIdentifier($identifier);
     if (file_exists($identifier->filepath)) {
         $classname = $identifier->classname;
     } else {
         $classname = $config->service_identifier->classname;
     }
     $instance = new $classname($config);
     return $instance;
 }
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     $identifier = clone $config->service_identifier;
     if ($config->data && $config->data->identifier) {
         $id = new KServiceIdentifier($config->data->identifier);
         if ($id->type === 'com') {
             $identifier->package = $id->package;
         }
     }
     $identifier = $container->getIdentifier($identifier);
     if ($identifier->classname != 'KDatabaseRowDefault' && class_exists($identifier->classname)) {
         $classname = $identifier->classname;
     } else {
         $classname = 'ComExtmanDatabaseRowExtension';
     }
     $instance = new $classname($config);
     return $instance;
 }
 /**
  * Gets the service identifier.
  *
  * @return	KServiceIdentifier
  * @see 	KObjectServiceable
  */
 public final function getIdentifier($identifier = null)
 {
     if (isset($identifier)) {
         $result = $this->__service_container->getIdentifier($identifier);
     } else {
         $result = $this->__service_identifier;
     }
     return $result;
 }
Example #14
0
 /**
  * Force creation of a singleton
  *
  * @param KConfigInterface 	$config    An optional KConfig object with configuration options
  * @param KServiceInterface	$container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     $strIdentifier = (string) $config->service_identifier;
     $registery = $container->get('application.registry', array('key' => $strIdentifier . '_default_class'));
     if (!$registery->offsetExists($strIdentifier)) {
         try {
             $identifier = clone $config->service_identifier;
             $identifier->type = 'repos';
             $identifier->path = array('domain', 'entity');
             $default = array('prefix' => $container->get($identifier)->getClone(), 'fallback' => 'ComBaseControllerDefault');
         } catch (Exception $e) {
             $default = 'Com' . ucfirst($config->service_identifier->package) . 'ControllerDefault';
             $default = array('default' => array($default, 'ComBaseControllerResource'));
         }
         $default['identifier'] = $config->service_identifier;
         register_default($default);
         $classname = AnServiceClass::findDefaultClass($config->service_identifier);
         $config->service_identifier->classname = $classname;
         $registery->offsetSet($strIdentifier, $classname);
     }
     $classname = $registery->offsetGet($strIdentifier);
     $instance = new $classname($config);
     return $instance;
 }
Example #15
0
 /**
  * Force creation of a singleton
  *
  * @param KConfigInterface 	$config    An optional KConfig object with configuration options
  * @param KServiceInterface	$container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $registry = $container->get('application.registry', array('key' => $config->service_identifier));
         if (!$registry->offsetExists('aggregations')) {
             $components = $container->get('repos://site/components.component')->fetchSet();
             $dispatcher = $container->get('koowa:event.dispatcher');
             $components->registerEventDispatcher($dispatcher);
             $aggregations = new KConfig();
             $event = new KEvent(array('aggregations' => $aggregations));
             $dispatcher->dispatchEvent('onStoryAggregation', $event);
             $registry->offsetSet('aggregations', $aggregations);
         }
         $container->set($config->service_identifier, $registry->offsetGet('aggregations'));
     }
     return $container->get($config->service_identifier);
 }
Example #16
0
 /**
  * Force creation of a singleton.
  *
  * @param KConfigInterface  $config    An optional KConfig object with configuration options
  * @param KServiceInterface $container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $id = JFactory::getUser()->id;
         if (!$id) {
             $viewer = $container->get('repos://site/people.person')->getEntity()->setData(array('userType' => ComPeopleDomainEntityPerson::USERTYPE_GUEST), AnDomain::ACCESS_PROTECTED);
             $viewer->set('id', 0);
             $viewer->getRepository()->extract($viewer);
         } else {
             $viewer = $container->get('repos://site/people.person')->find(array('userId' => $id));
         }
         $container->set($config->service_identifier, $viewer);
     }
     return $container->get($config->service_identifier);
 }
Example #17
0
 /**
  * Force creation of a singleton
  *
  * @param KConfigInterface 	$config    An optional KConfig object with configuration options
  * @param KServiceInterface	$container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $id = JFactory::getUser()->id;
         if (!$id) {
             $viewer = $container->get('repos://site/people.person')->getEntity()->setData(array('userType' => 'Guest'), AnDomain::ACCESS_PROTECTED);
             $viewer->set('id', 0);
             $viewer->getRepository()->extract($viewer);
         } else {
             $viewer = $container->get('repos://site/people.person')->find(array('userId' => $id));
             if (!$viewer) {
                 $viewer = $container->get('com://site/people.helper.person')->createFromUser(JFactory::getUser());
                 $viewer->save();
             }
         }
         $container->set($config->service_identifier, $viewer);
     }
     return $container->get($config->service_identifier);
 }
Example #18
0
 /**
  * Force creation of a singleton
  *
  * @param KConfigInterface 	$config    An optional KConfig object with configuration options
  * @param KServiceInterface	$container A KServiceInterface object
  *
  * @return KServiceInstantiatable
  */
 public static function getInstance(KConfigInterface $config, KServiceInterface $container)
 {
     if (!$container->has($config->service_identifier)) {
         $registry = $container->get('application.registry', array('key' => $config->service_identifier));
         if (!$registry->offsetExists('scopes')) {
             $components = $container->get('repos://site/components.component')->fetchSet();
             $dispatcher = $container->get('koowa:event.dispatcher');
             $components->registerEventDispatcher($dispatcher);
             $event = new KEvent(array('scope' => array()));
             $dispatcher->dispatchEvent('onBeforeFetch', $event);
             $scopes = new self();
             foreach ($event->scope as $scope) {
                 $scope = KConfig::unbox($scope);
                 if (is_array($scope)) {
                     $scope = $container->get('com://site/components.domain.entity.scope', $scope);
                 }
                 $scopes[$scope->getKey()] = $scope;
             }
             $registry->offsetSet('scopes', $scopes);
         }
         $container->set($config->service_identifier, $registry->offsetGet('scopes'));
     }
     return $container->get($config->service_identifier);
 }