本文整理汇总了PHP中Utilities::convertPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::convertPath方法的具体用法?PHP Utilities::convertPath怎么用?PHP Utilities::convertPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities
的用法示例。
在下文中一共展示了Utilities::convertPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConversions
public function testConversions()
{
// Windows to unix style paths:
$this->assertEquals('some/directory/file', Utilities::convertPath('some\\directory\\file'));
$this->assertEquals('///', Utilities::convertPath('\\\\\\'));
// CamelCase to lisp-case
$this->assertEquals('do-stuff', Utilities::camelCaseToDashes('DoStuff'));
$this->assertEquals('do-more-stuff', Utilities::camelCaseToDashes('doMoreStuff'));
$this->assertEquals('h-t-m-l', Utilities::camelCaseToDashes('HTML'));
// CamelCase to snake_case
$this->assertEquals('do_stuff', Utilities::camelCaseToUnderscores('DoStuff'));
$this->assertEquals('do_more_stuff', Utilities::camelCaseToUnderscores('doMoreStuff'));
$this->assertEquals('h_t_m_l', Utilities::camelCaseToUnderscores('HTML'));
// lisp-case to CamelCase
$this->assertEquals('DoStuff', Utilities::dashesToCamelCase('do-stuff'));
$this->assertEquals('DoMoreStuff', Utilities::dashesToCamelCase('do-more-stuff'));
$this->assertEquals('HTML', Utilities::dashesToCamelCase('h-t-m-l'));
$this->assertEquals('TEst', Utilities::dashesToCamelCase('t----est'));
// snake_case to CamelCase
$this->assertEquals('DoStuff', Utilities::underscoresToCamelCase('do_stuff'));
$this->assertEquals('DoMoreStuff', Utilities::underscoresToCamelCase('do_more_stuff'));
$this->assertEquals('HTML', Utilities::underscoresToCamelCase('h_t_m_l'));
$this->assertEquals('TEst', Utilities::underscoresToCamelCase('t____est'));
// Slugs
$this->assertEquals('my-post-title', Utilities::stringToDashes('My Post-Title1234'));
}
示例2: __construct
/**
* Create application.
* @param string $appPath Path to app-directory containing at least an
* 'app.json' configuration file.
* @param string $userPath Path to user-directory.
* @param string $entryScript Name of entry script, e.g. 'index.php'.
*/
public function __construct($appPath, $userPath, $entryScript = 'index.php')
{
parent::__construct();
$this->logger = ErrorHandler::getInstance()->getLogger();
$appPath = Utilities::convertPath($appPath);
$userPath = Utilities::convertPath($userPath);
$manifestFile = $appPath . '/app.json';
if (file_exists($manifestFile)) {
$manifest = Json::decodeFile($manifestFile);
$manifest = array_merge($this->defaultManifest, $manifest);
} else {
$this->logger->error('Invalid application. "app.json" not found. Configuring default application.');
$this->noManifest = true;
$manifest = $this->defaultManifest;
}
$this->manifest = $manifest;
$this->m = new ModuleLoader();
$this->paths = new Paths(Paths::convertPath(getcwd()), $userPath);
$this->paths->app = $appPath;
$this->paths->user = $userPath;
// $this->basePath = dirname($_SERVER['SCRIPT_NAME']);
$this->entryScript = $entryScript;
// Temporary work-around for weird SCRIPT_NAME.
// When url contains a trailing dot such as
// /app/index.php/admin./something
// SCRIPT_NAME returns /app/index.php/admin./something instead of expected
// /app/index.php
$script = explode('/', $_SERVER['SCRIPT_NAME']);
while (count($script) > 0) {
if ($script[count($script) - 1] == $entryScript) {
break;
}
array_pop($script);
}
$this->basePath = dirname(implode('/', $script));
// END work-around
$this->name = $manifest['name'];
$this->version = $manifest['version'];
$this->namespace = $manifest['namespace'];
Autoloader::getInstance()->addPath($this->namespace, $this->p('app'));
$this->paths->Jivoo = \Jivoo\PATH;
$this->paths->Core = \Jivoo\PATH . '/Core';
$file = new PhpStore($this->p('user/config.php'));
$this->config = new Document();
$this->config['user'] = new Config($file);
}
示例3: p
/**
* Convert an internal path.
* @param string $ipath Internal path, e.g. 'key/followed/by/subpath'.
* @param string $context Optional context for relative paths (paths starting
* with './'). The default is the {@see $basePath}.
*/
public function p($ipath, $context = null)
{
$ipath = Utilities::convertPath($ipath);
if (!isset($context)) {
$context = $this->basePath;
}
if ($ipath == '') {
return $context;
}
$splits = explode('/', $ipath, 2);
$key = $splits[0];
$path = '';
if (isset($splits[1])) {
$path = $splits[1];
}
if ($key == '.') {
return self::combinePaths($context, $path);
}
return self::combinePaths($this->__get($key), $path);
}