本文整理汇总了PHP中ConfigFile::isValidName方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFile::isValidName方法的具体用法?PHP ConfigFile::isValidName怎么用?PHP ConfigFile::isValidName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::isValidName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _loadConfigFile
/**
* @param $name
*/
private function _loadConfigFile($name)
{
$lowercaseName = StringHelper::toLowerCase($name);
// Is this a valid Craft config file?
if (ConfigFile::isValidName($name)) {
$defaultsPath = CRAFT_APP_PATH . 'etc/config/defaults/' . $name . '.php';
} else {
$defaultsPath = CRAFT_PLUGINS_PATH . $lowercaseName . '/config.php';
}
if (IOHelper::fileExists($defaultsPath)) {
$defaultsConfig = @(require_once $defaultsPath);
}
if (!isset($defaultsConfig) || !is_array($defaultsConfig)) {
$defaultsConfig = array();
}
// Little extra logic for the general config file.
if ($name == ConfigFile::General) {
// Does craft/config/general.php exist? (It used to be called blocks.php so maybe not.)
if (file_exists(CRAFT_CONFIG_PATH . 'general.php')) {
if (is_array($customConfig = @(include CRAFT_CONFIG_PATH . 'general.php'))) {
$this->_mergeConfigs($defaultsConfig, $customConfig);
}
} else {
if (file_exists(CRAFT_CONFIG_PATH . 'blocks.php')) {
// Originally blocks.php defined a $blocksConfig variable, and then later returned an array directly.
if (is_array($customConfig = (require_once CRAFT_CONFIG_PATH . 'blocks.php'))) {
$this->_mergeConfigs($defaultsConfig, $customConfig);
} else {
if (isset($blocksConfig)) {
$defaultsConfig = array_merge($defaultsConfig, $blocksConfig);
unset($blocksConfig);
}
}
}
}
} else {
$customConfigPath = CRAFT_CONFIG_PATH . $name . '.php';
if (!IOHelper::fileExists($customConfigPath)) {
// Be a little forgiving on case sensitive file systems.
$customConfigPath = CRAFT_CONFIG_PATH . StringHelper::toLowerCase($name) . '.php';
}
if (IOHelper::fileExists($customConfigPath)) {
if (is_array($customConfig = @(include $customConfigPath))) {
$this->_mergeConfigs($defaultsConfig, $customConfig);
} else {
if ($name == ConfigFile::Db) {
// Originally db.php defined a $dbConfig variable.
if (@(require_once CRAFT_CONFIG_PATH . 'db.php')) {
$this->_mergeConfigs($defaultsConfig, $dbConfig);
unset($dbConfig);
}
}
}
}
}
$this->_loadedConfigFiles[$lowercaseName] = $defaultsConfig;
}