本文整理匯總了PHP中OCP\IURLGenerator::imagePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP IURLGenerator::imagePath方法的具體用法?PHP IURLGenerator::imagePath怎麽用?PHP IURLGenerator::imagePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCP\IURLGenerator
的用法示例。
在下文中一共展示了IURLGenerator::imagePath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mimeTypeIcon
/**
* Get path to the icon of a file type
* @param string $mimetype the MIME type
* @return string the url
*/
public function mimeTypeIcon($mimetype)
{
$this->loadAliases();
while (isset($this->mimeTypeAlias[$mimetype])) {
$mimetype = $this->mimeTypeAlias[$mimetype];
}
if (isset($this->mimetypeIcons[$mimetype])) {
return $this->mimetypeIcons[$mimetype];
}
// Replace slash and backslash with a minus
$icon = str_replace('/', '-', $mimetype);
$icon = str_replace('\\', '-', $icon);
// Is it a dir?
if ($mimetype === 'dir') {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder.svg');
return $this->mimetypeIcons[$mimetype];
}
if ($mimetype === 'dir-shared') {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-shared.svg');
return $this->mimetypeIcons[$mimetype];
}
if ($mimetype === 'dir-external') {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-external.svg');
return $this->mimetypeIcons[$mimetype];
}
// Icon exists?
try {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $icon . '.svg');
return $this->mimetypeIcons[$mimetype];
} catch (\RuntimeException $e) {
// Specified image not found
}
// Try only the first part of the filetype
$mimePart = substr($icon, 0, strpos($icon, '-'));
try {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
return $this->mimetypeIcons[$mimetype];
} catch (\RuntimeException $e) {
// Image for the first part of the mimetype not found
}
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg');
return $this->mimetypeIcons[$mimetype];
}