本文整理汇总了PHP中League\Flysystem\FilesystemInterface::url方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::url方法的具体用法?PHP FilesystemInterface::url怎么用?PHP FilesystemInterface::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public function handle($path)
{
$files = [];
$folders = [];
$list = $this->filesystem->listContents($path);
$ignored = ['.', '..', '.DS_Store', '.gitignore', '.htaccess'];
foreach ($list as $entry) {
if (in_array($entry['basename'], $ignored)) {
continue;
}
if (!$this->filesystem->authorized($entry['path'])) {
continue;
}
if ($entry['type'] === 'file') {
try {
$url = $this->filesystem->url($entry['path']);
} catch (\Exception $e) {
$url = $entry['path'];
}
// Ugh, for some reason the foldername for the theme is included twice. Why?
// For now we 'fix' this with an ugly hack, replacing it. :-/
// TODO: dig into Filesystem and figure out why this happens.
$pathsegments = explode('/', $entry['path']);
if (!empty($pathsegments[0])) {
$url = str_replace('/' . $pathsegments[0] . '/' . $pathsegments[0] . '/', '/' . $pathsegments[0] . '/', $url);
}
$files[$entry['path']] = ['path' => $entry['dirname'], 'filename' => $entry['basename'], 'newpath' => $entry['path'], 'relativepath' => $entry['path'], 'writable' => true, 'readable' => false, 'type' => isset($entry['extension']) ? $entry['extension'] : '', 'filesize' => Lib::formatFilesize($entry['size']), 'modified' => date("Y/m/d H:i:s", $entry['timestamp']), 'permissions' => 'public', 'url' => $url];
/* **** Extra checks for files that can be resolved via PHP urlopen functions **** */
try {
$files[$entry['path']]['permissions'] = $this->filesystem->getVisibility($entry['path']);
} catch (\Exception $e) {
// Computer says "No!"
}
$fullfilename = $this->filesystem->getAdapter()->applyPathPrefix($entry['path']);
if (is_readable($fullfilename)) {
$files[$entry['path']]['readable'] = true;
if (!empty($entry['extension']) && in_array($entry['extension'], ['gif', 'jpg', 'png', 'jpeg'])) {
$size = getimagesize($fullfilename);
$files[$entry['path']]['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
}
$files[$entry['path']]['permissions'] = util::full_permissions($fullfilename);
}
}
if ($entry['type'] == 'dir') {
$folders[$entry['path']] = ['path' => $entry['dirname'], 'foldername' => $entry['basename'], 'newpath' => $entry['path'], 'modified' => date("Y/m/d H:i:s", $entry['timestamp']), 'writable' => true];
$fullfilename = $this->filesystem->getAdapter()->applyPathPrefix($entry['path']);
/* **** Extra checks for files that can be resolved via PHP urlopen functions **** */
if (is_readable($fullfilename)) {
if (!is_writable($fullfilename)) {
$folders[$entry['path']]['writable'] = false;
}
}
}
}
ksort($files);
ksort($folders);
return [$files, $folders];
}