本文整理汇总了PHP中Zend_Application::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Application::getOptions方法的具体用法?PHP Zend_Application::getOptions怎么用?PHP Zend_Application::getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Application
的用法示例。
在下文中一共展示了Zend_Application::getOptions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: config
/**
* Shortcut for the application config
*
* @param string $key A dot-separated path to a config value
* @param string $default The value to return if the key was not found
* @return Zend_Config | mixed
*/
public static function config($key = null, $default = null)
{
static $config;
if (!$config) {
$config = self::$_application->getOptions();
}
// Return the root object if no key is given
if (empty($key)) {
return $config;
}
// Find the value by following the path given
$level = $config;
$parts = explode('.', $key);
foreach ($parts as $part) {
if (isset($level[$part])) {
$level = $level[$part];
} else {
if ($default === NULL) {
trigger_error('Unable to find config key "' . $key . '"', E_USER_NOTICE);
return NULL;
} else {
return $default;
}
}
}
return $level;
}
示例2: __construct
/**
* Constructor
*
* Invoke setContainerFactory, set _coantainerFactory if factory is configurated
* Ensure FrontController resource is registered
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
* @return void
*/
public function __construct($application)
{
$this->setContainerFactory($application->getOptions());
parent::__construct($application);
if (!$this->hasPluginResource('FrontController')) {
$this->registerPluginResource('FrontController');
}
}
示例3: testSetOptionsShouldProperlyMergeTwoConfigFileOptions
/**
* @group ZF-6679
*/
public function testSetOptionsShouldProperlyMergeTwoConfigFileOptions()
{
$application = new Zend_Application('production', dirname(__FILE__) . '/_files/zf-6679-1.inc');
$options = $application->getOptions();
$this->assertEquals(array('includePaths', 'config'), array_keys($options));
}
示例4: define
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(__DIR__ . '/../app'));
if (!defined('APPLICATION_ROOT')) {
define('APPLICATION_ROOT', realpath(__DIR__ . '/..'));
}
// Application.ini.inc cache file
defined('CONFIG_INC') || define('CONFIG_INC', APPLICATION_ROOT . '/data/cache/' . APPLICATION_ENV . '.ini.inc');
// We use default config if no cache
$configFile = CONFIG_INC;
$noConfigCache = false;
if (false === is_file(CONFIG_INC)) {
$configFile = APPLICATION_PATH . '/config/application.ini';
$noConfigCache = true;
}
require_once APPLICATION_PATH . '/global.php';
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Loader/Autoloader.php';
//Zend_Session::writeClose(true); //If you will have problems with sesssions and APC
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, $configFile);
// Create the cache of config if no
// Only for production
if ($noConfigCache and 'production' == APPLICATION_ENV) {
$configs = '<?php' . PHP_EOL . 'return ' . var_export($application->getOptions(), true) . PHP_EOL . '?>';
file_put_contents(CONFIG_INC, $configs);
}
$application->bootstrap()->run();
示例5: define
<?php
/* set crossdomain request */
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
header("Access-Control-Allow-Credentials: true");
// Define application environment
if (!isset($_REQUEST['env']) || empty($_REQUEST['env'])) {
die;
} else {
define('APPLICATION_DB', $_REQUEST['env']);
}
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
/* Define application environment */
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$config = $application->getOptions();
$config['resources']['db']['params']['dbname'] = APPLICATION_DB;
$application->setOptions($config)->bootstrap()->run();
示例6: define
<?php
if (array_key_exists(1, $argv)) {
$env = $argv[1];
} else {
$env = 'production';
}
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__) . '/..'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(BASE_PATH . '/library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$config = array('config' => array(realpath(BASE_PATH . '/configs/application.ini')));
$application = new Zend_Application($env, $config);
$dbConnection = $application->getBootstrap()->bootstrap('Doctrine');
try {
Doctrine_Core::dropDatabases();
} catch (Doctrine_Connection_Mysql_Exception $e) {
error_log('The database did not exists');
}
Doctrine_Core::createDatabases();
$options = $application->getOptions();
$ymlPath = realpath(BASE_PATH . '/Scripts/Yaml/Schema/Koryukan.yml');
$modelsOptions = array('suffix' => '.php', 'generateTableClasses' => true, 'classPrefix' => 'Koryukan_Db_', 'classPrefixFiles' => false, 'baseClassPrefix' => 'Base', 'baseClassesDirectory' => '');
Doctrine_Core::generateModelsFromYaml($ymlPath, $options['db']['objectsPath'], $modelsOptions);
Doctrine_Core::createTablesFromModels($options['db']['objectsPath']);
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/news.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/storeItems.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/images.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/security.yml');
示例7: defined
if (isset($opts->app_env)) {
defined('APPLICATION_ENV') || define('APPLICATION_ENV', $opts->app_env);
} else {
echo "\n\nParametr app_env jest wymagany!";
echo "\n\n" . $opts->getUsageMessage() . "\n\n";
exit;
}
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
Base_Controller_Action_Helper_Currentip::$_unitTestEnabled = true;
$application->bootstrap();
$application->getBootstrap()->runForCmd();
Zend_Controller_Front::getInstance()->setParam('bootstrap', $application->getBootstrap());
Zend_registry::set('config', $application->getOptions());
$user = $application->getOption('bin');
$u = new User();
$u_data = $u->fetchAll("login = '" . $user['user'] . "'", "id DESC", 1);
if (null == $u_data) {
throw new Exception('Brak użytkownika o podanym ID');
}
$u_data = $u_data->toArray();
$storageRow = new stdClass();
foreach ($u_data[0] as $key => $value) {
$storageRow->{$key} = $value;
}
$auth = Zend_Auth::getInstance();
$storage = $auth->getStorage();
$o = new Branch();
$data = $o->fetchAll("branch_name = '" . $user['branch'] . "'", "id DESC", 1)->toArray();