protected function _initPlugins()
 {
     $this->bootstrap('frontController');
     $pluginsLoader = new Zend_Loader_PluginLoader();
     $pluginsLoader->addPrefixPath('Plugin', $this->getResourceLoader()->getBasePath() . '/plugins');
     $pluginsLoader->load("LayoutLoader");
     $pluginsLoader->load("AclUtils");
     if ($pluginsLoader->isLoaded('LayoutLoader')) {
         Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_LayoutLoader());
     }
 }
 protected function _initPlugins()
 {
     $this->bootstrap('frontController');
     $pluginsLoader = new Zend_Loader_PluginLoader();
     $pluginsLoader->addPrefixPath("Plugin", APPLICATION_PATH . '/plugins');
     $pluginsLoader->load("Layout");
     if ($pluginsLoader->isLoaded("Layout")) {
         $front = Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_Layout());
     }
     $pluginsLoader->load("Acl");
     if ($pluginsLoader->isLoaded("Acl")) {
         $front = Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_Acl());
     }
 }
Esempio n. 3
0
 /**
  * 构造函数
  * 
  * @param string $backend
  * @param string $frontend
  * @throws ZtChart_Model_Assemble_Exception
  */
 public function __construct($backend, $frontend = 'PHPArray')
 {
     $loader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Assemble_Backend_' => realpath(__DIR__ . '/Assemble/Backend'), 'ZtChart_Model_Assemble_Frontend_' => realpath(__DIR__ . '/Assemble/Frontend')));
     $backendName = is_array($backend) ? key($backend) : $backend;
     if (false === ($backendClass = $loader->load($backendName, false))) {
         throw new ZtChart_Model_Assemble_Exception("Specified backend class '{$backendName}' could not be found");
     }
     $this->_backend = new $backendClass($backend);
     $frontendName = is_array($frontend) ? key($frontend) : $frontend;
     if (false === ($frontendClass = $loader->load($frontendName, false))) {
         throw new ZtChart_Model_Assemble_Exception("Specified frontend class '{$frontendName}' could not be found");
     }
     $this->_frontend = new $frontendClass($frontend);
 }
Esempio n. 4
0
 /**
  * Load ACL classes from Brightfame Framework
  *
  * @return void
  */
 protected function _loadAclClasses()
 {
     $loader = new Zend_Loader_PluginLoader(array('Brightfame_Acl_Role' => APPLICATION_PATH . '/../library/Brightfame/Acl/Role/'));
     foreach (array('Guest', 'Member', 'Administrator') as $role) {
         $loader->load($role);
     }
 }
 /**
  * Load a form with the provided options.
  *
  * @param string            $name    The name of the form to be loaded
  * @param array|Zend_Config $options Options to be passed to the form
  *                                   constructor.
  *
  * @return Zend_Form
  */
 public function loadForm($name, $options = null)
 {
     $module = $this->getRequest()->getModuleName();
     $front = $this->getFrontController();
     $default = $front->getDispatcher()->getDefaultModule();
     if (empty($module)) {
         $module = $default;
     }
     $moduleDirectory = $front->getControllerDirectory($module);
     $formsDirectory = dirname($moduleDirectory) . '/forms';
     $prefix = ('default' == $module ? '' : ucfirst($module) . '_') . 'Form_';
     $this->pluginLoader->addPrefixPath($prefix, $formsDirectory);
     $name = ucfirst((string) $name);
     $formClass = $this->pluginLoader->load($name);
     return new $formClass($options);
 }
 public function _initPlugins()
 {
     $this->bootstrap('frontController');
     $pluginsLoader = new Zend_Loader_PluginLoader();
     $pluginsLoader->addPrefixPath("Plugin", APPLICATION_PATH . '/plugins');
     $pluginsLoader->load("PageModule");
     if ($pluginsLoader->isLoaded('PageModule')) {
         Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_PageModule());
     }
 }
Esempio n. 7
0
 /**
  * 构造函数
  * 
  * @param string $daemon
  * @param array|Zend_Config $config
  * @param ZtChart_Model_Monitor_Console $console
  */
 public function __construct($daemon, $config = array(), ZtChart_Model_Monitor_Console $console = null)
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     }
     if (null === $console) {
         $console = ZtChart_Model_Monitor_Console::getInstance();
     }
     $loader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Monitor_Daemon' => realpath(__DIR__ . '/Monitor/Daemon')));
     if (false === ($daemonClass = $loader->load($daemon, false))) {
         throw new ZtChart_Model_Monitor_Exception("Specified daemon class '{$daemon}' could not be found.");
     } else {
         if (!is_subclass_of($daemonClass, 'ZtChart_Model_Monitor_Daemon_Abstract')) {
             throw new ZtChart_Model_Monitor_Exception("Specified daemon class '{$daemon}' is illegal.");
         } else {
             $this->_daemon = new $daemonClass($console, $config);
         }
     }
 }
Esempio n. 8
0
 /**
  * Lazy-load a validator
  *
  * @param  array $validator Validator definition
  * @return Zend_Validate_Interface
  * @see Zend_Form_Element::loadValidator() (function from Zend_Form_Element borrowed and modified)
  */
 protected function loadValidator(array $validator)
 {
     $origName = $validator['name'];
     $name = $this->pluginLoader->load($validator['name']);
     if (array_key_exists($name, $this->validators)) {
         throw new Webdesktop_Model_Exception(sprintf('Validator instance already exists for validator "%s"', $origName));
     }
     if (empty($validator['options'])) {
         $instance = new $name();
     } else {
         $r = new ReflectionClass($name);
         if ($r->hasMethod('__construct')) {
             $instance = $r->newInstanceArgs((array) $validator['options']);
         } else {
             $instance = $r->newInstance();
         }
     }
     $this->validators[$origName] = $instance;
     return $instance;
 }
Esempio n. 9
0
 /**
  * Returns an manipulator instance based on its name.
  *
  * @param string $manipulator
  * @return Gem_Manipulator_Adapter_Interface
  */
 public static function getManipulatorInstance($manipulator)
 {
     $args = array();
     if (is_array($manipulator)) {
         $args = $manipulator;
         $manipulator = array_shift($args);
     }
     // TODO: Move to allow other plugins...
     $loader = new Zend_Loader_PluginLoader();
     $loader->addPrefixPath('Yag_Manipulator_Adapter', 'Yag/Manipulator/Adapter/');
     $className = $loader->load($manipulator);
     $class = new ReflectionClass($className);
     if (!$class->implementsInterface('Yag_Manipulator_Adapter_Interface')) {
         require_once 'Yag/Manipulator/Exception.php';
         throw new Gem_Manipulator_Exception('Manipulator must implement interface "Yag_Manipulator_Adapter_Interface".');
     }
     if ($class->hasMethod('__construct')) {
         $object = $class->newInstanceArgs($args);
     } else {
         $object = $class->newInstance();
     }
     return $object;
 }
Esempio n. 10
0
 /**
  * It loads plugins.
  * @param Zend_Config $method
  */
 protected function setupPlugins($method)
 {
     if (empty($this->_loadedPlugins) && !empty($this->_plugins)) {
         foreach ($this->_plugins as $pluginName => $options) {
             try {
                 $classname = $this->_pluginLoader->load($pluginName);
                 $r = new ReflectionClass($classname);
                 if ($r->isSubclassOf('App_Rest_Plugin_Abstract')) {
                     $this->_loadedPlugins[$pluginName] = new $classname($this, $method, $options);
                 } else {
                     unset($this->_plugins[$pluginName]);
                     $this->log(sprintf("Loading plugin %s.Class %s is not a App_Rest_Plugin_Abstract descendent", $pluginName, $classname), Zend_Log::CRIT);
                 }
             } catch (Zend_Loader_PluginLoader_Exception $e) {
                 $this->log($e->getMessage(), Zend_Log::CRIT);
             }
         }
     } else {
         foreach ($this->_loadedPlugins as $plugin) {
             $plugin->setRestMethod($method);
         }
     }
     return $this;
 }
 public function testClassFilesAreSearchedInLifoOrder()
 {
     $loader = new Zend_Loader_PluginLoader(array());
     $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper');
     $loader->addPrefixPath('ZfTest', dirname(__FILE__) . '/_files/ZfTest');
     try {
         $className = $loader->load('FormSubmit');
     } catch (Exception $e) {
         $paths = $loader->getPaths();
         $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
     }
     $this->assertEquals($className, $loader->getClassName('FormSubmit'));
     $this->assertEquals('ZfTest_FormSubmit', $loader->getClassName('FormSubmit'));
 }
Esempio n. 12
0
 /**
  * 工厂方法,返回指定游戏的在线人数日志数据表对象
  * 
  * @param integer $gameType
  * @param string $datetime
  * @param mixed $config
  * @return ZtChart_Model_DbTable_Infoserver
  */
 public static function factory($gameType, $datetime = null, $config = array())
 {
     $loader = new Zend_Loader_PluginLoader(array(__CLASS__ => realpath(__DIR__ . '/Infoserver')));
     if (false !== ($class = $loader->load(ZtChart_Model_GameType::getShortName($gameType), false))) {
         $infoserver = new $class($gameType, $datetime, $config);
     } else {
         $infoserver = new self($gameType, $datetime, $config);
     }
     return $infoserver;
 }
Esempio n. 13
0
 /**
  * @group ZF-7350
  */
 public function testPrefixesEndingInBackslashDenoteNamespacedClasses()
 {
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         $this->markTestSkipped(__CLASS__ . '::' . __METHOD__ . ' requires PHP 5.3.0 or greater');
         return;
     }
     $loader = new Zend_Loader_PluginLoader(array());
     $loader->addPrefixPath('Zfns\\', dirname(__FILE__) . '/_files/Zfns');
     try {
         $className = $loader->load('Foo');
     } catch (Exception $e) {
         $paths = $loader->getPaths();
         $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
     }
     $this->assertEquals('Zfns\\Foo', $className);
     $this->assertEquals('Zfns\\Foo', $loader->getClassName('Foo'));
 }
Esempio n. 14
0
 /**
  * 取得Auth适配器
  * 
  * @param string $adapter
  * @return Zend_Auth_Adapter_Interface
  */
 protected function _getAdapter($adapter = null)
 {
     if (empty($adapter)) {
         $adapter = $this->_adapter;
     }
     $pluginLoader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Auth_Adapter_' => realpath(__DIR__ . '/../models/Auth/Adapter'), 'Zend_Auth_Adapter_' => 'Zend/Auth/Adapter'));
     if (false === ($adapterClass = $pluginLoader->load($adapter, false))) {
         throw new Zend_Application_Resource_Exception("Specified Auth Adapter '{$adapter}' could not be found");
     }
     return new $adapterClass();
 }
Esempio n. 15
0
 /**
  * init additional plugins
  *
  * @return void
  */
 protected function _initPlugins()
 {
     // get front controller instance
     $front = Zend_Controller_Front::getInstance();
     // create loader
     $loader = new Zend_Loader_PluginLoader();
     $loader->addPrefixPath('Plugin', Zend_Registry::get('config')->resources->frontController->pluginsDirectory);
     $pluginAuthentication = $loader->load('Authentication');
     // register plugin
     $front->registerPlugin(new $pluginAuthentication());
 }
Esempio n. 16
0
 /**
  * @issue ZF-2741
  */
 public function testWin32UnderscoreSpacedShortNamesWillLoad()
 {
     $loader = new Zend_Loader_PluginLoader(array());
     $loader->addPrefixPath('Zend_Filter', $this->libPath . '/Zend/Filter');
     try {
         // Plugin loader will attempt to load "c:\path\to\library/Zend/Filter/Word\UnderscoreToDash.php"
         $className = $loader->load('Word_UnderscoreToDash');
     } catch (Exception $e) {
         $paths = $loader->getPaths();
         $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
     }
     $this->assertEquals($className, $loader->getClassName('Word_UnderscoreToDash'));
 }
Esempio n. 17
0
if (strpos($type, '_') === false) {
    $type = 'Spizer_Logger_' . $type;
}
Zend_Loader::loadClass($type);
$logger = new $type($config->logger->options->toArray());
$engine->setLogger($logger);
// Set up the handler objects - same underscore rules apply here as well.
$handlerLoader = new Zend_Loader_PluginLoader(array('Spizer_Handler_' => 'Spizer/Handler', 'Kumo_Handler' => 'Kumo/Handler'));
if ($config->handlers) {
    foreach ($config->handlers as $name => $hconf) {
        $type = $hconf->type;
        if (!$type) {
            continue;
        }
        // Silenty ignore badly-defined loggers (@todo: Throw exception?)
        $handlerClass = $handlerLoader->load($type);
        $handler = new $handlerClass($hconf->options->toArray());
        $handler->setHandlerName($name);
        $engine->addHandler($handler);
    }
}
// If we have pcntl - set up a handler for sigterm
if (function_exists('pcntl_signal')) {
    declare (ticks=1);
    pcntl_signal(SIGABRT, 'do_exit');
    pcntl_signal(SIGHUP, 'do_exit');
    pcntl_signal(SIGQUIT, 'do_exit');
    pcntl_signal(SIGINT, 'do_exit');
    pcntl_signal(SIGTERM, 'do_exit');
}
// Go!
Esempio n. 18
0
 public function load($name, $throwExceptions = true)
 {
     $formatedName = $this->_formatName($name);
     if ($this->isCached($formatedName)) {
         return $this->getClassName($formatedName);
     }
     //        if (false !== ($className = $this->getClassName($formatedName))) {
     //            return $className;
     //        }
     $result = parent::load($formatedName, $throwExceptions);
     self::_cache($formatedName, $result, $this->getClassPath($name));
     return $result;
 }
Esempio n. 19
0
 /**
  * Load a model class and return an object instance
  * 
  * @param  string $model 
  * @return object
  */
 public function getModel($model)
 {
     $class = $this->_loader->load($model);
     return new $class();
 }
Esempio n. 20
0
 /**
  * Set validation options
  *
  * @return void
  */
 private function _setDojoValidationOptions()
 {
     foreach ($this->getElements() as $elementName => $element) {
         foreach ($element->getValidators() as $validatorName => $validatorItem) {
             // apply required if validor is NotEmpty
             if ($validatorItem instanceof Zend_Validate_NotEmpty) {
                 $element->setRequired(true);
             }
             // get real type for field
             $type = null;
             if ($element instanceof ZLayer_Dojo_Form_Element_CustomElementDijit) {
                 if (isset($this->_options->elements->{$elementName}->validator)) {
                     $type = ucfirst($this->_options->elements->{$elementName}->validator);
                 }
             } else {
                 $typeArray = explode("_", $element->getType());
                 $type = end($typeArray);
             }
             if (!$type) {
                 continue;
             }
             // load the adapter of validator
             $loader = new Zend_Loader_PluginLoader();
             $loader->addPrefixPath('ZLayer_Dojo_Form_Validator_' . $type, 'ZLayer/Dojo/Form/Validator/' . $type);
             $validatorNameArray = explode("_", $validatorName);
             $validatorKey = end($validatorNameArray);
             $plugin = ucfirst($validatorKey);
             if ($class = $loader->load(ucfirst($plugin), false)) {
                 $adapter = new $class($validatorItem);
                 if ($adapterArray = $adapter->getDojoOptions()) {
                     $element->setOptions($adapterArray);
                 }
             }
         }
     }
 }
Esempio n. 21
0
 /**
  * @url https://github.com/zendframework/zf1/issues/152
  */
 public function testLoadClassesWithBackslashAndUnderscoreInName()
 {
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         $this->markTestSkipped(__CLASS__ . '::' . __METHOD__ . ' requires PHP 5.3.0 or greater');
         return;
     }
     $loader = new Zend_Loader_PluginLoader(array());
     $loader->addPrefixPath('Zfns\\Foo_', dirname(__FILE__) . '/_files/Zfns/Foo');
     try {
         $className = $loader->load('Demo');
     } catch (Exception $e) {
         $this->fail(sprintf("Failed loading helper with backslashes and underscores in name"));
     }
     $this->assertEquals('Zfns\\Foo_Demo', $className);
 }