本文整理汇总了PHP中Symfony\Component\Finder\SplFileInfo::getRelativePathName方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getRelativePathName方法的具体用法?PHP SplFileInfo::getRelativePathName怎么用?PHP SplFileInfo::getRelativePathName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Finder\SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getRelativePathName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPageFile
protected function createPageFile(DirectoryPath $repositoryPath, DirectoryPath $directoryPath, SplFileInfo $file)
{
$pageFile = new PageFile($repositoryPath->toAbsoluteFileString(), $directoryPath->toRelativeFileString(), $file->getRelativePathName());
$title = $this->elasticsearchRepository->getTitle($pageFile->getAbsolutePath());
if (empty($title)) {
$title = $pageFile->getRelativePath()->getFileName();
}
$pageFile->setTitle($title);
return $pageFile;
}
示例2: __construct
/**
* __construct
*/
protected function __construct(SplFileInfo $file, $language = 'en')
{
$parser = app(Parser::class);
$this->metadata = $parser->frontmatter($file->getContents());
$this->title = isset($this->metadata['PageTitle']) ? $this->metadata['PageTitle'] : (isset($this->metadata['Title']) ? $this->metadata['Title'] : Content::filename_to_title($file->getFilename()));
$this->slug = Content::str_to_slug($this->title);
if (ends_with($file->getRelativePathName(), 'index.md')) {
$this->is_section_home = true;
}
$this->level = count(array_filter(explode(DIRECTORY_SEPARATOR, $file->getRelativePath())));
$relativePath = str_replace('\\', '/', $file->getRelativePath());
$this->is_homepage = $this->level === 0 && $this->is_section_home;
if ($this->level > 0 && $this->is_section_home) {
$this->path = $relativePath;
} else {
$relativePath = $relativePath . (ends_with($relativePath, '/') ? '' : '/');
$this->path = $relativePath . $this->slug;
}
$this->language = $language;
$this->file = $file;
$this->order = isset($this->metadata['Order']) ? $this->metadata['Order'] : (isset($this->metadata['Sort']) ? $this->metadata['Sort'] : 0);
}
示例3: setTarget
/**
* Determine the target path.
*
* @param SplFileInfo $file
* @return string
*/
protected function setTarget(SplFileInfo $file)
{
// Page extension
$ext = $file->getExtension();
// Twig templates are HTML
if (!$this->has('template') || $this->get('template') === 'none') {
$targetExt = $ext;
} else {
$targetExt = 'html';
}
// Get clean source path
$sourcePath = $this->getCleanPath($file->getRelativePathName());
// Replace source extension with that of the template
$this->target = substr($sourcePath, 0, -strlen($ext));
$this->target .= $targetExt;
}
示例4: createPageFile
/**
* @param DirectoryPath $repositoryPath
* @param DirectoryPath $directoryPath
* @param SplFileInfo $file
*
* @return PageFile
*/
protected function createPageFile(DirectoryPath $repositoryPath, DirectoryPath $directoryPath, SplFileInfo $file)
{
$pageFile = new PageFile($repositoryPath->toAbsoluteFileString(), $directoryPath->toRelativeFileString(), $file->getRelativePathName());
$pageFile->setTitle($pageFile->getRelativePath()->getFileName());
return $pageFile;
}