本文整理汇总了PHP中MOXMAN_Util_PathUtils::getParent方法的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN_Util_PathUtils::getParent方法的具体用法?PHP MOXMAN_Util_PathUtils::getParent怎么用?PHP MOXMAN_Util_PathUtils::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOXMAN_Util_PathUtils
的用法示例。
在下文中一共展示了MOXMAN_Util_PathUtils::getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfig
/**
* Returns a config based on the specified file.
*
* @param MOXMAN_Vfs_IFile $file File to get the config for.
* @return MOXMAN_Util_Config Config for the specified file.
*/
public function getConfig(MOXMAN_Vfs_IFile $file)
{
$config = clone $this->config;
$path = $file->isFile() ? $file->getParent() : $file->getPath();
$root = $this->fileSystem->getRootPath();
$mcAccessFile = $this->config->get("filesystem.local.access_file_name", "mc_access");
$user = MOXMAN::getUser();
$configFiles = array();
$targetConfigPath = $path . '/' . $mcAccessFile;
// Collect config files
while ($path && strlen($path) >= strlen($root)) {
if (file_exists($path . '/' . $mcAccessFile)) {
$configFiles[] = $path . '/' . $mcAccessFile;
}
$path = MOXMAN_Util_PathUtils::getParent($path);
}
// Extend current config with the config files
for ($i = count($configFiles) - 1; $i >= 0; $i--) {
// Parse mc_access file
$iniParser = new MOXMAN_Util_IniParser();
$iniParser->load($configFiles[$i]);
// Loop and extend it
$items = $iniParser->getItems();
foreach ($items as $key => $value) {
// Group specific config
if (is_array($value)) {
$targetGroups = explode(',', $key);
foreach ($targetGroups as $targetGroup) {
if ($user->isMemberOf($targetGroup)) {
foreach ($value as $key2 => $value2) {
if (strpos($key2, '_') === 0) {
if ($targetConfigPath == $configFiles[$i]) {
$key2 = substr($key2, 1);
} else {
continue;
}
}
$config->put($key2, $value2);
}
}
}
} else {
if (strpos($key, '_') === 0) {
if ($targetConfigPath == $configFiles[$i]) {
$key = substr($key, 1);
} else {
continue;
}
}
$config->put($key, $value);
}
}
}
return $config;
}
示例2: getParent
/**
* Returns the parent files absolute path or an empty string if there is no parent.
*
* @return String parent files absolute path.
*/
public function getParent()
{
$path = MOXMAN_Util_PathUtils::getParent($this->getPath());
// If path is out side the file systems root path
if (!MOXMAN_Util_PathUtils::isChildOf($path, $this->fileSystem->getRootPath())) {
return "";
}
return $path;
}