本文整理汇总了PHP中sfToolkit::arrayDeepMerge方法的典型用法代码示例。如果您正苦于以下问题:PHP sfToolkit::arrayDeepMerge方法的具体用法?PHP sfToolkit::arrayDeepMerge怎么用?PHP sfToolkit::arrayDeepMerge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfToolkit
的用法示例。
在下文中一共展示了sfToolkit::arrayDeepMerge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($alias, $architecture)
{
$this->alias = $alias;
$this->architecture = $architecture;
$archiConfig = $architecture->getConfig();
$this->config = sfToolkit::arrayDeepMerge($archiConfig['hosts']['all'], $archiConfig['hosts'][$alias]);
}
示例2: executeTableManager
public function executeTableManager()
{
$class = $this->getRequestParameter('class');
$generator_configuration = array(
'model_class' => $class,
'theme' => 'sfControlPanel',
'moduleName' => $class.'ControlPanel',
'list' => array(
'title' => $class.' list',
),
'edit' => array(
'title' => 'edit '.$class,
),
);
if(file_exists(SF_ROOT_DIR.'/config/sfControlPanel_generator.yml'))
{
$custom_configuration = sfYaml::load(SF_ROOT_DIR.'/config/sfControlPanel_generator.yml');
if(isset($custom_configuration[$class]))
{
$generator_configuration = sfToolkit::arrayDeepMerge($generator_configuration, $custom_configuration[$class]);
}
}
$generatorManager = new sfGeneratorManager();
$generatorManager->initialize();
$data = $generatorManager->generate('sfControlPanelGenerator', $generator_configuration);
$this->redirect('auto'.$class.'ControlPanel/list');
}
示例3: initialize
protected function initialize(array $options)
{
$this->options = sfToolkit::arrayDeepMerge($this->options, $options);
if (!$this->page instanceof DmPage) {
throw new dmException(sprintf('%s require a source instance of DmPage, %s given', get_class($this), get_class($this->page)));
}
}
示例4: execute
/**
* Executes this configuration handler.
*
* @param array An array of absolute filesystem path to a configuration file
*
* @return string Data to be written to a cache file
*
* @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable
* @throws <b>sfParseException</b> If a requested configuration file is improperly formatted
* @throws <b>sfInitializationException</b> If a cache.yml key check fails
*/
public function execute($configFiles)
{
// set our required categories list and initialize our handler
$categories = array('required_categories' => array());
$this->initialize($categories);
// parse the yaml
$myConfig = $this->parseYamls($configFiles);
$myConfig['all'] = sfToolkit::arrayDeepMerge(isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array());
unset($myConfig['default']);
$this->yamlConfig = $myConfig;
// iterate through all action names
$data = array();
$first = true;
foreach ($this->yamlConfig as $actionName => $values) {
if ($actionName == 'all') {
continue;
}
$data[] = $this->addCache($actionName);
$first = false;
}
// general cache configuration
$data[] = $this->addCache('DEFAULT');
// compile data
$retval = sprintf("<?php\n" . "// auto-generated by sfCacheConfigHandler\n" . "// date: %s\n%s\n", date('Y/m/d H:i:s'), implode('', $data));
return $retval;
}
示例5: parseYamls
/**
* Parses an array of YAMLs files and merges them in one configuration array.
*
* @param array An array of configuration file paths
*
* @param array A merged configuration array
*/
protected function parseYamls($configFiles)
{
$config = array();
foreach ($configFiles as $configFile) {
$config = sfToolkit::arrayDeepMerge($config, $this->parseYaml($configFile));
}
return $config;
}
示例6: __construct
public function __construct($source, $ruleName = 'default')
{
$this->setSource(tsUploadSource::create($source));
$defaultRule = array('params' => array('image_resize' => true), 'sizes' => array());
$uploadConfig = sfYaml::load(sfConfig::get('sf_app_config_dir') . '/upload.yml');
$config = sfToolkit::arrayDeepMerge($uploadConfig['all'], (array) @$uploadConfig[sfConfig::get('sf_environment')]);
$this->_ruleConfig = sfToolkit::arrayDeepMerge((array) @$config['rules']['default'], $config['rules'][$ruleName]);
$this->_ruleConfig = sfToolkit::arrayDeepMerge($defaultRule, $this->_ruleConfig);
}
示例7: __construct
public function __construct(sfConfigCache $configCache, $architecture)
{
$this->configCache = $configCache;
if (!file_exists($path = sfConfig::get('sf_config_dir') . '/knp_architecture.yml')) {
throw new Exception($path . ' does not exist');
}
$this->configCache->registerConfigHandler('config/knp_architecture.yml', 'sfSimpleYamlConfigHandler');
$this->config = (include $this->configCache->checkConfig('config/knp_architecture.yml'));
$this->architecture = $architecture;
$this->config = sfToolkit::arrayDeepMerge($this->config['all'], $this->config[$architecture]);
}
示例8: execute
/**
* Executes this configuration handler.
*
* @param array An array of absolute filesystem path to a configuration file
*
* @return string Data to be written to a cache file
*
* @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable
* @throws <b>sfParseException</b> If a requested configuration file is improperly formatted
* @throws <b>sfInitializationException</b> If a view.yml key check fails
*/
public function execute($configFiles)
{
// parse the yaml
$myConfig = $this->parseYamls($configFiles);
$myConfig['all'] = sfToolkit::arrayDeepMerge(isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array());
unset($myConfig['default']);
// change all of the keys to lowercase
$myConfig = array_change_key_case($myConfig);
// compile data
$retval = sprintf("<?php\n" . "// auto-generated by sfSecurityConfigHandler\n" . "// date: %s\n\$this->security = %s;\n", date('Y/m/d H:i:s'), var_export($myConfig, true));
return $retval;
}
示例9: execute
/**
* Executes this configuration handler.
*
* @param array An array of absolute filesystem path to a configuration file
*
* @return string Data to be written to a cache file
*
* @throws sfConfigurationException If a requested configuration file does not exist or is not readable
* @throws sfParseException If a requested configuration file is improperly formatted
*/
public function execute($configFiles)
{
// parse the yaml
$myConfig = $this->parseYamls($configFiles);
$myConfig = sfToolkit::arrayDeepMerge(isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(), isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array());
// init our data and includes arrays
$data = array();
$databases = array();
$includes = array();
// get a list of database connections
foreach ($myConfig as $key => $dbConfig) {
// is this category already registered?
if (in_array($key, $databases)) {
// this category is already registered
$error = sprintf('Configuration file "%s" specifies previously registered category "%s"', $configFiles[0], $key);
throw new sfParseException($error);
}
// add this database
$databases[] = $key;
// let's do our fancy work
if (!isset($dbConfig['class'])) {
// missing class key
$error = sprintf('Configuration file "%s" specifies category "%s" with missing class key', $configFiles[0], $key);
throw new sfParseException($error);
}
if (isset($dbConfig['file'])) {
// we have a file to include
$file = $this->replaceConstants($dbConfig['file']);
$file = $this->replacePath($file);
if (!is_readable($file)) {
// database file doesn't exist
$error = sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s"', $configFiles[0], $dbConfig['class'], $file);
throw new sfParseException($error);
}
// append our data
$includes[] = sprintf("require_once('%s');", $file);
}
// parse parameters
if (isset($dbConfig['param'])) {
foreach ($dbConfig['param'] as &$value) {
$value = $this->replaceConstants($value);
}
$parameters = var_export($dbConfig['param'], true);
} else {
$parameters = 'null';
}
// append new data
$data[] = sprintf("\n\$database = new %s();\n" . "\$database->initialize(%s, '%s');\n" . "\$this->databases['%s'] = \$database;", $dbConfig['class'], $parameters, $key, $key);
}
// compile data
$retval = sprintf("<?php\n" . "// auto-generated by sfDatabaseConfigHandler\n" . "// date: %s%s\n%s\n", date('Y/m/d H:i:s'), implode("\n", $includes), implode("\n", $data));
return $retval;
}
示例10: getConfigForPath
protected function getConfigForPath($path)
{
if (strncmp($path, sfConfig::get('sf_root_dir'), $len = strlen(sfConfig::get('sf_root_dir'))) == 0) {
$path = substr($path, $len);
}
$config = array();
foreach ($this->patternConfigs as $pattern => $patternConfig) {
if (preg_match('/^' . str_replace('/', '\\/', $pattern) . '$/', $path) > 0) {
$config = sfToolkit::arrayDeepMerge($config, $patternConfig);
}
}
return $config;
}
示例11: applyInheritance
public static function applyInheritance($config)
{
$classes = array_keys($config);
$merged = array();
foreach ($classes as $class) {
if (class_exists($class)) {
$merged[$class] = $config[$class];
foreach (array_intersect(class_parents($class), $classes) as $parent) {
$merged[$class] = sfToolkit::arrayDeepMerge($config[$parent], $merged[$class]);
}
}
}
return $merged;
}
开发者ID:kriswallsmith,项目名称:sfFormYamlEnhancementsPlugin,代码行数:14,代码来源:sfFormYamlEnhancementsConfigHander.class.php
示例12: getAuthConfigSettings
public function getAuthConfigSettings($name = '')
{
if (!sfConfig::has('op_auth_' . $this->getAuthModeName())) {
// default
$configPath = sfConfig::get('sf_lib_dir') . '/config/config/auth.yml';
sfContext::getInstance()->getConfigCache()->registerConfigHandler($configPath, 'sfSimpleYamlConfigHandler', array());
$default = (include sfContext::getInstance()->getConfigCache()->checkConfig($configPath));
// plugins
$configPath = sfConfig::get('sf_plugins_dir') . '/opAuth' . $this->getAuthModeName() . 'Plugin/config/auth.yml';
sfContext::getInstance()->getConfigCache()->registerConfigHandler($configPath, 'sfSimpleYamlConfigHandler', array());
$plugins = (include sfContext::getInstance()->getConfigCache()->checkConfig($configPath));
sfConfig::set('op_auth_' . $this->getAuthModeName(), sfToolkit::arrayDeepMerge($default, $plugins));
}
$configs = sfConfig::get('op_auth_' . $this->getAuthModeName());
if (!$name) {
return $configs;
} elseif (!empty($configs[$name])) {
return $configs[$name];
}
return null;
}
示例13: execute
public function execute($configFiles)
{
// Parse yaml config files
$configs = $this->parseYamls($configFiles);
// Default config: all.attributes
$default_config = array();
if (isset($configs['all']['attributes']) && is_array($configs['all']['attributes'])) {
$default_config = $configs['all']['attributes'];
unset($configs['all']['attributes']);
}
// Environment specific defaults: <env>.attributes
$env = sfConfig::get('sf_environment');
if (isset($configs[$env]['attributes']) && is_array($configs[$env]['attributes'])) {
$default_config = sfToolKit::arrayDeepMerge($default_config, $configs[$env]['attributes']);
unset($configs[$env]['attributes']);
}
// Connection specific configs
$conn_configs = array();
foreach ($configs as $env => $env_config) {
foreach ($env_config as $conn => $conn_config) {
$conn_configs[$conn] = sfToolkit::arrayDeepMerge($default_config, $conn_config);
}
}
// Prepare default config data
$data = array();
foreach ($this->configToAttributes($default_config) as $key => $value) {
$data[] = sprintf('$default_attributes["%s"] = %s;', $key, $this->attributeToPhp($value));
}
$data[] = '';
// Prepare connection specific data
foreach ($conn_configs as $conn_name => $conn_config) {
foreach ($this->configToAttributes($conn_config) as $key => $value) {
$data[] = sprintf('$attributes["%s"]["%s"] = %s;', $conn_name, $key, $this->attributeToPHP($value));
}
$data[] = '';
}
// compile data
$retval = sprintf("<?php\n" . "// auto-generated by sfDoctrineConfigHandler\n" . "// date: %s\n%s\n", date('Y-m-d H:i:s'), implode("\n", $data));
return $retval;
}
示例14: execute
/**
* Executes this configuration handler.
*
* @param array An array of absolute filesystem path to a configuration file
*
* @return string Data to be written to a cache file
*
* @throws <b>sfParseException</b> If a requested configuration file is improperly formatted
*/
public function execute($configFiles)
{
// parse the yaml
$myConfig = $this->parseYamls($configFiles);
$myConfig = sfToolkit::arrayDeepMerge(isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(), isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array());
// Set Up Servers
$defaultServerConfig = array('host' => 'localhost', 'port' => 11211, 'persistent' => true, 'weight' => 1, 'timeout' => 1, 'retry_interval' => 15, 'status' => true);
if (!isset($myConfig['servers']) || !is_array($myConfig['servers'])) {
$myConfig['servers'] = array('default' => $defaultServerConfig);
}
$myConfig['servers']['default'] = array_merge($defaultServerConfig, isset($myConfig['servers']['default']) ? $myConfig['servers']['default'] : array());
foreach ($myConfig['servers'] as $serverName => &$server) {
$server = array_merge($myConfig['servers']['default'], $server);
}
// Set Up Buckets
if (!isset($myConfig['buckets']) || !is_array($myConfig['buckets'])) {
throw new sfParseException(sprintf('Configuration file "%s" does not specify any cache buckets.', $configFiles[0]));
}
$inits = array();
$tmp = array();
foreach ($myConfig['buckets'] as $bucketName => &$bucket) {
if (!isset($bucket['servers'])) {
$bucket['servers'] = 'default';
}
if (!is_array($bucket['servers'])) {
$bucket['servers'] = array($bucket['servers']);
}
foreach ($bucket['servers'] as $serverName => &$server) {
if (!isset($myConfig['servers'][$server])) {
throw new sfParseException(sprintf('Configuration file "%s" requires server configuration \'%s\' for bucket \'%s\', but server configuration does not exist.', $configFiles[0], $server, $bucketName));
}
$server = $myConfig['servers'][$server];
}
$tmp[$bucketName] = $bucket;
}
$inits[] = sprintf("sfConfig::set('%s', %s);", 'memcache_servers', var_export($tmp, true));
// Compile Return Value
return sprintf("<?php\n %s", implode("\n", $inits));
}
示例15: _buildArrayToWrite
protected function _buildArrayToWrite()
{
$old = $this->getDefaults();
$new = $this->getValues();
$array = array();
$array['all']['sympal_config'] = array();
// Add only the values that have changed from the old default values
foreach ($new as $key => $value) {
if ($value != $old[$key]) {
$array['all']['sympal_config'][$key] = $value;
}
}
// Merge in existing values from the current app.yml file
$array = sfToolkit::arrayDeepMerge(sfYaml::load(sfConfig::get('sf_app_dir') . '/config/app.yml'), $array);
// Remove values that don't exist anymore
foreach ($array['all']['sympal_config'] as $key => $value) {
if (!array_key_exists($key, $new)) {
unset($array['all']['sympal_config'][$key]);
}
}
return $array;
}