本文整理汇总了PHP中League\Flysystem\Util::map方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::map方法的具体用法?PHP Util::map怎么用?PHP Util::map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Util
的用法示例。
在下文中一共展示了Util::map方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalizeResponse
/**
* Normalize the object result array.
*
* @param array $response
* @param string $path
*
* @return array
*/
protected function normalizeResponse(array $response, $path = null)
{
$result = ['path' => $path ?: $this->removePathPrefix($response['Key'])];
$result = array_merge($result, Util::pathinfo($result['path']));
if (isset($response['LastModified'])) {
$result['timestamp'] = strtotime($response['LastModified']);
}
if (substr($result['path'], -1) === '/') {
$result['type'] = 'dir';
$result['path'] = rtrim($result['path'], '/');
return $result;
}
return array_merge($result, Util::map($response, static::$resultMap), ['type' => 'file']);
}
示例2: normalizeObject
/**
* Normalize a result from AWS
*
* @param string $object
* @param string $path
* @return array file metadata
*/
protected function normalizeObject($object, $path = null)
{
$result = array('path' => $path ?: $object['Key']);
if (isset($object['LastModified'])) {
$result['timestamp'] = strtotime($object['LastModified']);
}
$result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
$result['dirname'] = Util::dirname($result['path']);
if (isset($result['contents'])) {
$result['contents'] = (string) $result['contents'];
}
return $result;
}
示例3: normalizeObject
/**
* Normalize a zip response array.
*
* @param array $object
*
* @return array
*/
protected function normalizeObject(array $object)
{
if (substr($object['name'], -1) === '/') {
return ['path' => $this->removePathPrefix(trim($object['name'], '/')), 'type' => 'dir'];
}
$result = ['type' => 'file'];
$normalised = Util::map($object, static::$resultMap);
$normalised['path'] = $this->removePathPrefix($normalised['path']);
return array_merge($result, $normalised);
}
示例4: normalizeObject
protected function normalizeObject($object, $path = null)
{
$result = array('path' => $path ?: ltrim($object['path'], '/'));
if (isset($object['modified'])) {
$result['timestamp'] = strtotime($object['modified']);
}
$result = array_merge($result, Util::map($object, static::$resultMap));
$result['type'] = $object['is_dir'] ? 'dir' : 'file';
return $result;
}
示例5: normalizeObject
/**
* Normalize a result from Copy.
*
* @param stdClass $object
* @param string $path
*
* @return array|false file metadata
*/
protected function normalizeObject($object, $path)
{
if (!$object instanceof stdClass) {
return false;
}
if (isset($object->modified_time)) {
$timestamp = $object->modified_time;
}
$path = trim($this->removePathPrefix($path), '/');
$result = Util::map((array) $object, static::$resultMap);
return compact('timestamp', 'path') + $result;
}
示例6: getMetadata
/**
* @inheritdoc
*/
public function getMetadata($path)
{
$connection = $this->getConnection();
$info = $connection->stat($path);
if ($info === false) {
return false;
}
$result = Util::map($info, $this->statMap);
$result['type'] = $info['type'] === NET_SFTP_TYPE_DIRECTORY ? 'dir' : 'file';
$result['visibility'] = $info['permissions'] & $this->permPublic ? 'public' : 'private';
return $result;
}
示例7: normalizeObject
protected function normalizeObject($object, $path)
{
if (!isset($object['{DAV:}getcontentlength'])) {
return array('type' => 'dir', 'path' => trim($path, '/'));
}
$result = Util::map($object, static::$resultMap);
if (isset($object['{DAV:}getlastmodified'])) {
$result['timestamp'] = strtotime($object['{DAV:}getlastmodified']);
}
$result['type'] = 'file';
$result['path'] = trim($path, '/');
return $result;
}
示例8: normalizeObject
/**
* Normalize a result from Copy.
*
* @param stdClass $object
* @param string $path
*
* @return array|false file metadata
*/
protected function normalizeObject($object, $path)
{
if (is_a($object, 'stdClass') === false) {
return false;
}
if (isset($object->modified_time)) {
$timestamp = strtotime($object->modified_time);
}
$result = Util::map((array) $object, static::$resultMap);
return compact('timestamp', 'path') + $result;
}
示例9: normalizeObject
protected function normalizeObject(array $object)
{
if (substr($object['name'], -1) === '/') {
return array('path' => trim($object['name'], '/'), 'type' => 'dir');
}
$result = array('type' => 'file');
return array_merge($result, Util::map($object, static::$resultMap));
}
示例10: getVisibility
/**
* {@inheritdoc}
*/
public function getVisibility($path)
{
$metadata = $this->getMetadata($path);
return isset($metadata['visibility']) ? Util::map($metadata, ['visibility' => 'visibility']) : ['visibility' => 'public'];
}
示例11: normalizeResponse
/**
* Normalize a Dropbox response.
*
* @param $response
* @param string $path
*
* @return array
*/
protected function normalizeResponse(array $response, $path = null)
{
$result = ['path' => trim($path ?: $response['path'], '/')];
if (isset($response['modified'])) {
$result['timestamp'] = strtotime($response['modified']);
}
$result = array_merge($result, Util::map($response, static::$resultMap));
$result['type'] = $response['is_dir'] ? 'dir' : 'file';
return $result;
}
示例12: normalizeObject
/**
* Normalize a result from Google
*
* @param string $object
* @param string $path
* @return array file metadata
*/
protected function normalizeObject($object, $path = null)
{
$newObject = array();
foreach ((array) $object as $key => $value) {
if (substr($key, 0, 3) == "*") {
$key = substr($key, 3);
}
$newObject[$key] = $value;
}
$object = $newObject;
if (isset($object["dirname"])) {
$result = array('path' => $object['dirname'] . "/" . $object['id']);
} else {
$result = array('path' => $object['id']);
}
if (isset($object['modifiedDate'])) {
$result['timestamp'] = strtotime($object['modifiedDate']);
}
$result["basename"] = $object["title"];
if ($object['mimeType'] == 'application/vnd.google-apps.folder') {
$result['type'] = 'dir';
$result['path'] = rtrim($result['path'], '/');
$result['dirname'] = Util::dirname($result['path']);
return $result;
}
$result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
$result['dirname'] = Util::dirname($result['path']);
if (isset($result['contents'])) {
$result['contents'] = (string) $result['contents'];
}
return $result;
}
示例13: listContents
/**
* List contents of a directory.
*
* @param string $directory
* @param bool $recursive
*
* @return array
*/
public function listContents($directory = '', $recursive = false)
{
$results = [];
if ($directory != '') {
if (substr($directory, -1) != '/') {
$directory = $directory . '/';
}
}
if ($recursive == false) {
$dirs = $this->storage->getBucket($this->bucket, $directory, null, 10000, '/');
foreach ($dirs as $dir) {
if (!array_key_exists('subdir', $dir)) {
array_push($results, Util::map($dir, ['content_type' => 'type', 'name' => 'path', 'last_modified' => 'timestamp', 'bytes' => 'size']));
}
}
return $results;
} else {
$dirs = $this->storage->getBucket($this->bucket, $directory, null, 10000, '/');
foreach ($dirs as $dir) {
if (!array_key_exists('subdir', $dir)) {
array_push($results, Util::map($dir, ['content_type' => 'type', 'name' => 'path', 'last_modified' => 'timestamp', 'bytes' => 'size']));
} else {
$results = array_merge($results, $this->listContents($dir['subdir'], true));
}
}
return $results;
}
}
示例14: normalizeObject
/**
* Normalize a result from AWS
*
* @param array $object
* @param string $path
* @return array file metadata
*/
protected function normalizeObject(array $object, $path = null)
{
$result = array('path' => $path ?: $this->removePathPrefix($object['Key']));
$result['dirname'] = Util::dirname($result['path']);
if (isset($object['LastModified'])) {
$result['timestamp'] = strtotime($object['LastModified']);
}
if (substr($result['path'], -1) === '/') {
$result['type'] = 'dir';
$result['path'] = rtrim($result['path'], '/');
return $result;
}
$result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
return $result;
}