/** * Based heavily on Zend_Application->_loadConfig * Load configuration file of options. * * @param string $file * @throws Zend_Application_Exception When invalid configuration file is provided * @return array */ protected function _loadConfig($file) { if (!Zend_Loader::isReadable($file)) { return; } $environment = $this->_bootstrap->getApplication()->getEnvironment(); $suffix = strtolower(pathinfo($file, PATHINFO_EXTENSION)); switch ($suffix) { case 'ini': $config = new Zend_Config_Ini($file, $environment); break; case 'xml': $config = new Zend_Config_Xml($file, $environment); break; case 'php': case 'inc': $config = (include $file); if (!is_array($config)) { throw new Zend_Application_Exception('Invalid configuration file provided; PHP file does not return array value'); } return $config; default: throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type'); break; } return $config->toArray(); }
public function run() { // Cela permet d'avoir le fichier de configuration disponible depuis n'importe ou dans l'application. Zend_Registry::set('config', new Zend_Config($this->getOptions())); exit; parent::run(); }
/** * Constructor * * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application * @return void */ public function __construct($application) { parent::__construct($application); // Force dispatcher initialization. It must be loaded as soon as possible, // before any other _init*() kicks in, as other resources may depend on it. $this->_initDispatcher(); }
public function run() { // Lade Konfig $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); Zend_Registry::set('config', $config); // Erstelle DB Adapter $db = Zend_Db::factory($config->db); Zend_Registry::set('db', $db); Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('db')); if (APPLICATION_ENV !== 'production') { $profiler = new Zend_Db_Profiler_Firebug('All Database Queries:'); $profiler->setEnabled(true); $db->setProfiler($profiler); } $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => '')); $resourceLoader->addResourceType('plugins', 'plugins', 'Plugins'); if (PHP_SAPI != 'cli') { $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new Plugins_Stats()); if (APPLICATION_ENV == 'production') { $front->registerPlugin(new Plugins_Cache()); } } Zend_View_Helper_PaginationControl::setDefaultViewPartial('_partials/controls.phtml'); parent::run(); }
/** * ctor saves the bootstrap object in Zend Registry * saves also the config */ public function __construct($app) { parent::__construct($app); Zend_Registry::set('bootstrap', $this); Zend_Registry::set('config', new Zend_Config($this->getOptions(), true)); Zend_Registry::set('version', $this->version); }
/** * @inheritdoc */ public function getPluginLoader() { if (null === $this->_pluginLoader) { parent::getPluginLoader(); $this->_pluginLoader->addPrefixPath('Core_Application_Resource', 'Core/Application/Resource'); } return $this->_pluginLoader; }
/** * Adjust FrontController reference */ public function __construct($application) { $frontController = Zend_Controller_Front::getInstance(); Zend_Registry::set("FrontController", $frontController); // Setup paths define('LIBRARY_PATH', realpath(BASE_PATH . '/library')); parent::__construct($application); }
public function run() { Zend_Registry::set("contentdir", $this->getOption('contentdir')); Zend_Registry::set("repodir", $this->getOption('repodir')); Zend_Registry::set("datadir", $this->getOption('datadir')); Zend_Registry::set("defaultbranch", $this->getOption('defaultbranch')); Zend_Registry::set("pipelinestages", $this->getOption('pipelinestages')); parent::run(); }
public function indexAction() { $error = $this->_request->getQuery('error'); $redirect = $this->_request->getQuery('redirect'); $lang = Tudu_Lang::getInstance()->load('login'); $orgInfo = array(); // 使用SSL登陆 if ('http:' == PROTOCOL && strpos($this->options['sites']['www'], 'https:') === 0) { if (preg_replace('/^https:\\/\\//', '', $this->options['sites']['www']) == $this->_host) { $this->_redirect($this->options['sites']['www'] . $this->_request->getServer('REQUEST_URI')); } else { $this->_redirect('https://' . $this->_host . $this->_request->getServer('REQUEST_URI')); } } $memcache = $this->getInvokeArg('bootstrap')->getResource('memcache'); $orgInfo = $memcache->get('TUDU-HOST-' . $this->_host); if (!empty($this->session->auth['appinvoker'])) { return; } if (!$orgInfo) { /* @var $daoOrg Dao_Md_Org_Org */ $daoOrg = Oray_Dao::factory('Dao_Md_Org_Org', $this->bootstrap->getResource('multidb')->getDefaultDb()); $orgInfo = $daoOrg->getOrgByHost($this->_host); $flag = null; $memcache->set('TUDU-HOST-' . $this->_host, $orgInfo, $flag, 3600); } if ($this->_user && $this->_user->isLogined() && $this->_user->orgId == $orgInfo->orgId) { return $this->_redirect(PROTOCOL . '//' . $this->_request->getServer('HTTP_HOST') . '/frame'); } if ($orgInfo instanceof Dao_Md_Org_Record_Org) { $orgInfo = $orgInfo->toArray(); if (!empty($this->options['tudu']['customdomain'])) { $this->options['sites']['tudu'] = PROTOCOL . '//' . $orgInfo['orgid'] . '.' . $this->options['tudu']['domain']; } } if (in_array($error, array('params', 'failure', 'locked', 'unsupport', 'timeout', 'notexist', 'seccode', 'forbid')) && array_key_exists($error, $lang)) { $this->view->error = $error; } if ($error == 'admin') { $this->view->fromadmin = true; } $this->view->org = $orgInfo; $this->view->lang = $lang; $this->view->redirect = $redirect; $this->view->options = array('sites' => $this->options['sites'], 'tudu' => $this->options['tudu']); // 选择登陆模板 if (!empty($orgInfo) && !empty($orgInfo['loginskin'])) { $loginSkin = $orgInfo['loginskin']; if (!empty($loginSkin['selected']) && !empty($loginSkin['selected']['value']) && $loginSkin['selected']['value'] != 'SYS:default') { $this->view->loginskin = $orgInfo['loginskin']; $this->render('custom'); } } }
public function __construct($application) { parent::__construct($application); require_once 'Zend/Loader/Autoloader.php'; $loader = Zend_Loader_Autoloader::getInstance(); $loaders = $loader->getAutoloaders(); foreach ($loaders as $l) { $l->addResourceType('cronjob', 'cronjobs/', 'Cronjob'); $l->addResourceType('apiendpoint', 'apiendpoints/', 'Apiendpoint'); } $loader->setFallbackAutoloader(true); }
/** * @group ZF-10034 */ public function testSetCacheFromCacheManager() { $configCache = array('translate' => array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 120, 'automatic_serialization' => true)), 'backend' => array('name' => 'Black Hole'))); $this->bootstrap->registerPluginResource('cachemanager', $configCache); $options = $this->_translationOptions; $options['cache'] = 'translate'; $resource = new Zend_Application_Resource_Translate($options); $resource->setBootstrap($this->bootstrap); $resource->init(); $this->assertTrue(Zend_Translate::getCache() instanceof Zend_Cache_Core); Zend_Translate::removeCache(); }
public function __construct($application) { $identiy = Zend_Auth::getInstance()->getIdentity(); if ($identiy) { define('CURRENT_USER_ID', $identiy->id); define('CURRENT_USER_NAME', $identiy->nome); define('CURRENT_USER_EMAIL', $identiy->email); define('CURRENT_USER_ROLE', $identiy->role); } $locale = new Zend_Locale('pt_BR'); Zend_Registry::set('Zend_Locale', $locale); parent::__construct($application); }
public function __construct($application) { parent::__construct($application); //注册数据库组件 $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'mysql', true); Zend_Registry::set('config', $config); $dbAdapter = Zend_Db::factory($config->db->adapter, $config->db->config); $dbAdapter->query('SET NAMES UTF8'); Zend_Db_Table::setDefaultAdapter($dbAdapter); Zend_Registry::set('dbAdapter', $dbAdapter); //开启使用 layout 和 MVC 一起使用 Zend_Layout::startMvc(); }
public function __construct($application) { parent::__construct($application); /* $url = $_SERVER['SCRIPT_NAME']; $url = dirname($url); */ $url = dirname(__FILE__); //获取当前Bootstrp_php目录的绝对路径 $url = str_replace('application', 'public', $url); //把当前目录的application替换成public $url = str_replace('\\', '/', $url); //把路径中的‘\’改成‘/’ define('__PUBLIC__', $url); //定义常量存放 }
public function __construct($application) { parent::__construct($application); date_default_timezone_set('Europe/Paris'); $config = Zend_Registry::get('config')->{APPLICATION_ENV}->database; $db = Zend_Db::factory($config->adapter, array('host' => $config->params->host, 'username' => $config->params->username, 'password' => $config->params->password, 'dbname' => $config->params->dbname)); $db->query('SET NAMES UTF8'); Zend_Db_Table::setDefaultAdapter($db); Zend_Registry::set('database', $db); require_once CONFIGS_PATH . 'form.fr.php'; $view = new Zend_View(); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setView($view); $viewRenderer->view->doctype('XHTML1_TRANSITIONAL'); $viewRenderer->view->setEncoding('utf-8'); }
protected function _initView() { Zend_Layout::startMvc(array('layoutPath' => APPLICATION_PATH . '/views/scripts/layouts/', 'layout' => 'layouts/layout')); $layout = Zend_Layout::getMvcInstance(); $view = $layout->getView(); $view->addHelperPath(APPLICATION_PATH . '/views/helpers'); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setViewSuffix('phtml'); $viewRenderer->setView($view); $view->setEncoding('UTF-8'); $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8'); $config = parent::getOptions(); $view->headTitle($config['system']['title']); $view->doctype('XHTML1_STRICT'); return $view; }
public function __construct($app) { parent::__construct($app); date_default_timezone_set('America/Lima'); $this->bootstrap('multidb'); /* ejecuta un recurso */ $db = $this->getPluginResource('multidb')->getDb('db'); /* obtiene los datos del recurso */ Zend_Db_Table::setDefaultAdapter($db); /* registra el adaptador */ Zend_Registry::set('db', $db); /*registra la clase adaptadora*/ Zend_Form::setDefaultTranslator(new Zend_Translate('array', APPLICATION_PATH . '/configs/lang/es.php', 'es')); $this->getResourceLoader()->addResourceType('entity', 'entitys/', 'Entity'); $this->getResourceLoader()->addResourceType('service', 'services/', 'Service'); $response = new Zend_Controller_Response_Http(); $response->setHeader('Content-Type', 'text/html; charset=utf-8')->setHeader('Accept-Encoding', 'gzip, deflate')->setHeader('Expires', 'max-age=' . 20, true)->setHeader('Cache-Control', 'private', 'must-revalidate')->setHeader('Pragma', 'no-cache', true); $response->sendResponse(); }
public function run() { //Autoload Library classes $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('EasyCMS_'); $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH . '/modules/default', 'namespace' => 'App', 'resourceTypes' => array('form' => array('path' => 'forms/', 'namespace' => 'Form'), 'model' => array('path' => 'models/', 'namespace' => 'Model')))); $admin_resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH . '/modules/admin', 'namespace' => 'Admin', 'resourceTypes' => array('form' => array('path' => 'forms/', 'namespace' => 'Form')))); //Setup modules $front = $this->getResource('FrontController'); $front->addModuleDirectory(APPLICATION_PATH . '/modules'); $this->setupRoutes($front); //Load Doctrine $db_config = $this->getApplication()->getOption('database'); $db_params = $db_config['params']; $this->loadDoctrine($db_params['database_name'], $db_params['host'], $db_params['username'], $db_params['password']); //Sort out view $this->initView(); Zend_Registry::set('media_path', $this->getApplication()->getOption('media_path')); parent::run(); }
public function __construct($application) { parent::__construct($application); /* ANTIGA CONEXÃO private function connectDatabase(){ $resource = $this->getPluginResource('db'); $db = $resource->getDbAdapter(); Zend_Registry::set('db',$db); } $resource = $bootstrap->getPluginResource('multidb'); $db1 = $resource->getDb('db1'); $db2 = $resource->getDb('db2'); */ $resource = $this->getPluginResource('multidb'); $resource->init(); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production'); Zend_Registry::set('config', $config); //$db = Zend_Db::factory($config->resources->db); //$db = Zend_Db::factory($config->resources->multidb->db1); Zend_Registry::set('db', $resource->getDb('db1')); Zend_Registry::set('dbcardio', $resource->getDb('db2')); $acl_ini = APPLICATION_PATH . '/configs/roles.ini'; $this->_acl = new Sam_Acl_Ini($acl_ini); Zend_Registry::set('zend_acl', $this->_acl); $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new Sam_Auth_Plugin($this->_acl)); $this->_auth = Zend_Auth::getInstance(); $user = null; if ($this->_auth->hasIdentity()) { // yes ! we get his role $user = $this->_auth->getStorage()->read(); $role = $user->perfil; } else { // no = guest user $role = 'guest'; } Zend_Registry::set('zend_auth_user', $user); Zend_Registry::set('role', $role); }
/** * Get Symfony container instead of default registry container. * Load container from cache if necessary. * {@inheritdoc} */ public function getContainer() { $options = $this->getOption('bootstrap'); if (null === $this->_container && $options['container']['type'] == 'symfony') { if ($this->_doCache() && $this->_cacheExists()) { $cacheFile = $this->_getCacheFile(); $cacheName = pathinfo($cacheFile, PATHINFO_FILENAME); require_once $cacheFile; $this->_container = new $cacheName(); } else { $this->_container = new \LoSo\Symfony\Component\DependencyInjection\ContainerBuilder(); $this->_loadContainer(); if ($this->_doCache() && !$this->_cacheExists()) { $this->_cacheContainer(); } } Zend_Registry::set(self::getRegistryIndex(), $this->_container); Zend_Controller_Action_HelperBroker::addHelper(new LoSo_Zend_Controller_Action_Helper_DependencyInjection()); } return parent::getContainer(); }
public function __construct($application) { parent::__construct($application); // get view resources $this->bootstrap('layout'); $layout = $this->getResource('layout'); $this->_view = $layout->getView(); // add view script path $this->_view->setScriptPath(APPLICATION_PATH . '/views/layout/'); // add custom view helpers paths $this->_view->addHelperPath(APPLICATION_PATH . '/views/helpers/'); // setup database for boostrap use $db = $this->getPluginResource('db')->getDbAdapter(); // Firebug DB Profiler if (isset($_GET['profiler']) && $_GET['profiler'] == 'firebug') { $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); $profiler->setEnabled(true); $db->setProfiler($profiler); } // Force the initial connection to handle error relating to caching etc. try { $db->getConnection(); } catch (Zend_Exception $e) { echo 'ERROR: Cannot connect to database.<br />'; echo $e->getMessage(); die; } Zend_Db_Table::setDefaultAdapter($db); // Set default storage adapter Zend_Registry::set('storage_adapter', 'Application_Model_StorageFilesystem'); // Strip magic quotes if enabled if (get_magic_quotes_gpc()) { function magicQuotes_awStripslashes(&$value, $key) { $value = stripslashes($value); } $gpc = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); array_walk_recursive($gpc, 'magicQuotes_awStripslashes'); } }
protected function _bootstrap($resource = null) { Zend_Session::start(); require_once "DBSettings.php"; require_once "Zend/Registry.php"; require_once 'Zend/Db.php'; require_once 'Zend/Db/Table.php'; require_once 'Zend/Debug.php'; require_once '../application/models/Vocable.php'; parent::_bootstrap($resource); require_once 'Zend/Loader/Autoloader.php'; //-- Set up Autoload Zend_Loader_Autoloader::getInstance(); $mysqli = new mysqli(DBSettings::HOST, DBSettings::USER, DBSettings::PASSWD, DBSettings::SCHEMA); if (!$mysqli) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } $mysqli->set_charset('utf8'); Zend_Registry::set('dbc', $mysqli); $params = array('host' => DBSettings::HOST, 'username' => DBSettings::USER, 'password' => DBSettings::PASSWD, 'dbname' => DBSettings::SCHEMA); $db = Zend_Db::factory('PDO_MYSQL', $params); Zend_Db_Table::setDefaultAdapter($db); }
/** * @group ZF-9110 * @expectedException Zend_Application_Bootstrap_Exception */ public function testPassingSameBootstrapAsApplicationShouldNotCauseRecursion() { $bootstrap = new Zend_Application_Bootstrap_Bootstrap($this->application); $bootstrap->setApplication($bootstrap); }
/** * @group ZF-8496 */ public function testBootstrapAutoloaderNamespaceShouldBeConfigurable() { $application = new Zend_Application('testing', array('appnamespace' => 'Default')); $bootstrap = new Zend_Application_Bootstrap_Bootstrap($application); $al = $bootstrap->getResourceLoader(); $this->assertEquals('Default', $al->getNamespace()); }
public function __construct($application) { parent::__construct($application); $this->bootstrap('view'); $this->_view = $this->getResource('view'); }
public function _bootstrap($resource = null) { Ifphp_Controller_Front::getInstance(); parent::_bootstrap($resource); }
/** * Constructor * * Ensure FrontController resource is registered * * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application * @return void */ public function __construct($application) { parent::__construct($application); $this->_options = $this->getOptions(); }
/** * Overrride this protected method of our parent class to force the order of initializing resources * */ protected function _bootstrap($resource = null) { if ($resource == null) { $resources = array('db', 'profiling', 'logging', 'session', 'locale', 'translate', 'view'); foreach ($resources as $resource) { $this->_executeResource($resource); } // now configure anything else in the config not already initialized foreach ($this->getPluginResourceNames() as $resource) { if (!in_array($resource, $resources)) { $this->_executeResource($resource); } } } else { return parent::_bootstrap($resource); } }
/** * Add graceful error handling to the dispatch, this will handle * errors during Front Controller dispatch. */ public function Xrun() { $errorHandling = $this->getOption('errorhandling'); try { parent::run(); } catch (Exception $exp) { if (true == (bool) $errorHandling['graceful']) { $this->__handleErrors($exp, $errorHandling['email']); } else { throw $exp; } } }
/** * Constructor * * Ensure FrontController resource is registered * * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application * @return void */ public function __construct($application) { parent::__construct($application); $this->runAllInits(); }