本文整理汇总了PHP中Director::is_absolute方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::is_absolute方法的具体用法?PHP Director::is_absolute怎么用?PHP Director::is_absolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::is_absolute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsAbsolute
/**
* Tests that {@link Director::is_absolute()} works under different environment types
*/
public function testIsAbsolute()
{
$expected = array('C:/something' => true, 'd:\\' => true, 'e/' => false, 's:/directory' => true, '/var/www' => true, '\\Something' => true, 'something/c:' => false, 'folder' => false, 'a/c:/' => false);
foreach ($expected as $path => $result) {
$this->assertEquals(Director::is_absolute($path), $result, "Test result for {$path}");
}
}
示例2: requireDefaultRecords
/**
* Adds the default languages if they are missing
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$defaultLangs = array_keys($this->defaultLanguages);
$dbLangCount = SnippetLanguage::get()->filter('Name', $defaultLangs)->filter('UserLanguage', 0)->Count();
if ($dbLangCount < count($defaultLangs)) {
foreach ($this->defaultLanguages as $name => $data) {
if (!SnippetLanguage::get()->find('Name', $name)) {
$lang = new SnippetLanguage();
$lang->Name = $name;
$lang->FileExtension = $data['Extension'];
$lang->HighlightCode = $data['HighlightCode'];
$lang->UserLanguage = false;
$lang->write();
DB::alteration_message('Created snippet language "' . $name . '"', 'created');
}
}
}
//Look for config languages
$configLanguages = CodeBank::config()->extra_languages;
if (!empty($configLanguages)) {
foreach ($configLanguages as $language) {
//Validate languages
if (empty($language['Name']) || empty($language['FileName']) || empty($language['HighlightCode']) || empty($language['Brush'])) {
user_error('Invalid snippet user language found in config, user languages defined in config must contain a Name, FileName, HighlightCode and Brush file path', E_USER_WARNING);
continue;
}
$lang = SnippetLanguage::get()->filter('Name', Convert::raw2sql($language['Name']))->filter('HighlightCode', Convert::raw2sql($language['HighlightCode']))->filter('UserLanguage', true)->first();
if (empty($lang) || $lang === false || $lang->ID <= 0) {
if (Director::is_absolute($language['Brush']) || Director::is_absolute_url($language['Brush'])) {
user_error('Invalid snippet user language found in config, user languages defined in config must contain a path to the brush relative to the SilverStripe base (' . Director::baseFolder() . ')', E_USER_WARNING);
continue;
}
if (preg_match('/\\.js$/', $language['Brush']) == 0) {
user_error('Invalid snippet user language found in config, user languages defined in config must be javascript files', E_USER_WARNING);
continue;
}
//Add language
$lang = new SnippetLanguage();
$lang->Name = $language['Name'];
$lang->FileExtension = $language['FileName'];
$lang->HighlightCode = $language['HighlightCode'];
$lang->BrushFile = $language['Brush'];
$lang->UserLanguage = true;
$lang->write();
DB::alteration_message('Created snippet user language "' . $language['Name'] . '"', 'created');
}
}
}
}
示例3: __construct
/**
* @param String Absolute file path, or relative path to {@link Director::baseFolder()}
*/
function __construct($fixtureFile) {
if(!Director::is_absolute($fixtureFile)) $fixtureFile = Director::baseFolder().'/'. $fixtureFile;
if(!file_exists($fixtureFile)) {
throw new InvalidArgumentException('YamlFixture::__construct(): Fixture path "' . $fixtureFile . '" not found');
}
$this->fixtureFile = $fixtureFile;
parent::__construct();
}
示例4: __construct
/**
* @param String Absolute file path, or relative path to {@link Director::baseFolder()}
*/
public function __construct($fixture)
{
if (false !== strpos($fixture, "\n")) {
$this->fixtureString = $fixture;
} else {
if (!Director::is_absolute($fixture)) {
$fixture = Director::baseFolder() . '/' . $fixture;
}
if (!file_exists($fixture)) {
throw new InvalidArgumentException('YamlFixture::__construct(): Fixture path "' . $fixture . '" not found');
}
$this->fixtureFile = $fixture;
}
parent::__construct();
}
示例5: getDatabaseTemplates
/**
* Get all *.sql database files located in a specific path,
* keyed by their file name.
*
* @param String $path Absolute folder path
* @return array
*/
protected function getDatabaseTemplates($path = null)
{
$templates = array();
if (!$path) {
$path = $this->config()->database_templates_path;
}
// TODO Remove once we can set BASE_PATH through the config layer
if ($path && !Director::is_absolute($path)) {
$path = BASE_PATH . '/' . $path;
}
if ($path && file_exists($path)) {
$it = new FilesystemIterator($path);
foreach ($it as $fileinfo) {
if ($fileinfo->getExtension() != 'sql') {
continue;
}
$templates[$fileinfo->getRealPath()] = $fileinfo->getFilename();
}
}
return $templates;
}