Beispiel #1
0
 public static function factory(Zend_Db_Adapter_Abstract $adapter, $options = array())
 {
     list($prefix, $type) = explode('_Db_Adapter_', get_class($adapter));
     $class = 'Khcn' . '_Db_Export_' . $type;
     Khcn_Loader::loadClass($class);
     $instance = new $class($adapter, $options);
     if (!$instance instanceof Engine_Db_Export) {
         throw new Khcn_Exception('Must be an instance of Engine_Db_Export');
     }
     return $instance;
 }
Beispiel #2
0
 public function __construct($options)
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     if (!is_array($options)) {
         // require_once 'Zend/Loader/Exception.php';
         throw new Zend_Loader_Exception('Options must be passed to resource loader constructor');
     }
     $this->setOptions($options);
     $namespace = $this->getNamespace();
     if (null === $namespace || null === $this->getBasePath()) {
         // require_once 'Zend/Loader/Exception.php';
         throw new Zend_Loader_Exception('Resource loader requires both a namespace and a base path for initialization');
     }
     if (!empty($namespace)) {
         $namespace .= '_';
     }
     Khcn_Loader::getInstance()->register(trim($namespace, '_'), $this->getBasePath());
     //Zend_Loader_Autoloader::getInstance()->unshiftAutoloader($this, $namespace);
 }
Beispiel #3
0
 public function __construct($application, $options = null)
 {
     // Set application
     $this->setApplication($application);
     // Set custom module options (for dynamic bootstrapping)
     if (is_array($options)) {
         $this->setOptions($options);
     }
     // Use same plugin loader as parent bootstrap
     if ($application instanceof Zend_Application_Bootstrap_ResourceBootstrapper) {
         $this->setPluginLoader($application->getPluginLoader());
     }
     // Get the options from config
     $key = strtolower($this->getModuleName());
     if ($application->hasOption($key)) {
         // Don't run via setOptions() to prevent duplicate initialization
         $this->setOptions($application->getOption($key));
     }
     // Init resource loader
     if ($application->hasOption('resourceloader')) {
         $this->setOptions(array('resourceloader' => $application->getOption('resourceloader')));
     }
     //$this->initResourceLoader();
     Khcn_Loader::getInstance()->register($this->getModuleName(), $this->getModulePath());
     $isDefaultModule = get_class($this->getApplication()) === 'Zend_Application';
     // ZF-6545: ensure front controller resource is loaded
     if (!$isDefaultModule && !$this->hasPluginResource('FrontController')) {
         $this->registerPluginResource('FrontController');
     }
     // ZF-6545: prevent recursive registration of modules
     if (!$isDefaultModule && $this->hasPluginResource('Modules')) {
         $this->unregisterPluginResource('Modules');
     }
     // Register with Engine_Api
     Khcn_Api::_()->setModuleBootstrap($this);
     // Run internal hook
     $this->preBootstrap();
 }
Beispiel #4
0
 /**
  * Loads a singleton instance of a module resource using a full class name
  *
  * @param string $class The class name
  * @return mixed The requested singleton object
  */
 public function loadClass($class)
 {
     return Khcn_Loader::getInstance()->load($class);
 }
Beispiel #5
0
 /**
  * Get the loader object
  * 
  * @return Engine_Loader
  */
 public function getAutoloader()
 {
     if (null === $this->_autoloader) {
         $this->_autoloader = Khcn_Loader::getInstance();
     }
     return $this->_autoloader;
 }
Beispiel #6
0
 /**
  * Set current loader instance
  * 
  * @param Engine_Loader $loader
  */
 public static function setInstance(Khcn_Loader $loader = null)
 {
     self::$_instance = $loader;
 }