Elgg  Version 5.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Elgg\Filesystem\Directory\Fly Class Reference

A wrapper around Flysystem that implements Elgg's filesystem API. More...

Inheritance diagram for Elgg\Filesystem\Directory\Fly:
Elgg\Filesystem\Directory

Public Member Functions

 __construct (Filesystem $filesystem, $local_path= '', $chroot= '')
 Use one of the static factory functions to create an instance. More...
 
 chroot ($path)
 Returns a subdirectory with access limited to the given directory.
Parameters
string$pathThe path relative to this directory to chroot to.
Returns
Directory A new directory instance.
Exceptions
InvalidArgumentException
More...
 
 isFile ($path)
 Whether this directory has an existing file at the given location.
Parameters
string$pathThe relative path within this directory
Returns
boolean
Exceptions
InvalidArgumentException
More...
 
 getContents ($path)
 Read the file off the filesystem.
Parameters
string$pathThe directory-relative path to the target file.
Returns
string Empty string if the file doesn't exist.
Exceptions
InvalidArgumentException
More...
 
 getFile ($path)
 A reference to the file at the given path, even if it doesn't exist yet.However, will throw an exception if the file is already a directory.
Parameters
string$pathThe path to the file, relative to this directory.
Returns
File
Exceptions
InvalidArgumentException
More...
 
 getFiles ($path= '', $recursive=true)
 List the files in the given directory path.
Parameters
string$pathThe subdirectory path within this directory
bool$recursiveFind files recursively
Returns
<File>
Exceptions
InvalidArgumentException
More...
 
 getDirectories ($path= '', $recursive=true)
 List the directories in the given directory path.
Parameters
string$pathThe subdirectory path within this directory
bool$recursiveFind directories recursively
Returns
<Directory>
Exceptions
InvalidArgumentException
More...
 
 getPath ($path= '')
 Get the absolute path to the given directory-relative path.
Parameters
string$pathA file/directory path within this directory.
Returns
string
Exceptions
InvalidArgumentException
More...
 
 includeFile ($path)
 Do a PHP include of the file and return the result.NB: This only really works with local filesystems amirite?
Parameters
string$pathFilesystem-relative path for the file to include.
Returns
mixed
Exceptions
InvalidArgumentException
More...
 
 putContents ($path, $content)
 Write a file, overwriting the contents if necessary.
Parameters
string$pathThe path to the file.
string$contentThe literal text content of the file.
Returns
void
Exceptions
InvalidArgumentException
More...
 

Static Public Member Functions

static createLocal ($path)
 Shorthand for generating a new local filesystem. More...
 
static createInMemory ()
 Shorthand for generating a new in-memory-only filesystem. More...
 

Protected Member Functions

 getEntries ($path= '', $recursive=true, $types=['file', 'dir'])
 List the files and directories in the given directory path. More...
 

Detailed Description

A wrapper around Flysystem that implements Elgg's filesystem API.

Since
1.10.0

Definition at line 20 of file Fly.php.

Constructor & Destructor Documentation

Elgg\Filesystem\Directory\Fly::__construct ( Filesystem  $filesystem,
  $local_path = '',
  $chroot = '' 
)

Use one of the static factory functions to create an instance.

Parameters
Filesystem$filesystemThe underlying filesystem implementation. It must have the 'ListFiles' plugin.
string$local_pathOnly applicable for local filesystem.
string$chrootPath relative to the underlying filesystem root.

Definition at line 44 of file Fly.php.

Member Function Documentation

Elgg\Filesystem\Directory\Fly::chroot (   $path)

Returns a subdirectory with access limited to the given directory.

Parameters
string$pathThe path relative to this directory to chroot to.
Returns
Directory A new directory instance.
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 53 of file Fly.php.

static Elgg\Filesystem\Directory\Fly::createInMemory ( )
static

Shorthand for generating a new in-memory-only filesystem.

Returns
Directory

Definition at line 189 of file Fly.php.

static Elgg\Filesystem\Directory\Fly::createLocal (   $path)
static

Shorthand for generating a new local filesystem.

Parameters
string$pathabsolute path to directory on local filesystem.
Returns
Directory

Definition at line 179 of file Fly.php.

Elgg\Filesystem\Directory\Fly::getContents (   $path)

Read the file off the filesystem.

Parameters
string$pathThe directory-relative path to the target file.
Returns
string Empty string if the file doesn't exist.
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 79 of file Fly.php.

Elgg\Filesystem\Directory\Fly::getDirectories (   $path = '',
  $recursive = true 
)

List the directories in the given directory path.

Parameters
string$pathThe subdirectory path within this directory
bool$recursiveFind directories recursively
Returns
<Directory>
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 106 of file Fly.php.

Elgg\Filesystem\Directory\Fly::getEntries (   $path = '',
  $recursive = true,
  $types = ['file',
'dir']   
)
protected

List the files and directories in the given directory path.

Parameters
string$pathThe subdirectory path within this directory
bool$recursiveFind files and directories recursively
string[]$types Entry types to return ('file' and/or 'dir')
Returns
Collection<File|Directory>

Definition at line 119 of file Fly.php.

Elgg\Filesystem\Directory\Fly::getFile (   $path)

A reference to the file at the given path, even if it doesn't exist yet.However, will throw an exception if the file is already a directory.

Parameters
string$pathThe path to the file, relative to this directory.
Returns
File
Exceptions
InvalidArgumentException

Exceptions
RuntimeException

Implements Elgg\Filesystem\Directory.

Definition at line 88 of file Fly.php.

Elgg\Filesystem\Directory\Fly::getFiles (   $path = '',
  $recursive = true 
)

List the files in the given directory path.

Parameters
string$pathThe subdirectory path within this directory
bool$recursiveFind files recursively
Returns
<File>
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 99 of file Fly.php.

Elgg\Filesystem\Directory\Fly::getPath (   $path = '')

Get the absolute path to the given directory-relative path.

Parameters
string$pathA file/directory path within this directory.
Returns
string
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 141 of file Fly.php.

Elgg\Filesystem\Directory\Fly::includeFile (   $path)

Do a PHP include of the file and return the result.NB: This only really works with local filesystems amirite?

Parameters
string$pathFilesystem-relative path for the file to include.
Returns
mixed
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 161 of file Fly.php.

Elgg\Filesystem\Directory\Fly::isFile (   $path)

Whether this directory has an existing file at the given location.

Parameters
string$pathThe relative path within this directory
Returns
boolean
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 72 of file Fly.php.

Elgg\Filesystem\Directory\Fly::putContents (   $path,
  $content 
)

Write a file, overwriting the contents if necessary.

Parameters
string$pathThe path to the file.
string$contentThe literal text content of the file.
Returns
void
Exceptions
InvalidArgumentException

Implements Elgg\Filesystem\Directory.

Definition at line 168 of file Fly.php.


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