本文整理汇总了PHP中League\Flysystem\Util::pathinfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::pathinfo方法的具体用法?PHP Util::pathinfo怎么用?PHP Util::pathinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Util
的用法示例。
在下文中一共展示了Util::pathinfo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeContents
/**
* {@inheritdoc}
*/
public function storeContents($directory, array $contents, $recursive)
{
if ($recursive) {
return $contents;
}
foreach ($contents as $index => $object) {
$pathinfo = Util::pathinfo($object['path']);
$object = array_merge($pathinfo, $object);
if (!$recursive && $object['dirname'] !== $directory) {
unset($contents[$index]);
continue;
}
$contents[$index] = $object;
}
return $contents;
}
示例2: testMetaGetters
/**
* @dataProvider metaGetterProvider
*
* @param $method
* @param $key
* @param $value
*/
public function testMetaGetters($method, $key, $value)
{
$cache = new Memory();
$this->assertFalse($cache->{$method}('path.txt'));
$cache->updateObject('path.txt', $object = ['path' => 'path.txt', 'type' => 'file', $key => $value] + Util::pathinfo('path.txt'), true);
$this->assertEquals($object, $cache->{$method}('path.txt'));
$this->assertEquals($object, $cache->getMetadata('path.txt'));
}
示例3: 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']);
}
示例4: listContents
/**
* {@inheritdoc}
*/
public function listContents($directory = '', $recursive = false)
{
$directory = Util::normalizePath($directory);
$contents = $this->getAdapter()->listContents($directory, $recursive);
$mapper = function ($entry) use($directory, $recursive) {
if ($entry['path'] === false && (!empty($directory) && strpos($entry['path'], $directory) === false)) {
return false;
}
$entry = $entry + Util::pathinfo($entry['path']);
if ($recursive === false && Util::dirname($entry['path']) !== $directory) {
return false;
}
return $entry;
};
$listing = array_values(array_filter(array_map($mapper, $contents)));
usort($listing, function ($a, $b) {
return strcasecmp($a['path'], $b['path']);
});
return $listing;
}
示例5: ensureParentDirectories
/**
* Ensure parent directories of an object
*
* @param string $path object path
*/
public function ensureParentDirectories($path)
{
$object = $this->cache[$path];
while ($object['dirname'] !== '' && !isset($this->cache[$object['dirname']])) {
$object = Util::pathinfo($object['dirname']);
$object['type'] = 'dir';
$this->cache[$object['path']] = $object;
}
}
示例6: listContents
/**
* List the filesystem contents.
*
* @param string $directory
* @param bool $recursive
*
* @return array contents
*/
public function listContents($directory = '', $recursive = false)
{
$directory = Util::normalizePath($directory);
$contents = $this->adapter->listContents($directory, $recursive);
$mapper = function ($entry) use($directory, $recursive) {
$entry = $entry + Util::pathinfo($entry['path']);
if (!empty($directory) && strpos($entry['path'], $directory) === false) {
return false;
}
if ($recursive === false && Util::dirname($entry['path']) !== $directory) {
return false;
}
return $entry;
};
return array_values(array_filter(array_map($mapper, $contents)));
}
示例7: addPathInfo
private function addPathInfo(array $entry)
{
return $entry + Util::pathinfo($entry['path']);
}
示例8: getPathInfo
protected function getPathInfo($path)
{
$info = Util::pathinfo('/' . Util::normalizePath($path));
$info['path'] = ltrim($info['path'], '/');
$info['dirname'] = ltrim($info['dirname'], '/');
if (empty($info['basename'])) {
$info['basename'] = '.';
}
return $info;
}
示例9: listContents
/**
* @inheritdoc
*/
public function listContents($directory = '', $recursive = false)
{
$directory = Util::normalizePath($directory);
$adapter = $this->getAdapter();
$separator = $adapter instanceof Local ? DIRECTORY_SEPARATOR : '/';
$contents = $adapter->listContents($directory, $recursive);
$mapper = function ($entry) use($directory, $recursive, $separator) {
if (strlen($entry['path']) === 0 || !empty($directory) && strpos($entry['path'], $directory . $separator) === false || $recursive === false && Util::dirname($entry['path']) !== $directory) {
return false;
}
return $entry + Util::pathinfo($entry['path']);
};
$listing = array_values(array_filter(array_map($mapper, $contents)));
usort($listing, function ($a, $b) {
return strcasecmp($a['path'], $b['path']);
});
return $listing;
}
示例10: testListContents
public function testListContents()
{
$rawListing = [['path' => 'other_root/file.txt'], ['path' => 'valid/to_deep/file.txt'], ['path' => 'valid/file.txt']];
$expected = [Util::pathinfo('valid/file.txt')];
$this->prophecy->listContents('valid', false)->willReturn($rawListing);
$output = $this->filesystem->listContents('valid', false);
$this->assertEquals($expected, $output);
}
示例11: listContents
/**
* @inheritdoc
*/
public function listContents($directory = '', $recursive = false)
{
$directory = Util::normalizePath($directory);
$contents = $this->getAdapter()->listContents($directory, $recursive);
$filter = function (array $entry) use($directory, $recursive) {
if (empty($entry['path']) && $entry['path'] !== '0') {
return false;
}
if ($recursive) {
return $directory === '' || strpos($entry['path'], $directory . '/') === 0;
}
return Util::dirname($entry['path']) === $directory;
};
$mapper = function (array $entry) {
return $entry + Util::pathinfo($entry['path']);
};
$listing = array_values(array_map($mapper, array_filter($contents, $filter)));
usort($listing, function ($a, $b) {
return strcasecmp($a['path'], $b['path']);
});
return $listing;
}