本文整理汇总了PHP中League\Flysystem\Filesystem::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getMetadata方法的具体用法?PHP Filesystem::getMetadata怎么用?PHP Filesystem::getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Remove file or a directory
*
* @param $path
* @return void
*/
public function remove($path)
{
if (!$this->filesystem->has($path)) {
return;
}
$meta = $this->filesystem->getMetadata($path);
if ($meta['type'] === 'file') {
$this->filesystem->delete($path);
} else {
$this->filesystem->deleteDir($path);
}
}
示例2: testGetMetadata
public function testGetMetadata()
{
$data = $this->filesystem->getMetadata('2.txt');
$this->assertArrayHasKey('type', $data);
$this->assertArrayHasKey('dirname', $data);
$this->assertArrayHasKey('path', $data);
$this->assertArrayHasKey('timestamp', $data);
$this->assertArrayHasKey('mimetype', $data);
$this->assertArrayHasKey('size', $data);
}
示例3: filetype
/**
* {@inheritdoc}
*/
public function filetype($path) {
if ($path === '' or $path === '/' or $path === '.') {
return 'dir';
}
try {
$info = $this->flysystem->getMetadata($this->buildPath($path));
} catch (FileNotFoundException $e) {
return false;
}
return $info['type'];
}
示例4: getMetadata
/**
* @inheritdoc
*/
public function getMetadata($path)
{
try {
$return = $this->fileSystem->getMetadata($this->getInnerPath($path));
} catch (FileNotFoundException $e) {
throw $this->exceptionWrapper($e, $path);
}
if ($return !== false) {
$return = array_merge($return, pathinfo($path), ["path" => $path]);
}
return $return;
}
示例5: get
/**
* Get an object from the filesystem based on its path.
*
* Dependening on the adapter in the underlying flysystem, this might treat
* empty directories as if they would not exist (e.g. for ZipArchiveAdapter).
*
* @param string $path
* @return FSObject|null
*/
public function get($path)
{
// TODO: This does not deal with ~ for home directory.
assert(is_string($path));
// For ZipArchiveAdapter this is required to get the directories correctly,
// as Filesystem::get will raise.
if ($this->filesystem->listContents($path)) {
return new Directory($this, $path);
}
try {
$info = $this->filesystem->getMetadata($path);
if ($info) {
if ($info["type"] == "file") {
return new File($this, $path);
}
return new Directory($this, $path);
}
} catch (\League\Flysystem\FileNotFoundException $e) {
return null;
}
return null;
}
示例6: _stat
/**
* @inheritdoc
*/
protected function _stat($path)
{
$stat = array('size' => 0, 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'mime' => 'directory');
// If root, just return from above
if ($this->root == $path) {
$stat['name'] = $this->root;
return $stat;
}
// If not exists, return empty
// if ( !$this->fs->has($path)) {
// return array();
// }
//
// $meta = $this->fs->getMetadata($path);
try {
$meta = $this->fs->getMetadata($path);
} catch (FileNotFoundException $e) {
$path = $path . '/';
try {
$meta = $this->fs->getMetadata($path);
} catch (FileNotFoundException $e) {
return array();
}
}
// Get timestamp/size
$stat['ts'] = isset($meta['timestamp']) ? $meta['timestamp'] : $this->fs->getTimestamp($path);
$stat['size'] = isset($meta['size']) ? $meta['size'] : $this->fs->getSize($path);
// Check if file, if so, check mimetype
if ($meta['type'] == 'file') {
$stat['mime'] = isset($meta['mimetype']) ? $meta['mimetype'] : $this->fs->getMimetype($path);
$imgMimes = ['image/jpeg', 'image/png', 'image/gif'];
if ($this->urlBuilder && in_array($stat['mime'], $imgMimes)) {
$stat['url'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts']]);
$stat['tmb'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts'], 'w' => $this->tmbSize, 'h' => $this->tmbSize, 'fit' => $this->options['tmbCrop'] ? 'crop' : 'contain']);
}
}
// if (!isset($stat['url']) && $this->fs->getUrl()) {
// $stat['url'] = 1;
// }
return $stat;
}
示例7: stat
/**
* @param Payload $payload
* @param Messenger $messenger
* @return PromiseInterface
*/
public function stat(Payload $payload, Messenger $messenger)
{
$stat = $this->flysystem->getMetadata($payload['path']);
return \React\Promise\resolve(['size' => $stat['size'], 'atime' => $stat['timestamp'], 'mtime' => $stat['timestamp'], 'ctime' => $stat['timestamp']]);
}
示例8: getMetadata
/**
* Get a file's metadata
*
* ```php
* getMetadata('cache/file.tmp')
* getMetadata('~/file.tmp$/')
* ```
*
* @param string $path path to file or regexp pattern
* @return array|false file metadata or FALSE when fails
* to fetch it from existing file
*/
public function getMetadata($path)
{
if (StringHelper::isRegexp($path) && !($path = $this->searchByPattern($path))) {
return false;
}
try {
if ($metadata = parent::getMetadata($path)) {
if (!isset($metadata['dirname'])) {
$metadata['dirname'] = FileHelper::dirname($metadata['path']);
}
if (!isset($metadata['basename'])) {
$metadata['basename'] = FileHelper::basename($metadata['path']);
}
}
return $metadata;
} catch (\Exception $e) {
$this->errors[] = $e->getMessage();
}
return false;
}