コード例 #1
0
ファイル: template.php プロジェクト: stonyyi/anahita
 /**
  * Get the classname based on an identifier.
  *
  * @param 	mixed  		 An identifier object - koowa:[path].name
  *
  * @return string|false Return object on success, returns FALSE on failure
  */
 public function findClass(KServiceIdentifier $identifier)
 {
     $classname = 'Tmpl' . ucfirst($identifier->package) . KInflector::implode($identifier->path) . ucfirst($identifier->name);
     if (!$this->getService('koowa:loader')->loadClass($classname, $identifier->basepath)) {
         $classname = AnServiceClass::findDefaultClass($identifier);
         if (!$classname) {
             //$path      = KInflector::implode($identifier->path);
             $classpath = $identifier->path;
             $classtype = !empty($classpath) ? array_shift($classpath) : '';
             //Create the fallback path and make an exception for views
             $path = $classtype != 'view' ? ucfirst($classtype) . KInflector::camelize(implode('_', $classpath)) : ucfirst($classtype);
             $classes[] = 'Tmpl' . ucfirst($identifier->package) . $path . ucfirst($identifier->name);
             $classes[] = 'Tmpl' . ucfirst($identifier->package) . $path . 'Default';
             $classes[] = 'ComApplication' . $path . ucfirst($identifier->name);
             $classes[] = 'ComApplication' . $path . 'Default';
             $classes[] = 'LibApplication' . $path . ucfirst($identifier->name);
             $classes[] = 'LibApplication' . $path . 'Default';
             $classes[] = 'LibBase' . $path . ucfirst($identifier->name);
             $classes[] = 'LibBase' . $path . 'Default';
             $classes[] = 'K' . $path . ucfirst($identifier->name);
             $classes[] = 'K' . $path . 'Default';
             foreach ($classes as $class) {
                 if ($this->getService('koowa:loader')->loadClass($class, $identifier->basepath)) {
                     $classname = $class;
                     break;
                 }
             }
             if ($classname) {
                 AnServiceClass::setDefaultClass($identifier, $classname);
             }
         }
     }
     return $classname;
 }
コード例 #2
0
ファイル: anahita.php プロジェクト: stonyyi/anahita
 /**
  * Get the classname based on an identifier.
  *
  * @param 	mixed  		 An identifier object - koowa:[path].name
  *
  * @return string|false Return object on success, returns FALSE on failure
  */
 public function findClass(KServiceIdentifier $identifier)
 {
     $classname = 'An' . ucfirst($identifier->package) . KInflector::implode($identifier->path) . ucfirst($identifier->name);
     if (!class_exists($classname)) {
         $classname = AnServiceClass::findDefaultClass($identifier);
         if (!$classname) {
             // use default class instead
             $classname = 'An' . ucfirst($identifier->package) . KInflector::implode($identifier->path) . 'Default';
             if (!class_exists($classname)) {
                 $classname = false;
             }
         }
     }
     return $classname;
 }
コード例 #3
0
ファイル: component.php プロジェクト: walteraries/anahita
 /**
  * Get the classname based on an identifier
  *
  * @param 	mixed  		 An identifier object - koowa:[path].name
  * @return string|false  Return object on success, returns FALSE on failure
  */
 public function findClass(KServiceIdentifier $identifier)
 {
     $path = KInflector::camelize(implode('_', $identifier->path));
     $classname = 'Com' . ucfirst($identifier->package) . $path . ucfirst($identifier->name);
     $loader = $this->getService('koowa:loader');
     //Manually load the class to set the basepath
     if (!$loader->loadClass($classname, $identifier->basepath)) {
         //the default can be in either in the default folder
         //be a registered default class
         $classname = AnServiceClass::findDefaultClass($identifier);
         //hack
         if ($classname == 'AnDomainBehaviorDefault') {
             $classname = null;
         }
         if (!$classname) {
             $classname = $this->_findClass($identifier);
         }
     }
     return $classname;
 }
コード例 #4
0
ファイル: anahita.php プロジェクト: walteraries/anahita
 /**
  * Constructor
  *
  * Prevent creating instances of this class by making the contructor private
  *
  * @param  array  An optional array with configuration options.
  */
 private final function __construct($config = array())
 {
     //store the path
     $this->_path = dirname(__FILE__);
     //instantiate koowa
     Koowa::getInstance(array('cache_prefix' => $config['cache_prefix'], 'cache_enabled' => $config['cache_enabled']));
     //if caching is not enabled then reset the apc cache to
     //to prevent corrupt identifier
     if (!$config['cache_enabled']) {
         clean_apc_with_prefix($config['cache_prefix']);
     }
     require_once dirname(__FILE__) . '/loader/adapter/anahita.php';
     KLoader::addAdapter(new AnLoaderAdapterAnahita(array('basepath' => dirname(__FILE__))));
     KLoader::addAdapter(new AnLoaderAdapterDefault(array('basepath' => JPATH_LIBRARIES . '/default')));
     AnServiceClass::getInstance();
     KServiceIdentifier::addLocator(new AnServiceLocatorAnahita());
     KServiceIdentifier::addLocator(new AnServiceLocatorRepository());
     //register an empty path for the application
     //a workaround to remove the applicaiton path from an identifier
     KServiceIdentifier::setApplication('', '');
     //create a central event dispatcher
     KService::set('anahita:event.dispatcher', KService::get('koowa:event.dispatcher'));
 }
コード例 #5
0
ファイル: default.php プロジェクト: walteraries/anahita
 /**
  * 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;
 }
コード例 #6
0
ファイル: class.php プロジェクト: stonyyi/anahita
 /**
  * Constructor.
  *
  * Prevent creating instances of this class by making the contructor private
  */
 private final function __construct(KConfig $config)
 {
     //Create the identifier registry
     self::$_defaults = new ArrayObject();
 }