本文整理汇总了PHP中Zend_Config::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Config::toArray方法的具体用法?PHP Zend_Config::toArray怎么用?PHP Zend_Config::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Config
的用法示例。
在下文中一共展示了Zend_Config::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
}
}
示例2: _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());
}
示例3: 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));
}
示例4: 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);
}
示例5: testSetOptionsSkipsCallsToSetOptionsAndSetConfig
public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig()
{
$options = $this->getOptions();
$config = new Zend_Config($options);
$options['config'] = $config;
$options['options'] = $config->toArray();
$this->form->setOptions($options);
}
示例6: __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;
}
}
示例7: createFromConfig
public static function createFromConfig(Zend_Config $config)
{
if (!isset($config->host) || $config->host == '') {
throw new EngineBlock_Exception('No Grouper Host specified! Please set "grouper.host" in your application configuration.');
}
$url = $config->protocol . '://' . $config->user . ':' . $config->password . '@' . $config->host . (isset($config->port) ? ':' . $config->port : '') . $config->path . '/' . $config->version . '/';
$grouper = new self($url, $config->toArray());
return $grouper;
}
示例8: 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;
}
示例9: getPlugin
/**
* Return errorHandler
*
* @param Zend_Config $config
* @return Zym_Controller_Plugin_ErrorHandler
*/
public function getPlugin(Zend_Config $config = null)
{
if ($config instanceof Zend_Config) {
$options = $config->toArray();
} else {
$options = array();
}
$plugin = new Zym_Controller_Plugin_ErrorHandler($options);
return $plugin;
}
示例10: getXmlForConfig
/**
* Returns a SimpleXMLElement for the given config.
*
* @see Zend_Build_Resource_Interface
* @param Zend_Build_Resource_Interface Resource to convert to XML
* @return string String in valid XML 1.0 format
*/
public static function getXmlForConfig(Zend_Config $config)
{
// First create the empty XML element
$xml = self::_arrayToXml($config->toArray(), new SimpleXMLElement('<' . self::CONFIG_XML_ROOT_ELEMENT . '/>'), true);
// Format output for readable XML and save to $filename
$dom = new DomDocument('1.0');
$domnode = dom_import_simplexml($xml);
$domnode = $dom->importNode($domnode, true);
$domnode = $dom->appendChild($domnode);
$dom->formatOutput = true;
return $dom->saveXML();
}
示例11: _handleConfig
/**
* Modify config for Zend_Layout
*
* @param Zend_Config $config
* @return array
*/
protected function _handleConfig(Zend_Config $config)
{
// Remove null items
$inflectedConfig = $config->toArray();
foreach ($inflectedConfig as $index => $var) {
if (null === $var) {
unset($inflectedConfig[$index]);
}
}
// Change underscore items to camelcased
$inflectedConfig = array_flip($inflectedConfig);
$inflectedConfig = array_flip(array_map(array($this, '_inflectConfig'), $inflectedConfig));
return $inflectedConfig;
}
示例12: init
/**
* Init observers
*
* @param Evil_Config $events
* @param null $object
* @return void
*/
public function init(Evil_Config $events, $object = null)
{
foreach ($events->observers as $name => $body) {
foreach ($body as $handler) {
/// соединяем настройки по умолчанию с настройками текущего handler, в т.ч. src
/// т.к. Zend_Config v1.11.4 не умеет рекурсивно мержить конфиги
$handler = new Zend_Config(array_merge_recursive($events->handler->toArray(), $handler->toArray()));
// print_r($events->handler->toArray());
// print_r($handler->toArray());
$this->addHandler(new Evil_Event_Slot($name, $handler, $object));
}
}
// var_dump($this->_handlers);
}
示例13: _initConfig
public function _initConfig()
{
$config = new Zend_Config($this->getOptions(), true);
$inifiles = array('app', 'cache', 'private');
//TODO: only load cache.ini for models
foreach ($inifiles as $file) {
$inifile = APPLICATION_PATH . "/configs/{$file}.ini";
if (is_readable($inifile)) {
$config->merge(new Zend_Config_Ini($inifile));
}
}
$config->setReadOnly();
$this->setOptions($config->toArray());
Zend_Registry::set('config', $config);
define('DATE_DB', 'Y-m-d H:i:s');
}
示例14: testDefaultBehaviour
public function testDefaultBehaviour()
{
$config = new Zend_Config($this->data, false, false);
$this->assertEquals('1.2', $config->float);
$this->assertEquals('1200', $config->integer);
$this->assertEquals('0124', $config->pseudo_int);
$this->assertEquals('foobar', $config->string);
$this->assertEquals('true', $config->bool_true);
$this->assertEquals('false', $config->bool_false);
$array = $config->toArray();
$this->assertEquals('1.2', $array['float']);
$this->assertEquals('1200', $array['integer']);
$this->assertEquals('0124', $array['pseudo_int']);
$this->assertEquals('foobar', $array['string']);
$this->assertEquals('true', $array['bool_true']);
$this->assertEquals('false', $array['bool_false']);
}
示例15: _initBar
protected function _initBar()
{
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Api_');
$loader->registerNamespace(array('Api_'));
$router = $this->setRouter();
// Создание объекта front контроллера
$front = Zend_Controller_Front::getInstance();
// Настройка front контроллера, указание базового URL, правил маршрутизации
$front->setRouter($router);
$registry = Zend_Registry::getInstance();
$registry->constants = new Zend_Config($this->getApplication()->getOption('constants'));
//настройки почты
$mail_const = new Zend_Config($this->getApplication()->getOption('mail'));
$tr = new Zend_Mail_Transport_Smtp($mail_const->host, $mail_const->toArray());
Zend_Mail::setDefaultTransport($tr);
}