本文整理汇总了PHP中League\Flysystem\Filesystem::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::has方法的具体用法?PHP Filesystem::has怎么用?PHP Filesystem::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ArrayCollection
function it_returns_flat_data_with_media($channelManager, Filesystem $filesystem, ChannelInterface $channel, LocaleInterface $locale, ProductInterface $product, FileInfoInterface $media1, FileInfoInterface $media2, ProductValueInterface $value1, ProductValueInterface $value2, AttributeInterface $attribute, ProductValueInterface $identifierValue, AttributeInterface $identifierAttribute, $serializer, $productBuilder)
{
$localeCodes = ['en_US'];
$channel->getLocales()->willReturn(new ArrayCollection([$locale]));
$channel->getLocaleCodes()->willReturn($localeCodes);
$productBuilder->addMissingProductValues($product, [$channel], [$locale])->shouldBeCalled();
$media1->getKey()->willReturn('key/to/media1.jpg');
$media2->getKey()->willReturn('key/to/media2.jpg');
$value1->getAttribute()->willReturn($attribute);
$value1->getMedia()->willReturn($media1);
$value2->getAttribute()->willReturn($attribute);
$value2->getMedia()->willReturn($media2);
$attribute->getAttributeType()->willReturn('pim_catalog_image');
$product->getValues()->willReturn([$value1, $value2, $identifierValue]);
$identifierValue->getAttribute()->willReturn($identifierAttribute);
$identifierAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
$product->getIdentifier()->willReturn($identifierValue);
$identifierValue->getData()->willReturn('data');
$filesystem->has('key/to/media1.jpg')->willReturn(true);
$filesystem->has('key/to/media2.jpg')->willReturn(true);
$serializer->normalize($media1, 'flat', ['field_name' => 'media', 'prepare_copy' => true, 'value' => $value1])->willReturn(['normalized_media1']);
$serializer->normalize($media2, 'flat', ['field_name' => 'media', 'prepare_copy' => true, 'value' => $value2])->willReturn(['normalized_media2']);
$serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => $localeCodes, 'decimal_separator' => '.', 'date_format' => 'yyyy-MM-dd'])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$this->setChannel('foobar');
$this->process($product)->shouldReturn(['media' => [['normalized_media1'], ['normalized_media2']], 'product' => ['normalized_product']]);
}
示例3: slash
/**
* {@inheritdoc}
*/
public function slash()
{
$app_path = str_replace(config('path.root'), '', config()->path->app);
$arg_name = studly_case(str_slug($this->input->getArgument('name'), '_'));
$stub = file_get_contents(__DIR__ . '/stubs/makeRoute.stub');
$stub = stubify($stub, ['routeName' => $arg_name, 'prefixRouteName' => strtolower($arg_name)]);
$file_name = $arg_name . 'Routes.php';
$module = $this->input->getArgument('module');
$has_dir = is_dir(config()->path->app . $module);
if ($has_dir === false) {
$this->error('Module not found `' . $module . '`');
return;
}
$module = $this->input->getArgument('module');
if ($this->app->has($module) === false) {
$this->error('Module not found `' . $module . '`');
return;
}
$routes = $module . '/routes/';
if ($this->app->has($routes) === false) {
$this->error('Routes folder not found from your module: `' . $module . '`');
return;
}
$stub = stubify($stub, ['namespace' => path_to_namespace($app_path . $routes), 'controllerNamespace' => path_to_namespace($app_path . $module . '/controllers/')]);
$this->info('Crafting Route...');
if ($this->app->has($file_name)) {
$this->error(' Route already exists!');
return;
}
$this->app->put($routes . $file_name, $stub);
$this->info(' ' . $file_name . ' created!');
$this->callDumpAutoload();
}
示例4: remove
/**
* {@inheritdoc}
*/
public function remove(File $file) : bool
{
$key = $file->getKey();
if ($this->filesystem->has($key)) {
return $this->filesystem->delete($key);
}
return true;
}
示例5: write
protected function write($data)
{
$destination = $this->composer->getClassPath($this->data['name']);
if ($this->force && $this->external->has($destination)) {
$this->external->delete($destination);
}
return $this->external->write($destination, $data);
}
示例6: exists
/**
* Check if key exists.
*
* @param string $key
*
* @return bool
*/
public function exists($key)
{
if (!is_string($key)) {
return false;
}
$file = $this->get_file_name($key);
return $this->filesystem->has($file);
}
示例7: delete
/**
* @param string $providerPrefix
* @param string $uri
* @param string $query
*
* @return bool
*/
public function delete($providerPrefix, $uri, $query)
{
$hash = $this->getHash($providerPrefix, $uri, $query);
if ($this->filesystem->has($hash)) {
return $this->filesystem->delete($hash);
}
return false;
}
示例8: parse
/**
* {@inheritdoc}
*/
public function parse(Configuration $configuration = null)
{
if (!$this->filesystem->has($this->file)) {
throw new ParsingFailed(sprintf('File "%s" not found', $this->file));
}
$fileContents = $this->filesystem->read($this->file);
$parser = new Text($fileContents);
return $parser->parse($configuration);
}
示例9: testAddsNamespaceToSubClass
public function testAddsNamespaceToSubClass()
{
$generator = $this->getGenerator();
$generator->generateForEndpoint("Users/Followers");
static::$content = $generator->getGeneratedTemplate();
$check = $this->filesystem->has('Users/Followers.php');
$this->assertTrue($check);
$this->assertContains("Wubs\\Trakt\\Api\\Users", static::$content);
}
示例10: unpublish
/**
* @param File $file
* @param Version $version
* @param VersionProvider $versionProvider
* @param Linker $linker
* @return bool
*/
public function unpublish(File $file, Version $version, VersionProvider $versionProvider, Linker $linker)
{
$path = $linker->getLink($file, $version, $versionProvider->getExtension($file, $version));
if (!$this->filesystem->has($path)) {
return false;
}
$this->filesystem->delete($path);
return true;
}
示例11: loadFile
/**
* @return false|string
*/
private function loadFile()
{
if (!$this->filesystem->has($this->getFile())) {
$this->filesystem->write($this->getFile(), '');
}
if (!$this->sites) {
$this->sites = $this->filesystem->read($this->file);
}
return $this->sites;
}
示例12: publishesAndUnpublishes
/**
* @test
*/
public function publishesAndUnpublishes()
{
$this->assertFalse($this->filesystem->has($this->path));
$this->assertTrue($this->adapter->publish($this->file, Version::get('xooxer'), $this->vp, $this->linker));
$this->assertTrue($this->filesystem->has($this->path));
$this->assertFalse($this->adapter->publish($this->file, Version::get('xooxer'), $this->vp, $this->linker));
$this->assertTrue($this->adapter->unpublish($this->file, Version::get('xooxer'), $this->vp, $this->linker));
$this->assertFalse($this->filesystem->has($this->path));
$this->assertFalse($this->adapter->unpublish($this->file, Version::get('xooxer'), $this->vp, $this->linker));
}
示例13: fetch
/**
* @inheritdoc
*/
public function fetch($key)
{
if ($this->filesystem->has($key)) {
// The file exist, read it!
$data = @unserialize($this->filesystem->read($key));
if ($data instanceof CacheEntry) {
return $data;
}
}
return;
}
示例14: getFileOrFail
/**
* Checks if the underlying flysystem contains a file of the given name.
*
* @param string $name
*
* @return \League\Flysystem\File|\League\Flysystem\Handler
* @throws Twig_Error_Loader
*/
protected function getFileOrFail($name)
{
if (!$this->filesystem->has($this->resolveTemplateName($name))) {
throw new Twig_Error_Loader('Template could not be found on the given filesystem');
}
$fileObject = $this->filesystem->get($this->resolveTemplateName($name));
if ($fileObject->isDir()) {
throw new Twig_Error_Loader('Cannot use directory as template');
}
return $fileObject;
}
示例15: getData
/**
* Returns the historical price data as a csv string for $ticker
* @param string $ticker
* @param bool $fromCache
* @param bool $saveToCache
* @param bool $return
* @return TickerCollection
*/
public function getData($ticker, $fromCache = true, $saveToCache = true, $return = true)
{
if ($fromCache && $this->fileSystem->has($ticker)) {
return $this->present($ticker, $this->fileSystem->read($ticker));
}
$data = (string) $this->guzzle->request('GET', '', ['query' => ['s' => $ticker, 'ignore' => '.csv']])->getBody();
if ($saveToCache) {
$this->fileSystem->put($ticker, $data);
}
if ($return) {
return $this->present($ticker, $data);
}
}