本文整理汇总了PHP中Zend_Config类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Config类的具体用法?PHP Zend_Config怎么用?PHP Zend_Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: config
/**
* @param array $config
*/
public function config($config = [])
{
$settings = null;
// check for an initial configuration template
// used eg. by the demo installer
$configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php";
if (file_exists($configTemplatePath)) {
try {
$configTemplate = new \Zend_Config(include $configTemplatePath);
if ($configTemplate->general) {
// check if the template contains a valid configuration
$settings = $configTemplate->toArray();
// unset database configuration
unset($settings["database"]["params"]["host"]);
unset($settings["database"]["params"]["port"]);
}
} catch (\Exception $e) {
}
}
// set default configuration if no template is present
if (!$settings) {
// write configuration file
$settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]];
}
$settings = array_replace_recursive($settings, $config);
// create initial /website/var folder structure
// @TODO: should use values out of startup.php (Constants)
$varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"];
foreach ($varFolders as $folder) {
\Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder);
}
$configFile = \Pimcore\Config::locateConfigFile("system.php");
File::putPhpFile($configFile, to_php_data_file_format($settings));
}
示例2: _initConfig
/**
* Combine the static info found in application.ini with the
* dynamic info found in the Info table.
*
* @return void
*/
protected function _initConfig()
{
$this->bootstrap('db');
$this->bootstrap('locale');
if (!class_exists('Model_Info')) {
return;
}
try {
$staticConfig = Zend_Registry::get('config');
$infoModel = $this->_getInfoModel();
$dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV);
// Very sneakily bypass 'readOnly'
if ($staticConfig->readOnly()) {
$staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true);
}
$staticConfig->merge($dynamicConfig);
$staticConfig->setReadOnly();
Zend_Registry::set('config', $staticConfig);
} catch (Exception $e) {
$msg = $e->getMessage();
if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false) {
throw $e;
}
}
}
示例3: setup
/**
* Setup db
*
*/
public function setup(Zend_Config $config)
{
$sessionConfig = $config->get('config');
$configArray = $sessionConfig->toArray();
// save_path handler
$configArray = $this->_prependSavePath($configArray);
// name handler
$configArray = $this->_parseName($configArray);
// Setup config
Zend_Session::setOptions($configArray);
// Setup save handling?
$saveHandlerConfig = $config->get('save_handler');
if ($className = $saveHandlerConfig->get('class_name')) {
if ($args = $saveHandlerConfig->get('constructor_args')) {
if ($args instanceof Zend_Config) {
$args = $args->toArray();
} else {
$args = (array) $args;
}
} else {
$args = array();
}
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($className);
$saveHandler = new ReflectionClass($className);
$saveHandler = $saveHandler->newInstanceArgs($args);
Zend_Session::setSaveHandler($saveHandler);
}
// Autostart session?
if ($config->get('auto_start')) {
// Start session
Zend_Session::start();
}
}
示例4: setup
/**
* Setup Doctrine
*
* @return void
*/
public function setup(Zend_Config $config)
{
if (is_array($config->path_config)) {
$this->setPathConfig($config->path_config);
} elseif ($config->path_config instanceof Zend_Config) {
$this->setPathConfig($config->path_config->toArray());
}
if ($charset = $config->get('charset')) {
$listener = new Zym_App_Resource_Doctrine_ConnectionListener();
$listener->setCharset($charset);
Doctrine_Manager::getInstance()->addListener($listener);
}
// determine if config is for a single-db or a multi-db site
$connections = $config->connection instanceof Zend_Config ? $config->connection->toArray() : (array) $config->connection;
// add connection(s) to doctrine
foreach ($connections as $name => $connection) {
if ($connection instanceof Zend_Config) {
$connection = $connection->toArray();
}
if (is_string($name)) {
Doctrine_Manager::connection($connection, $name);
} else {
Doctrine_Manager::connection($connection);
}
}
}
示例5: _initConfig
/**
* Инициализация конфигурации
*/
protected function _initConfig()
{
$path = APPLICATION_PATH . '/../library/Zkernel/Application/configs';
$config = new Zend_Config(array(), true);
$it = new DirectoryIterator($path);
foreach ($it as $file) {
if ($file->isFile()) {
$fullpath = $path . '/' . $file;
switch (substr(trim(strtolower($fullpath)), -3)) {
case 'ini':
$cfg = new Zend_Config_Ini($fullpath, $this->getEnvironment());
break;
case 'xml':
$cfg = new Zend_Config_Xml($fullpath, $this->getEnvironment());
break;
default:
throw new Zend_Config_Exception('Invalid format for config file');
break;
}
$config->merge($cfg);
}
}
$config->merge(new Zend_Config($this->getOptions()));
$this->setOptions($config->toArray());
}
示例6: getArgConfig
/**
* @param Zend_Config $testConfig
* @param ReflectionParameter $arg
* @throws Exception
* @throws KalturaTestException
* @return Ambigous
*/
protected function getArgConfig(Zend_Config $testConfig, ReflectionParameter $arg)
{
$argName = $arg->getName();
$argConfig = $testConfig->get($argName);
KalturaLog::debug("Tests data [{$argName}] config [" . print_r($argConfig, true) . "]");
if (!$argConfig) {
if (!$arg->allowsNull()) {
throw new Exception("Argument [{$argName}] can't be null for test [" . $this->getName() . "]");
}
return null;
}
if (is_string($argConfig)) {
return $argConfig;
}
switch ($argConfig->objectType) {
case 'dependency':
throw new KalturaTestException("Argument [{$argName}] taken from dependency");
case 'array':
return $this->populateArray($argConfig);
case 'native':
return $argConfig->value;
case 'file':
return $argConfig->path;
default:
return $this->populateObject($argConfig);
}
}
示例7: mapSlavesConfig
/**
* @param $databaseConfig
* @param $masterParams
* @return array
*/
private function mapSlavesConfig(Zend_Config $databaseConfig, $masterParams)
{
$slaves = $databaseConfig->get('slaves');
if (!$slaves || !$slaves instanceof Zend_Config || $slaves->count() === 0) {
$slaves = array();
}
$slavesParams = array();
foreach ($slaves as $slaveId) {
$slaveConfig = $databaseConfig->get($slaveId);
if (!$slaveConfig || !$slaveConfig instanceof Zend_Config) {
$this->logger->warning(sprintf("Listed slave '%s' has no configuration. Skipping candidate slave.", $slaveId));
continue;
}
$slaveParams = $this->getParamsFromConfig($slaveConfig);
if ($slaveParams['driver'] !== $masterParams['driver']) {
$this->logger->warning(sprintf("Listed slave '%s' has different driver ('%s') than master ('%s'). This is not supported. " . 'Skipping candidate slave.', $slaveId, $slaveParams['driver'], $masterParams['driver']));
continue;
}
$slavesParams[] = $slaveParams;
}
if (empty($slavesParams)) {
$this->logger->warning('No (properly) configured slaves, using master as slave.');
$slavesParams[] = $masterParams;
}
return $slavesParams;
}
示例8: getTransport
/**
* Get transport
*
* @param Zend_Config $config
* @return Zend_Mail_Transport_Sendmail
*/
public static function getTransport(Zend_Config $config = null)
{
$host = isset($config->host) ? $config->get('host') : null;
$otherConfig = ($config instanceof Zend_Config) ? $config->toArray() : null;
return new Zend_Mail_Transport_Smtp($host, $otherConfig);
}
示例9: __construct
/**
* Constructor.
* @param array $options
*/
public function __construct(Zend_Config $config = null)
{
$defaultConfig = new Zend_Config(array('style' => array('itemClass' => 'Item', 'titleClass' => 'Title', 'descriptionClass' => 'Description', 'tagContainerClass' => 'TagList', 'tagClass' => 'Tag', 'iconClass' => 'Icon', 'iconWidth' => 16, 'iconHeight' => 16, 'dateClass' => 'Date')), true);
if (!is_null($config)) {
$defaultConfig->merge($config);
}
$this->_config = $defaultConfig;
}
示例10: _init
/**
* Pseudo-constructor (the actual constructor must be final).
* @param Zend_Config $config
* @return void
*/
protected function _init(Zend_Config $config)
{
$defaultConfig = new Zend_Config(array('url' => null, 'cacheLifetime' => 7200, 'cacheDir' => './cache', 'limit' => 5, 'items' => array()), true);
if (!isset($config->url)) {
throw new Polycast_Stalker_Provider_Exception('No feed url given');
}
$this->_config = $defaultConfig->merge($config);
}
示例11: testSetOptionsSkipsCallsToSetOptionsAndSetConfig
public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig()
{
$options = $this->getOptions();
$config = new Zend_Config($options);
$options['config'] = $config;
$options['options'] = $config->toArray();
$this->form->setOptions($options);
}
示例12: setup
/**
* Setup navigation
*
* @return void
*/
public function setup(Zend_Config $config)
{
// determine registry key
$confKey = $config->get('registry_key');
$key = is_string($confKey) && strlen($confKey) ? $confKey : self::DEFAULT_REGISTRY_KEY;
$nav = new Zym_Navigation($config->get('pages'));
Zend_Registry::set($key, $nav);
}
示例13: __construct
/**
* Sets filter options
*
* @param string|array|Zend_Config $options
* @return void
*/
public function __construct($options = null)
{
if ($options instanceof Zend_Config) {
$this->_options = $options->toArray();
} else {
$this->_options = (array) $options;
}
}
示例14: setQuotaModuleEnableDev
/**
* @param boolean $enableDev
*/
protected function setQuotaModuleEnableDev($enableDev)
{
$config = Registry::getConfig();
$newConfig = new \Zend_Config($config->toArray(), true);
$newConfig->quota->module->enableDev = $enableDev;
$newConfig->setReadOnly();
Registry::setConfig($newConfig);
}
示例15: fromZendConfig
/**
*
* Creates a new test configuration from Zend_Config
*/
public static function fromZendConfig(Zend_Config $config)
{
$newConfig = new KalturaTestConfig();
$dataArray = $config->toArray();
foreach ($dataArray as $key => $value) {
$newConfig->{$key} = $value;
}
return $newConfig;
}