Exemple #1
0
 public function getLoader()
 {
     if ($this->_loader == null) {
         $this->_loader = new Zend_Loader_PluginLoader();
         $this->_loader->addPrefixPath('Bc_Annotations', 'Bc/Annotations');
     }
     return $this->_loader;
 }
Exemple #2
0
 /**
  * Get plugin loader
  * 
  * @return Zend_Loader_PluginLoader
  */
 public function getPluginLoader()
 {
     if (null === $this->_loader) {
         $this->_loader = new Zend_Loader_PluginLoader();
         $this->_loader->addPrefixPath('Model_Table', dirname(__FILE__) . '/Table/');
     }
     return $this->_loader;
 }
 public function addPrefixToPaths($prefix, $path = null)
 {
     if (is_array($prefix)) {
         $prefixToPaths = $prefix;
     } else {
         $prefixToPaths = array($prefix => $path);
     }
     foreach ($prefixToPaths as $prefix => $path) {
         $this->_pluginLoader->addPrefixPath($prefix, $path);
     }
     return $this;
 }
 protected function _initPlugins()
 {
     $this->bootstrap('frontController');
     $pluginsLoader = new Zend_Loader_PluginLoader();
     $pluginsLoader->addPrefixPath('Plugin', $this->getResourceLoader()->getBasePath() . '/plugins');
     $pluginsLoader->load("AclAdmin");
     //$pluginsLoader->load("SessionAdmin");
     //$pluginsLoader->load("Acl");
     $pluginsLoader->addPrefixPath('Plugin', APPLICATION_PATH . '/plugins');
     $pluginsLoader->load("LayoutLoader");
     if ($pluginsLoader->isLoaded('LayoutLoader')) {
         Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_LayoutLoader());
     }
 }
Exemple #5
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $sysCache = $registry->get("sysCache");
     $cacheFiles = new Ml_Cache_Files($sysCache);
     Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/controllers/helpers');
     $frontController = $this->getBootstrap()->getResource('FrontController');
     $dispatcher = $frontController->getDispatcher();
     $request = $frontController->getRequest();
     $router = $frontController->getRouter();
     $router->removeDefaultRoutes();
     //@todo remove this patched route module and use the original instead ASAP
     $compat = new Ml_Controller_Router_Route_Module(array(), $dispatcher, $request);
     $router->addRoute("default", $compat);
     $routerConfig = $cacheFiles->getConfigIni(APPLICATION_PATH . '/configs/' . HOST_MODULE . 'Routes.ini');
     $router->addConfig($routerConfig, "routes");
     $frontController->registerPlugin(new Ml_Plugins_ReservedUsernames());
     Zend_Controller_Action_HelperBroker::getStaticHelper("Redirector")->setPrependBase(false);
     $frontController->setBaseUrl($config['webroot']);
     $loader = new Zend_Loader_PluginLoader();
     $loader->addPrefixPath('Zend_View_Helper', EXTERNAL_LIBRARY_PATH . '/Zend/View/Helper/')->addPrefixPath('Ml_View_Helper', APPLICATION_PATH . '/views/helpers');
     $classFileIncCache = CACHE_PATH . '/PluginDefaultLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         require $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     $viewRenderer->initView();
 }
 /**
  * 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);
 }
 /**
  * Options setter.
  * @param array|Zend_Config $options
  */
 public function setOptions($options)
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     if (is_array($options)) {
         if (isset($options['restApi']) && !$options['restApi'] instanceof Zend_Config) {
             $options['restApi'] = new Zend_Config($options['restApi']);
         }
         if (isset($options['pluginPath']) && is_array($options['pluginPath'])) {
             foreach ($options['pluginPath'] as $key => $pluginPathData) {
                 if (is_array($pluginPathData) && isset($pluginPathData['path']) && isset($pluginPathData['prefix'])) {
                     $this->_pluginLoader->addPrefixPath($pluginPathData['prefix'], $pluginPathData['path']);
                 }
             }
             unset($options['pluginPath']);
         }
         foreach ($options as $key => $value) {
             $method = 'set' . ucfirst($key);
             if (method_exists($this, $method)) {
                 $this->{$method}($value);
             } else {
                 $this->log(sprintf("No set method for option %s.", $key), Zend_Log::WARN);
             }
         }
     }
     return $this;
 }
Exemple #8
0
 /**
  * Returns the table loader for this instance.
  * @return Zend_Loader_PluginLoader
  */
 protected function getTableLoader()
 {
     if (!isset($this->_tableLoader)) {
         $this->_tableLoader = new Zend_Loader_PluginLoader();
         $this->_tableLoader->addPrefixPath('Hmd_Db_Model_Table', 'Hmd/Db/Model/Table');
     }
     return $this->_tableLoader;
 }
Exemple #9
0
 /**
  * Load system module plugins
  */
 public function _initPlugins()
 {
     $loader = new Zend_Loader_PluginLoader();
     $loader->addPrefixPath('System_Plugin', 'application/modules/system/plugins/');
     $this->bootstrap('frontController');
     $front = $this->getResource('frontController');
     $front->registerPlugin(new System_Plugin_Router());
 }
Exemple #10
0
 /**
  * Get plugin loader
  *
  * @return Zend_Loader_PluginLoader_Interface
  */
 public static function getPluginLoader()
 {
     if (self::$pluginLoader == null) {
         $pluginLoader = new Zend_Loader_PluginLoader();
         $pluginLoader->addPrefixPath(__CLASS__, 'System/Serializer/Dom');
         self::$pluginLoader = $pluginLoader;
     }
     return self::$pluginLoader;
 }
Exemple #11
0
 /**
  * Get plugin loader
  *
  * @return Zend_Loader_PluginLoader_Interface
  */
 public static function getPluginLoader()
 {
     if (self::$pluginLoader == null) {
         $pluginLoader = new Zend_Loader_PluginLoader();
         $pluginLoader->addPrefixPath(str_replace('Abstract', '', __CLASS__), dirname(__FILE__));
         self::$pluginLoader = $pluginLoader;
     }
     return self::$pluginLoader;
 }
Exemple #12
0
 /**
  * Get plugin loader
  *
  * @return Zend_Loader_PluginLoader_Interface
  */
 public static function getPluginLoader()
 {
     if (self::$pluginLoader == null) {
         $pluginLoader = new Zend_Loader_PluginLoader();
         $pluginLoader->addPrefixPath('System_Acl_Loader', 'System/Acl/Loader');
         self::$pluginLoader = $pluginLoader;
     }
     return self::$pluginLoader;
 }
 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());
     }
 }
 protected function _initPlugins()
 {
     $this->bootstrap('frontController');
     $pluginsLoader = new Zend_Loader_PluginLoader();
     $pluginsLoader->addPrefixPath("Plugin", APPLICATION_PATH . '/plugins');
     $front = Zend_Controller_Front::getInstance();
     $pluginsLoader->load("Redirect");
     if ($pluginsLoader->isLoaded("Redirect")) {
         $front->registerPlugin(new Plugin_Redirect());
     }
 }
Exemple #15
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;
 }
 /**
  * Returns a default adapter plugin loader
  *
  * @return Zend_Loader_PluginLoader
  */
 protected static function _getDefaultAdapterLoader()
 {
     $loader = new Zend_Loader_PluginLoader();
     $loader->addPrefixPath('Zend_Serializer_Adapter', dirname(__FILE__) . '/Serializer/Adapter');
     return $loader;
 }
 /**
  * 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());
 }
Exemple #18
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'));
 }
 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'));
 }
Exemple #20
0
 /**
  * Plugin loader plugin for front controller
  * @return void
  */
 protected function _initPluginLoader()
 {
     $loader = new Zend_Loader_PluginLoader();
     $loader->addPrefixPath('Extzf_Controller_Plugin', LIBRARY_PATH . '/Extzf/Controller/Plugin');
     Zend_Registry::set('PluginLoader', $loader);
 }
Exemple #21
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'));
 }
 /**
  * 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);
                 }
             }
         }
     }
 }
Exemple #23
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);
 }