ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
League\Flysystem\Filesystem Class Reference

array getWithMetadata(string $path, array $metadata) bool forceCopy(string $path, string $newpath) bool forceRename(string $path, string $newpath) array listFiles(string $path = '', boolean $recursive = false) array listPaths(string $path = '', boolean $recursive = false) array listWith(array $keys = [], $directory = '', $recursive = false) More...

+ Inheritance diagram for League\Flysystem\Filesystem:
+ Collaboration diagram for League\Flysystem\Filesystem:

Public Member Functions

 __construct (AdapterInterface $adapter, $config=null)
 Constructor. More...
 
 getAdapter ()
 Get the Adapter. More...
 
 has ($path)
 Check whether a file exists.
Parameters
string$path
Returns
bool
More...
 
 write ($path, $contents, array $config=[])
 Write a new file.
Parameters
string$pathThe path of the new file.
string$contentsThe file contents.
array$configAn optional configuration array.
Exceptions
FileExistsException
Returns
bool True on success, false on failure.
More...
 
 writeStream ($path, $resource, array $config=[])
 Write a new file using a stream.
Parameters
string$pathThe path of the new file.
resource$resourceThe file handle.
array$configAn optional configuration array.
Exceptions
More...
 
 put ($path, $contents, array $config=[])
 Create a file or update if exists.
Parameters
string$pathThe path to the file.
string$contentsThe file contents.
array$configAn optional configuration array.
Returns
bool True on success, false on failure.
More...
 
 putStream ($path, $resource, array $config=[])
 Create a file or update if exists.
Parameters
string$pathThe path to the file.
resource$resourceThe file handle.
array$configAn optional configuration array.
Exceptions
More...
 
 readAndDelete ($path)
 Read and delete a file.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The file contents, or false on failure.
More...
 
 update ($path, $contents, array $config=[])
 Update an existing file.
Parameters
string$pathThe path of the existing file.
string$contentsThe file contents.
array$configAn optional configuration array.
Exceptions
FileNotFoundException
Returns
bool True on success, false on failure.
More...
 
 updateStream ($path, $resource, array $config=[])
 Update an existing file using a stream.
Parameters
string$pathThe path of the existing file.
resource$resourceThe file handle.
array$configAn optional configuration array.
Exceptions
More...
 
 read ($path)
 Read a file.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The file contents or false on failure.
More...
 
 readStream ($path)
 Retrieves a read-stream for a path.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
resource|false The path resource or false on failure.
More...
 
 rename ($path, $newpath)
 Rename a file.
Parameters
string$pathPath to the existing file.
string$newpathThe new path of the file.
Exceptions
FileExistsExceptionThrown if $newpath exists.
FileNotFoundExceptionThrown if $path does not exist.
Returns
bool True on success, false on failure.
More...
 
 copy ($path, $newpath)
 Copy a file.
Parameters
string$pathPath to the existing file.
string$newpathThe new path of the file.
Exceptions
FileExistsExceptionThrown if $newpath exists.
FileNotFoundExceptionThrown if $path does not exist.
Returns
bool True on success, false on failure.
More...
 
 delete ($path)
 Delete a file.
Parameters
string$path
Exceptions
FileNotFoundException
Returns
bool True on success, false on failure.
More...
 
 deleteDir ($dirname)
 Delete a directory.
Parameters
string$dirname
Exceptions
RootViolationExceptionThrown if $dirname is empty.
Returns
bool True on success, false on failure.
More...
 
 createDir ($dirname, array $config=[])
 Create a directory.
Parameters
string$dirnameThe name of the new directory.
array$configAn optional configuration array.
Returns
bool True on success, false on failure.
More...
 
 listContents ($directory='', $recursive=false)
 List contents of a directory.
Parameters
string$directoryThe directory to list.
bool$recursiveWhether to list recursively.
Returns
array A list of file metadata.
More...
 
 getMimetype ($path)
 Get a file's mime-type.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The file mime-type or false on failure.
More...
 
 getTimestamp ($path)
 Get a file's timestamp.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The timestamp or false on failure.
More...
 
 getVisibility ($path)
 Get a file's visibility.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The visibility (public|private) or false on failure.
More...
 
 getSize ($path)
 Get a file's size.
Parameters
string$pathThe path to the file.
Returns
int|false The file size or false on failure.
More...
 
 setVisibility ($path, $visibility)
 Set the visibility for a file.
Parameters
string$pathThe path to the file.
string$visibilityOne of 'public' or 'private'.
Returns
bool True on success, false on failure.
More...
 
 getMetadata ($path)
 Get a file's metadata.
Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
array|false The file metadata or false on failure.
More...
 
 get ($path, Handler $handler=null)
 Get a file/directory handler.
Parameters
string$pathThe path to the file.
Handler$handlerAn optional existing handler to populate.
Returns
Handler Either a file or directory handler.
More...
 
 assertPresent ($path)
 Assert a file is present. More...
 
 assertAbsent ($path)
 Assert a file is absent. More...
 
- Public Member Functions inherited from League\Flysystem\FilesystemInterface
 addPlugin (PluginInterface $plugin)
 Register a plugin. More...
 

Protected Attributes

 $adapter
 

Detailed Description

array getWithMetadata(string $path, array $metadata) bool forceCopy(string $path, string $newpath) bool forceRename(string $path, string $newpath) array listFiles(string $path = '', boolean $recursive = false) array listPaths(string $path = '', boolean $recursive = false) array listWith(array $keys = [], $directory = '', $recursive = false)

Definition at line 18 of file Filesystem.php.

Constructor & Destructor Documentation

◆ __construct()

League\Flysystem\Filesystem::__construct ( AdapterInterface  $adapter,
  $config = null 
)

Constructor.

Parameters
AdapterInterface$adapter
Config | array$config

Definition at line 34 of file Filesystem.php.

References League\Flysystem\Filesystem\$adapter, $config, and League\Flysystem\setConfig().

35  {
36  $this->adapter = $adapter;
37  $this->setConfig($config);
38  }
setConfig($config)
Set the config.
+ Here is the call graph for this function:

Member Function Documentation

◆ assertAbsent()

League\Flysystem\Filesystem::assertAbsent (   $path)

Assert a file is absent.

Parameters
string$pathpath to file
Exceptions
FileExistsException
Returns
void

Definition at line 399 of file Filesystem.php.

References $path, and League\Flysystem\Filesystem\has().

Referenced by League\Flysystem\Filesystem\copy(), League\Flysystem\Filesystem\rename(), League\Flysystem\Filesystem\write(), and League\Flysystem\Filesystem\writeStream().

400  {
401  if ($this->config->get('disable_asserts', false) === false && $this->has($path)) {
402  throw new FileExistsException($path);
403  }
404  }
has($path)
Check whether a file exists.bool
Definition: Filesystem.php:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assertPresent()

League\Flysystem\Filesystem::assertPresent (   $path)

Assert a file is present.

Parameters
string$pathpath to file
Exceptions
FileNotFoundException
Returns
void

Definition at line 383 of file Filesystem.php.

References $path, and League\Flysystem\Filesystem\has().

Referenced by League\Flysystem\Filesystem\copy(), League\Flysystem\Filesystem\delete(), League\Flysystem\Filesystem\getMetadata(), League\Flysystem\Filesystem\getMimetype(), League\Flysystem\Filesystem\getTimestamp(), League\Flysystem\Filesystem\getVisibility(), League\Flysystem\Filesystem\read(), League\Flysystem\Filesystem\readAndDelete(), League\Flysystem\Filesystem\readStream(), League\Flysystem\Filesystem\rename(), League\Flysystem\Filesystem\update(), and League\Flysystem\Filesystem\updateStream().

384  {
385  if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) {
386  throw new FileNotFoundException($path);
387  }
388  }
has($path)
Check whether a file exists.bool
Definition: Filesystem.php:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copy()

League\Flysystem\Filesystem::copy (   $path,
  $newpath 
)

Copy a file.

Parameters
string$pathPath to the existing file.
string$newpathThe new path of the file.
Exceptions
FileExistsExceptionThrown if $newpath exists.
FileNotFoundExceptionThrown if $path does not exist.
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 219 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertAbsent(), League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

220  {
222  $newpath = Util::normalizePath($newpath);
223  $this->assertPresent($path);
224  $this->assertAbsent($newpath);
225 
226  return $this->getAdapter()->copy($path, $newpath);
227  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertAbsent($path)
Assert a file is absent.
Definition: Filesystem.php:399
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ createDir()

League\Flysystem\Filesystem::createDir (   $dirname,
array  $config = [] 
)

Create a directory.

Parameters
string$dirnameThe name of the new directory.
array$configAn optional configuration array.
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 257 of file Filesystem.php.

References $config, League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Util\normalizePath(), and League\Flysystem\prepareConfig().

258  {
259  $dirname = Util::normalizePath($dirname);
260  $config = $this->prepareConfig($config);
261 
262  return (bool) $this->getAdapter()->createDir($dirname, $config);
263  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
+ Here is the call graph for this function:

◆ delete()

League\Flysystem\Filesystem::delete (   $path)

Delete a file.

Parameters
string$path
Exceptions
FileNotFoundException
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 232 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

233  {
235  $this->assertPresent($path);
236 
237  return $this->getAdapter()->delete($path);
238  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ deleteDir()

League\Flysystem\Filesystem::deleteDir (   $dirname)

Delete a directory.

Parameters
string$dirname
Exceptions
RootViolationExceptionThrown if $dirname is empty.
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 243 of file Filesystem.php.

References League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

244  {
245  $dirname = Util::normalizePath($dirname);
246 
247  if ($dirname === '') {
248  throw new RootViolationException('Root directories can not be deleted.');
249  }
250 
251  return (bool) $this->getAdapter()->deleteDir($dirname);
252  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
+ Here is the call graph for this function:

◆ get()

League\Flysystem\Filesystem::get (   $path,
Handler  $handler = null 
)

Get a file/directory handler.

Parameters
string$pathThe path to the file.
Handler$handlerAn optional existing handler to populate.
Returns
Handler Either a file or directory handler.

Implements League\Flysystem\FilesystemInterface.

Definition at line 359 of file Filesystem.php.

References $handler, $metadata, $path, League\Flysystem\Filesystem\getMetadata(), and League\Flysystem\Util\normalizePath().

360  {
362 
363  if ( ! $handler) {
364  $metadata = $this->getMetadata($path);
365  $handler = $metadata['type'] === 'file' ? new File($this, $path) : new Directory($this, $path);
366  }
367 
368  $handler->setPath($path);
369  $handler->setFilesystem($this);
370 
371  return $handler;
372  }
static normalizePath($path)
Normalize path.
Definition: Util.php:82
getMetadata($path)
Get a file's metadata.The path to the file.array|false The file metadata or false on failure...
Definition: Filesystem.php:348
$metadata['__DYNAMIC:1__']
$handler
+ Here is the call graph for this function:

◆ getAdapter()

◆ getMetadata()

League\Flysystem\Filesystem::getMetadata (   $path)

Get a file's metadata.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
array|false The file metadata or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 348 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

Referenced by League\Flysystem\Filesystem\get().

349  {
351  $this->assertPresent($path);
352 
353  return $this->getAdapter()->getMetadata($path);
354  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMimetype()

League\Flysystem\Filesystem::getMimetype (   $path)

Get a file's mime-type.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The file mime-type or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 279 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

280  {
282  $this->assertPresent($path);
283 
284  if ( ! $object = $this->getAdapter()->getMimetype($path)) {
285  return false;
286  }
287 
288  return $object['mimetype'];
289  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
getMimetype($path)
Get a file's mime-type.The path to the file.string|false The file mime-type or false on failure...
Definition: Filesystem.php:279
+ Here is the call graph for this function:

◆ getSize()

League\Flysystem\Filesystem::getSize (   $path)

Get a file's size.

Parameters
string$pathThe path to the file.
Returns
int|false The file size or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 324 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

325  {
327 
328  if (($object = $this->getAdapter()->getSize($path)) === false || ! isset($object['size'])) {
329  return false;
330  }
331 
332  return (int) $object['size'];
333  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
getSize($path)
Get a file's size.The path to the file.int|false The file size or false on failure.
Definition: Filesystem.php:324
+ Here is the call graph for this function:

◆ getTimestamp()

League\Flysystem\Filesystem::getTimestamp (   $path)

Get a file's timestamp.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The timestamp or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 294 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

295  {
297  $this->assertPresent($path);
298 
299  if ( ! $object = $this->getAdapter()->getTimestamp($path)) {
300  return false;
301  }
302 
303  return $object['timestamp'];
304  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
getTimestamp($path)
Get a file's timestamp.The path to the file.string|false The timestamp or false on failure...
Definition: Filesystem.php:294
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ getVisibility()

League\Flysystem\Filesystem::getVisibility (   $path)

Get a file's visibility.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The visibility (public|private) or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 309 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

310  {
312  $this->assertPresent($path);
313 
314  if (($object = $this->getAdapter()->getVisibility($path)) === false) {
315  return false;
316  }
317 
318  return $object['visibility'];
319  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
getVisibility($path)
Get a file's visibility.The path to the file.string|false The visibility (public|private) or false on...
Definition: Filesystem.php:309
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ has()

League\Flysystem\Filesystem::has (   $path)

Check whether a file exists.

Parameters
string$path
Returns
bool

Implements League\Flysystem\FilesystemInterface.

Definition at line 53 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

Referenced by League\Flysystem\Filesystem\assertAbsent(), League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\put(), and League\Flysystem\Filesystem\putStream().

54  {
56 
57  return strlen($path) === 0 ? false : (bool) $this->getAdapter()->has($path);
58  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listContents()

League\Flysystem\Filesystem::listContents (   $directory = '',
  $recursive = false 
)

List contents of a directory.

Parameters
string$directoryThe directory to list.
bool$recursiveWhether to list recursively.
Returns
array A list of file metadata.

Implements League\Flysystem\FilesystemInterface.

Definition at line 268 of file Filesystem.php.

References $contents, League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

269  {
270  $directory = Util::normalizePath($directory);
271  $contents = $this->getAdapter()->listContents($directory, $recursive);
272 
273  return (new ContentListingFormatter($directory, $recursive))->formatListing($contents);
274  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
+ Here is the call graph for this function:

◆ put()

League\Flysystem\Filesystem::put (   $path,
  $contents,
array  $config = [] 
)

Create a file or update if exists.

Parameters
string$pathThe path to the file.
string$contentsThe file contents.
array$configAn optional configuration array.
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 93 of file Filesystem.php.

References $config, $contents, $path, League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Filesystem\has(), League\Flysystem\Util\normalizePath(), and League\Flysystem\prepareConfig().

94  {
96  $config = $this->prepareConfig($config);
97 
98  if ( ! $this->adapter instanceof CanOverwriteFiles && $this->has($path)) {
99  return (bool) $this->getAdapter()->update($path, $contents, $config);
100  }
101 
102  return (bool) $this->getAdapter()->write($path, $contents, $config);
103  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
has($path)
Check whether a file exists.bool
Definition: Filesystem.php:53
+ Here is the call graph for this function:

◆ putStream()

League\Flysystem\Filesystem::putStream (   $path,
  $resource,
array  $config = [] 
)

Create a file or update if exists.

Parameters
string$pathThe path to the file.
resource$resourceThe file handle.
array$configAn optional configuration array.
Exceptions

Implements League\Flysystem\FilesystemInterface.

Definition at line 108 of file Filesystem.php.

References $config, $path, League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Filesystem\has(), League\Flysystem\Util\normalizePath(), League\Flysystem\prepareConfig(), and League\Flysystem\Util\rewindStream().

109  {
110  if ( ! is_resource($resource)) {
111  throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
112  }
113 
115  $config = $this->prepareConfig($config);
116  Util::rewindStream($resource);
117 
118  if ( ! $this->adapter instanceof CanOverwriteFiles &&$this->has($path)) {
119  return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
120  }
121 
122  return (bool) $this->getAdapter()->writeStream($path, $resource, $config);
123  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
static rewindStream($resource)
Rewind a stream.
Definition: Util.php:248
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
has($path)
Check whether a file exists.bool
Definition: Filesystem.php:53
+ Here is the call graph for this function:

◆ read()

League\Flysystem\Filesystem::read (   $path)

Read a file.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The file contents or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 176 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

Referenced by League\Flysystem\Filesystem\readAndDelete().

177  {
179  $this->assertPresent($path);
180 
181  if ( ! ($object = $this->getAdapter()->read($path))) {
182  return false;
183  }
184 
185  return $object['contents'];
186  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
read($path)
Read a file.The path to the file.string|false The file contents or false on failure.
Definition: Filesystem.php:176
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readAndDelete()

League\Flysystem\Filesystem::readAndDelete (   $path)

Read and delete a file.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
string|false The file contents, or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 128 of file Filesystem.php.

References $contents, $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Util\normalizePath(), and League\Flysystem\Filesystem\read().

129  {
131  $this->assertPresent($path);
132  $contents = $this->read($path);
133 
134  if ($contents === false) {
135  return false;
136  }
137 
138  $this->delete($path);
139 
140  return $contents;
141  }
static normalizePath($path)
Normalize path.
Definition: Util.php:82
read($path)
Read a file.The path to the file.string|false The file contents or false on failure.
Definition: Filesystem.php:176
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ readStream()

League\Flysystem\Filesystem::readStream (   $path)

Retrieves a read-stream for a path.

Parameters
string$pathThe path to the file.
Exceptions
FileNotFoundException
Returns
resource|false The path resource or false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 191 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

192  {
194  $this->assertPresent($path);
195 
196  if ( ! $object = $this->getAdapter()->readStream($path)) {
197  return false;
198  }
199 
200  return $object['stream'];
201  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
readStream($path)
Retrieves a read-stream for a path.The path to the file.resource|false The path resource or false on ...
Definition: Filesystem.php:191
+ Here is the call graph for this function:

◆ rename()

League\Flysystem\Filesystem::rename (   $path,
  $newpath 
)

Rename a file.

Parameters
string$pathPath to the existing file.
string$newpathThe new path of the file.
Exceptions
FileExistsExceptionThrown if $newpath exists.
FileNotFoundExceptionThrown if $path does not exist.
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 206 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\assertAbsent(), League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

207  {
209  $newpath = Util::normalizePath($newpath);
210  $this->assertPresent($path);
211  $this->assertAbsent($newpath);
212 
213  return (bool) $this->getAdapter()->rename($path, $newpath);
214  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertAbsent($path)
Assert a file is absent.
Definition: Filesystem.php:399
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ setVisibility()

League\Flysystem\Filesystem::setVisibility (   $path,
  $visibility 
)

Set the visibility for a file.

Parameters
string$pathThe path to the file.
string$visibilityOne of 'public' or 'private'.
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 338 of file Filesystem.php.

References $path, League\Flysystem\Filesystem\getAdapter(), and League\Flysystem\Util\normalizePath().

339  {
341 
342  return (bool) $this->getAdapter()->setVisibility($path, $visibility);
343  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
+ Here is the call graph for this function:

◆ update()

League\Flysystem\Filesystem::update (   $path,
  $contents,
array  $config = [] 
)

Update an existing file.

Parameters
string$pathThe path of the existing file.
string$contentsThe file contents.
array$configAn optional configuration array.
Exceptions
FileNotFoundException
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 146 of file Filesystem.php.

References $config, $contents, $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Util\normalizePath(), and League\Flysystem\prepareConfig().

147  {
149  $config = $this->prepareConfig($config);
150 
151  $this->assertPresent($path);
152 
153  return (bool) $this->getAdapter()->update($path, $contents, $config);
154  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ updateStream()

League\Flysystem\Filesystem::updateStream (   $path,
  $resource,
array  $config = [] 
)

Update an existing file using a stream.

Parameters
string$pathThe path of the existing file.
resource$resourceThe file handle.
array$configAn optional configuration array.
Exceptions

Implements League\Flysystem\FilesystemInterface.

Definition at line 159 of file Filesystem.php.

References $config, $path, League\Flysystem\Filesystem\assertPresent(), League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Util\normalizePath(), League\Flysystem\prepareConfig(), and League\Flysystem\Util\rewindStream().

160  {
161  if ( ! is_resource($resource)) {
162  throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
163  }
164 
166  $config = $this->prepareConfig($config);
167  $this->assertPresent($path);
168  Util::rewindStream($resource);
169 
170  return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
171  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
static rewindStream($resource)
Rewind a stream.
Definition: Util.php:248
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
assertPresent($path)
Assert a file is present.
Definition: Filesystem.php:383
+ Here is the call graph for this function:

◆ write()

League\Flysystem\Filesystem::write (   $path,
  $contents,
array  $config = [] 
)

Write a new file.

Parameters
string$pathThe path of the new file.
string$contentsThe file contents.
array$configAn optional configuration array.
Exceptions
FileExistsException
Returns
bool True on success, false on failure.

Implements League\Flysystem\FilesystemInterface.

Definition at line 63 of file Filesystem.php.

References $config, $contents, $path, League\Flysystem\Filesystem\assertAbsent(), League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Util\normalizePath(), and League\Flysystem\prepareConfig().

64  {
66  $this->assertAbsent($path);
67  $config = $this->prepareConfig($config);
68 
69  return (bool) $this->getAdapter()->write($path, $contents, $config);
70  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertAbsent($path)
Assert a file is absent.
Definition: Filesystem.php:399
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
+ Here is the call graph for this function:

◆ writeStream()

League\Flysystem\Filesystem::writeStream (   $path,
  $resource,
array  $config = [] 
)

Write a new file using a stream.

Parameters
string$pathThe path of the new file.
resource$resourceThe file handle.
array$configAn optional configuration array.
Exceptions

Implements League\Flysystem\FilesystemInterface.

Definition at line 75 of file Filesystem.php.

References $config, $path, League\Flysystem\Filesystem\assertAbsent(), League\Flysystem\Filesystem\getAdapter(), League\Flysystem\Util\normalizePath(), League\Flysystem\prepareConfig(), and League\Flysystem\Util\rewindStream().

76  {
77  if ( ! is_resource($resource)) {
78  throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
79  }
80 
82  $this->assertAbsent($path);
83  $config = $this->prepareConfig($config);
84 
85  Util::rewindStream($resource);
86 
87  return (bool) $this->getAdapter()->writeStream($path, $resource, $config);
88  }
getAdapter()
Get the Adapter.
Definition: Filesystem.php:45
static normalizePath($path)
Normalize path.
Definition: Util.php:82
assertAbsent($path)
Assert a file is absent.
Definition: Filesystem.php:399
static rewindStream($resource)
Rewind a stream.
Definition: Util.php:248
prepareConfig(array $config)
Convert a config array to a Config object with the correct fallback.
+ Here is the call graph for this function:

Field Documentation

◆ $adapter

League\Flysystem\Filesystem::$adapter
protected

The documentation for this class was generated from the following file: