本文整理汇总了PHP中Gaufrette\Filesystem::listKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::listKeys方法的具体用法?PHP Filesystem::listKeys怎么用?PHP Filesystem::listKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaufrette\Filesystem
的用法示例。
在下文中一共展示了Filesystem::listKeys方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFiles
/** @inheritDoc */
public function getFiles($path = '')
{
$keys = $this->gaufrette->listKeys($this->getGaufrettePath($path));
$files = new ArrayCollection($keys['keys']);
return $files->map(function ($path) {
return new File($this, $path);
});
}
示例2: getArchives
/**
* {@inheritdoc}
*/
public function getArchives(JobExecution $jobExecution)
{
$archives = array();
$keys = $this->filesystem->listKeys(dirname($this->getRelativeArchivePath($jobExecution)));
foreach ($keys['keys'] as $key) {
$archives[basename($key)] = $key;
}
return $archives;
}
示例3: getChildren
/**
* {@inheritdoc}
*/
public function getChildren()
{
$children = array();
$keys = $this->filesystem->listKeys($this->prefix);
foreach ($this->getDirectories($keys['dirs']) as $dir) {
$children[] = $this->getChild($dir);
}
foreach ($this->getFiles($keys['keys']) as $file) {
$children[] = $this->getChild($file);
}
return $children;
}
示例4: getFiles
/**
* @param $path
* @return array|\Cocoders\FileSource\File[]
*/
public function getFiles($path)
{
$listedKeys = $this->filesystem->listKeys($path);
$files = [];
foreach ($listedKeys['keys'] as $key) {
$filePath = $this->tmpPath . '/' . $key;
$this->createBaseDirectory($filePath);
if ($this->isNotInRootDir($filePath)) {
file_put_contents($filePath, $this->filesystem->read($key));
$files[] = new File($filePath);
}
}
return $files;
}
示例5: getFiles
/**
* Recursively list the files in the given directory path.
*
* @param string $path The directory path on this filesystem
*
* @return File[]
*/
public function getFiles($path = '')
{
$keys = $this->gaufrette->listKeys($this->getGaufrettePath($path));
$filesystem = $this;
return array_map(function ($path) use($filesystem) {
return new File($filesystem, $path);
}, $keys['keys']);
}
示例6:
function it_saves_content_of_files_from_gaufrette_at_local_disk(Filesystem $filesystem)
{
$filesystem->listKeys('test')->willReturn(['keys' => ['test/aaa/z.txt', 'test/aaa/test2.txt', 'test.txt'], 'dirs' => ['test/aaa']]);
$filesystem->read('test/aaa/z.txt')->willReturn('Some content');
$filesystem->read('test/aaa/test2.txt')->willReturn('Other text content');
$files = $this->getFiles('test');
$files[0]->shouldBeAnInstanceOf('Cocoders\\FileSource\\File');
$files[0]->shouldHaveContent('Some content');
$files[1]->shouldBeAnInstanceOf('Cocoders\\FileSource\\File');
$files[1]->shouldHaveContent('Other text content');
}
示例7: iShouldSeeIn
/**
* @Then I should see :fileKey
* @Then I should see :fileKey in :key
*/
public function iShouldSeeIn($fileKey, $key = '')
{
$outputArray = [];
$list = new RecursiveIteratorIterator(new RecursiveArrayIterator($this->filesystem->listKeys($key)));
foreach ($list as $sub) {
$subArray = $list->getSubIterator();
if ($subArray === $fileKey) {
$outputArray[] = iterator_to_array($subArray);
}
}
return count($outputArray) > 0;
}
示例8: execute
/**
* @param string $targetPath
* @param array $replacePatterns
* @return mixed|void
*/
public function execute($targetPath = '', array $replacePatterns = array())
{
$adapter = new LocalAdapter($targetPath);
$filesystem = new Filesystem($adapter);
$listKeys = $filesystem->listKeys();
if (count($replacePatterns) > 0) {
foreach ($listKeys['keys'] as $file) {
if (!@strstr(mime_content_type($targetPath . $file), 'image') && !@strstr($file, '.git') && !@strstr($file, '.svn')) {
$filesystem->write($file, $this->replaceContent($replacePatterns, $filesystem->read($file)), TRUE);
}
}
}
}
示例9: fetchRemoteFilesAction
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function fetchRemoteFilesAction(Request $request)
{
$provider = InputHelper::string($request->request->get('provider'));
$path = InputHelper::string($request->request->get('path', ''));
$dispatcher = $this->factory->getDispatcher();
$name = AssetEvents::ASSET_ON_REMOTE_BROWSE;
if (!$dispatcher->hasListeners($name)) {
return $this->sendJsonResponse(array('success' => 0));
}
/** @var \Mautic\PluginBundle\Helper\IntegrationHelper $integrationHelper */
$integrationHelper = $this->factory->getHelper('integration');
/** @var \Mautic\PluginBundle\Integration\AbstractIntegration $integration */
$integration = $integrationHelper->getIntegrationObject($provider);
$event = new RemoteAssetBrowseEvent($integration);
$dispatcher->dispatch($name, $event);
if (!($adapter = $event->getAdapter())) {
return $this->sendJsonResponse(array('success' => 0));
}
$connector = new Filesystem($adapter);
$output = $this->renderView('MauticAssetBundle:Remote:list.html.php', array('connector' => $connector, 'integration' => $integration, 'items' => $connector->listKeys($path)));
return $this->sendJsonResponse(array('success' => 1, 'output' => $output));
}
示例10: fileAction
/**
* Get Virtual Files Action
*
* @param string $file
*
* @throws NotFoundHttpException
* @return Response
*/
public function fileAction($file = null)
{
if (null == $file) {
return $this->redirect($this->generateUrl('vfs_files', array('file' => '/')));
}
$cacheDirectory = $this->getParameter('adapter_cache_dir');
$local = new LocalAdapter($cacheDirectory, true);
$localadapter = new LocalAdapter($this->getParameter('adapter_files'));
$adapter = new CacheAdapter($localadapter, $local, 3600);
$fsAvatar = new Filesystem($adapter);
if ($this->endswith($file, '/')) {
if ($fsAvatar->has($file)) {
$this->gvars['title'] = $this->translate('indexof', array('%dir%' => $this->generateUrl('vfs_files', array('file' => $file))));
$this->gvars['pagetitle'] = $this->translate('indexof_raw', array('%dir%' => $this->generateUrl('vfs_files', array('file' => $file))));
$path = substr($file, 1);
$fs = $fsAvatar->listKeys($path);
$listfiles = array();
foreach ($fs['dirs'] as $key) {
$fulldir = $key . '/';
$dirname = $key;
if (substr($key, 0, strlen($path)) == $path) {
$dirname = substr($dirname, strlen($path));
}
if (!strstr($dirname, '/')) {
$listfiles[$fulldir] = $dirname;
}
}
foreach ($fs['keys'] as $key) {
$fullfile = $key;
$filename = $key;
if (substr($key, 0, strlen($path)) == $path) {
$filename = substr($filename, strlen($path));
}
if (!strstr($filename, '/')) {
$listfiles[$fullfile] = $filename;
}
}
$this->gvars['fs'] = $listfiles;
return $this->renderResponse('AcfResBundle:Vfs:list_files.html.twig', $this->gvars);
} else {
throw new NotFoundHttpException();
}
}
if ($fsAvatar->has($file)) {
if ($fsAvatar->getAdapter()->isDirectory($file)) {
$file .= '/';
return $this->redirect($this->generateUrl('vfs_files', array('file' => $file)));
}
$reqFile = $fsAvatar->get($file);
$response = new Response();
$response->headers->set('Content-Type', 'binary');
$response->setContent($reqFile->getContent());
return $response;
} else {
throw new NotFoundHttpException();
}
}