Пример #1
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();
 }
Пример #2
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);
     }
 }
Пример #3
0
 public function getLoader()
 {
     if ($this->_loader == null) {
         $this->_loader = new Zend_Loader_PluginLoader();
         $this->_loader->addPrefixPath('Bc_Annotations', 'Bc/Annotations');
     }
     return $this->_loader;
 }
Пример #4
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());
 }
Пример #5
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;
 }
Пример #6
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;
 }
Пример #7
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;
 }
Пример #8
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;
 }
Пример #9
0
 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());
     }
 }
Пример #10
0
 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());
     }
 }
Пример #11
0
 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());
     }
 }
Пример #12
0
 /**
  * _loadContexts() - statically find and load the context files
  *
  */
 protected static function _loadContexts()
 {
     $pluginLoader = new Zend_Loader_PluginLoader(array('Zend_Tool_Provider_ZfProject_ProjectContext_' => dirname(__FILE__) . '/ProjectContext/'));
     $classes = $pluginLoader->loadAll();
     foreach ($classes as $class) {
         $reflectionClass = new ReflectionClass($class);
         if ($reflectionClass->isInstantiable() && $reflectionClass->isSubclassOf('Zend_Tool_Provider_ZfProject_ProjectContext_ProjectContextAbstract')) {
             $context = $reflectionClass->newInstance();
             self::$_contexts[$context->getContextName()] = $context;
         }
     }
 }
Пример #13
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);
 }
Пример #14
0
 public function load()
 {
     $loadedClasses = $this->_pluginLoader->loadAll();
     foreach ($loadedClasses as $className) {
         $reflector = new ReflectionClass($className);
         if ($reflector->isInstantiable() && $reflector->isSubclassOf('Zend_Tool_Provider_Abstract')) {
             $this->addProvider($reflector->newInstance());
             continue;
         }
         if ($reflector->isInstantiable() && ($reflector->getName() == 'Zend_Tool_Provider_Action' || $reflector->isSubclassOf('Zend_Tool_Provider_Action'))) {
             $this->addAction($reflector->newInstance());
             continue;
         }
     }
     return $this;
 }
Пример #15
0
 /**
  * To init the view
  *
  * @return Zend_View $view
  */
 public function init()
 {
     $frontendOptions = array('automatic_serialization' => true, 'lifetime' => 86400);
     $backendOptions = array('cache_dir' => PROJECT_ROOT . '/repository/cache/');
     if ('development' == APPLICATION_ENV) {
         $frontendOptions['caching'] = false;
         //关闭缓存
     } else {
         $classFileIncCache = $backendOptions['cache_dir'] . 'pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
     $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
     //缓存Zend_Db_Table元数据
     Zend_Date::setOptions(array('cache' => $this->_cache));
     //缓存Zend_Date
     Zend_Translate::setCache($this->_cache);
     //缓存Zend_Translate
     Zend_Registry::set('cache', $this->_cache);
     // Return it, so that it can be stored by the bootstrap
     return $this->_cache;
 }
Пример #16
0
 /**
  *
  * Kilka dodatkowych statycznych inicjaliacji
  *
  */
 public function _initStatics()
 {
     $config = $this->getApplication()->getOptions();
     /**
      * Ustawienie konfigu na rejestrze dla kompatybilnosci z poprzednmi rozwiazaniami (resouce plugin dla ACL)
      */
     Zend_Registry::set('config', $config);
     if (isset($config['general']['pluginloader']) and $config['general']['pluginloader']) {
         $classFileIncCache = APPLICATION_PATH . '/../tmp/pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
     /**
      * Ustawienie fallback tak by klasy bez namespacu tez dzialaly
      */
     Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true)->pushAutoloader(NULL, 'Smarty_');
     /**
      * Domyslny rozmiar strony paginatora
      */
     Zend_Paginator::setDefaultItemCountPerPage($config['paginator']['DefaultItemCountPerPage']);
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('/common/paginator_footer.phtml');
     Zend_Controller_Action_HelperBroker::addPrefix('Base_Controller_Action_Helper');
     Zend_Markup::addRendererPath('Logic', 'Logic/');
     Base_Logic_Abstract::setUsePreexecuteHooks($config['general']['usepreexecutehooks']);
 }
 /**
  * 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);
 }
Пример #18
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;
 }
Пример #19
0
 /**
  * Set include file cache
  *
  * @return  void
  */
 public function setIncludeFileCache()
 {
     if ($options = $this->getOptions()) {
         if (is_string($options) && file_exists($options)) {
             include_once $options;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($options);
     }
 }
Пример #20
0
 /**
  * Метод инициализирует кеширование загрузки плагинов приложения.
  *
  * @param string $path
  */
 protected function _initPluginCache($path)
 {
     if (file_exists($path) && is_readable($path)) {
         include $path;
     }
     if (is_writable($path) || is_writable(dirname($path))) {
         Zend_Loader_PluginLoader::setIncludeFileCache($path);
     }
 }
Пример #21
0
 /**
  * Setup include file cache to increase performance
  *
  * @return void
  * @author Jim Li
  */
 protected function _initFileInlcudeCache()
 {
     $classFileIncCacheOptions = $this->getOption('cache');
     $classFileIncCache = $classFileIncCacheOptions['classFileIncludeCache'];
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
 }
Пример #22
0
 protected function _initCachePlugin()
 {
     //Tunning do Zend
     $pathIncCache = APPLICATION_PATH_CACHE . '/cachePlugin';
     $classFileIncCache = $pathIncCache . '/pluginLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
 }
Пример #23
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);
         }
     }
 }
Пример #24
0
 public function init()
 {
     if (!RFLib_Core::getIsDeveloperMode()) {
         $classFileCache = VAR_PATH . DS . self::CACHE_FOLDER . DS . self::CACHE_FILE;
         if (file_exists($classFileCache)) {
             include_once $classFileCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileCache);
     }
 }
Пример #25
0
 /**
  * Configure the pluginloader cache
  */
 protected function X_initPluginLoaderCache()
 {
     if ('production' == $this->getEnvironment()) {
         $classFileIncCache = APPLICATION_PATH . '/../data/cache/pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
 }
Пример #26
0
 protected function _initPluginCache()
 {
     if ($this->getEnvironment() != 'production') {
         return;
     }
     $file = APPLICATION_PATH . '/../data/plugin-cache.php';
     if (file_exists($file)) {
         include_once $file;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($file);
 }
Пример #27
0
 protected function _initAutoLoader()
 {
     $classFileIncCache = APPLICATION_PATH . '/../datas/cache/pluginLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     if ($this->_config->enablePluginLoaderCache) {
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->registerNamespace('Enterprise_');
 }
Пример #28
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;
 }
Пример #29
0
 /**
  * Setup our cache
  */
 protected function _initAppCache()
 {
     $this->bootstrap('cachemanager');
     $metaCache = $this->getResource('cachemanager')->getCache('metadata');
     $dateCache = $this->getResource('cachemanager')->getCache('date');
     Zend_Db_Table_Abstract::setDefaultMetadataCache($metaCache);
     Zend_Date::setOptions(array('cache' => $dateCache));
     if ('production' === $this->getEnvironment()) {
         $classFileIncCache = APPLICATION_PATH . '/tmp/pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
 }
Пример #30
0
 public function _initCache()
 {
     $this->bootstrap('cachemanager');
     $options = $this->getOption('resources');
     if (!$options['cachemanager']['default']['active']) {
         return;
     }
     $cache = $this->getPluginResource('cachemanager')->getCacheManager()->getCache('default');
     $classFileIncCache = APPLICATION_PATH . '/../data/cache/pluginLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Zend_Registry::set('cache', $cache);
 }