本文整理汇总了PHP中League\Flysystem\Util::emulateDirectories方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::emulateDirectories方法的具体用法?PHP Util::emulateDirectories怎么用?PHP Util::emulateDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Util
的用法示例。
在下文中一共展示了Util::emulateDirectories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listContents
/**
* {@inheritdoc}
*/
public function listContents($dirname = '', $recursive = false)
{
$objectsIterator = $this->client->getIterator('listObjects', ['Bucket' => $this->bucket, 'Prefix' => $this->applyPathPrefix($dirname)]);
$contents = iterator_to_array($objectsIterator);
$result = array_map([$this, 'normalizeResponse'], $contents);
$result = array_filter($result, function ($value) {
return $value['path'] !== false;
});
return Util::emulateDirectories($result);
}
示例2: listContents
/**
* List contents of a directory.
*
* @param string $directory
* @param bool $recursive
*
* @return array
*/
public function listContents($directory = '', $recursive = false)
{
$prefix = $this->applyPathPrefix(rtrim($directory, '/') . '/');
$options = ['Bucket' => $this->bucket, 'Prefix' => ltrim($prefix, '/')];
if ($recursive === false) {
$options['Delimiter'] = '/';
}
$listing = $this->retrievePaginatedListing($options);
$normalizer = [$this, 'normalizeResponse'];
$normalized = array_map($normalizer, $listing);
return Util::emulateDirectories($normalized);
}
示例3: listContents
/**
* @inheritdoc
*/
public function listContents($directory = '', $recursive = false)
{
$params = [];
$sql = "SELECT * FROM {$this->pathTable}";
if (!empty($directory)) {
$sql .= " WHERE path LIKE :prefix OR path = :path";
$params = ['prefix' => $directory . '/%', 'path' => $directory];
}
$stmt = $this->db->prepare($sql);
if (!$stmt->execute($params)) {
return [];
}
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$rows = array_map([$this, 'normalizeMetadata'], $rows);
if ($recursive) {
$rows = Util::emulateDirectories($rows);
}
return $rows;
}
示例4: listContents
/**
* {@inheritdoc}
*/
public function listContents($dirname = '', $recursive = false)
{
$dirname = rtrim($dirname, '/') . '/';
$commandOptions = ['Bucket' => $this->bucket, 'Prefix' => $this->applyPathPrefix($dirname)];
$iteratorOptions = [];
if (!$recursive) {
$commandOptions['Delimiter'] = '/';
$iteratorOptions['return_prefixes'] = true;
}
$objectsIterator = $this->client->getIterator('listObjects', $commandOptions, $iteratorOptions);
$contents = iterator_to_array($objectsIterator);
$result = array_map([$this, 'normalizeResponse'], $contents);
$result = array_filter($result, function ($value) {
return $value['path'] !== false;
});
return Util::emulateDirectories($result);
}
示例5: listContents
/**
* {@inheritdoc}
*/
public function listContents($dirname = '', $recursive = false)
{
$bucket = $this->bucket;
$dir = $this->listDirObjects($dirname, true);
$contents = $dir["objects"];
$result = array_map([$this, 'normalizeResponseOri'], $contents);
$result = array_filter($result, function ($value) {
return $value['path'] !== false;
});
return Util::emulateDirectories($result);
}
示例6: listContents
/**
* Get a file's metadata
*
* @param string $path
* @return array file metadata
*/
public function listContents($directory = '', $recursive = false)
{
$response = $this->container->objectList(array('prefix' => $directory));
$response = iterator_to_array($response);
$contents = array_map(array($this, 'normalizeObject'), $response);
return Util::emulateDirectories($contents);
}
示例7: listContents
/**
* {@inheritdoc}
*/
public function listContents($directory = '', $recursive = false)
{
$directory = $this->applyPathPrefix($directory);
// Append trailing slash only for directory other than root (which after normalization is an empty string).
// Listing for / doesn't work properly otherwise.
if (strlen($directory)) {
$directory = rtrim($directory, '/') . '/';
}
$options = new ListBlobsOptions();
$options->setPrefix($directory);
if (!$recursive) {
$options->setDelimiter('/');
}
/** @var ListBlobsResult $listResults */
$listResults = $this->client->listBlobs($this->container, $options);
$contents = [];
foreach ($listResults->getBlobs() as $blob) {
$contents[] = $this->normalizeBlobProperties($blob->getName(), $blob->getProperties());
}
if (!$recursive) {
$contents = array_merge($contents, array_map([$this, 'normalizeBlobPrefix'], $listResults->getBlobPrefixes()));
}
return Util::emulateDirectories($contents);
}
示例8: listContents
/**
* List contents of a directory.
*
* @param string $directory
* @param bool $recursive
*
* @return array
*/
public function listContents($directory = '', $recursive = false)
{
$prefix = $this->applyPathPrefix(rtrim($directory, '/') . '/');
$options = ['Bucket' => $this->bucket, 'Prefix' => ltrim($prefix, '/')];
$iterator = $this->s3Client->getIterator('ListObjects', $options);
$normalizer = [$this, 'normalizeResponse'];
$normalized = array_map($normalizer, iterator_to_array($iterator));
return Util::emulateDirectories($normalized);
}
示例9: listContents
/**
* List contents of a directory
*
* @param string $dirname
* @param bool $recursive
* @return array directory contents
*/
public function listContents($dirname = '', $recursive = false)
{
if ($dirname == '') {
$dirname = "root";
}
$dirname = basename($dirname);
$parameters = array();
$result = array();
do {
try {
if (isset($pageToken)) {
$parameters['pageToken'] = $pageToken;
}
$files = $this->service->children->listChildren($dirname, $parameters);
foreach ($files as $file) {
$meta = (array) $this->service->files->get($file['id'], $parameters);
if ($dirname == "root") {
} else {
$meta['dirname'] = $dirname;
}
$result = array_merge($result, array($meta));
}
//$result = array_merge($result, $files->getItems());
$pageToken = $files->getNextPageToken();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
$pageToken = NULL;
}
} while ($pageToken);
$result = array_map(array($this, 'normalizeObject'), $result);
return Util::emulateDirectories($result);
}
示例10: listContents
/**
* List contents of a directory
*
* @param string $dirname
* @param bool $recursive
* @return array directory contents
*/
public function listContents($dirname = '', $recursive = false)
{
$objectsIterator = $this->client->getIterator('listObjects', array('Bucket' => $this->bucket, 'Prefix' => $this->prefix($dirname)));
$contents = iterator_to_array($objectsIterator);
$result = array_map(array($this, 'normalizeObject'), $contents);
return Util::emulateDirectories($result);
}
示例11: listContents
/**
* List contents of a directory.
*
* @param string $directory
* @param bool $recursive
*
* @return array
*/
public function listContents($directory = '', $recursive = false)
{
$keys = $this->client->keys($directory . '/*');
$values = [];
foreach ($keys as $key) {
if (!$recursive && preg_match("|{$directory}/.+/|", $key) !== 0) {
continue;
}
$stream = tmpfile();
fwrite($stream, $this->client->get($key));
rewind($stream);
$values[$key] = ['mimetype' => Util::guessMimeType(stream_get_meta_data($stream)['uri'], stream_get_contents($stream)), 'type' => 'file'];
}
return Util::emulateDirectories($values);
}
示例12: listContents
/**
* {@inheritdoc}
*/
public function listContents($directory = '', $recursive = false)
{
$location = $this->applyPathPrefix($directory);
$response = $this->container->objectList(['prefix' => $location]);
$response = iterator_to_array($response);
$contents = array_map([$this, 'normalizeObject'], $response);
return Util::emulateDirectories($contents);
}
示例13: listContents
/**
* {@inheritdoc}
*/
public function listContents($directory = '', $recursive = false)
{
$directory = $this->applyPathPrefix($directory);
$objects = $this->bucket->objects(['prefix' => $directory]);
$normalised = [];
foreach ($objects as $object) {
$normalised[] = $this->normaliseObject($object);
}
return Util::emulateDirectories($normalised);
}
示例14: listContents
/**
* @inheritdoc
*/
public function listContents($directory = '', $recursive = false)
{
$options = new ListBlobsOptions();
$options->setPrefix($directory);
/** @var ListBlobsResult $listResults */
$listResults = $this->client->listBlobs($this->container, $options);
$contents = [];
foreach ($listResults->getBlobs() as $blob) {
$contents[] = $this->normalizeBlobProperties($blob->getName(), $blob->getProperties());
}
return Util::emulateDirectories($contents);
}
示例15: listContents
/**
* {@inheritdoc}
*/
public function listContents($directory = '', $recursive = false)
{
$response = [];
$marker = null;
$location = $this->applyPathPrefix($directory);
while (true) {
$objectList = $this->client->listObjects(['Bucket' => $this->bucket, 'Prefix' => $location, 'Marker' => $marker, 'MaxKeys' => 100]);
$objectSummarys = $objectList->getObjectSummarys();
if (!$objectSummarys || count($objectSummarys) === 0) {
break;
}
foreach ($objectSummarys as $summary) {
if ($summary) {
$object = $this->getObject($this->removePathPrefix($summary->getKey()));
if (!$object) {
continue;
}
$response[] = $object;
$marker = $object->getKey();
}
}
}
return Util::emulateDirectories(array_map([$this, 'normalizeObject'], $response));
}