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

Class MountManager. More...

+ Collaboration diagram for League\Flysystem\MountManager:

Public Member Functions

 __construct (array $filesystems=[])
 Constructor. More...
 
 mountFilesystems (array $filesystems)
 Mount filesystems. More...
 
 mountFilesystem ($prefix, FilesystemInterface $filesystem)
 Mount filesystems. More...
 
 getFilesystem ($prefix)
 Get the filesystem with the corresponding prefix. More...
 
 filterPrefix (array $arguments)
 Retrieve the prefix from an arguments array. More...
 
 listContents ($directory='', $recursive=false)
 
 __call ($method, $arguments)
 Call forwarder. More...
 
 copy ($from, $to, array $config=[])
 
 listWith (array $keys=[], $directory='', $recursive=false)
 List with plugin adapter. More...
 
 move ($from, $to, array $config=[])
 Move a file. More...
 
 invokePluginOnFilesystem ($method, $arguments, $prefix)
 Invoke a plugin on a filesystem mounted on a given prefix. More...
 

Protected Member Functions

 getPrefixAndPath ($path)
 

Protected Attributes

 $filesystems = []
 

Detailed Description

Class MountManager.

Proxies methods to Filesystem (

See also
__call):

@method AdapterInterface getAdapter($prefix) @method Config getConfig($prefix) @method bool has($path) @method bool write($path, $contents, array $config = []) @method bool writeStream($path, $resource, array $config = []) @method bool put($path, $contents, $config = []) @method bool putStream($path, $contents, $config = []) @method string readAndDelete($path) @method bool update($path, $contents, $config = []) @method bool updateStream($path, $resource, $config = []) @method string|false read($path) @method resource|false readStream($path) @method bool rename($path, $newpath) @method bool delete($path) @method bool deleteDir($dirname) @method bool createDir($dirname, $config = []) @method array listFiles($directory = '', $recursive = false) @method array listPaths($directory = '', $recursive = false) @method array getWithMetadata($path, array $metadata) @method string|false getMimetype($path) @method string|false getTimestamp($path) @method string|false getVisibility($path) @method int|false getSize($path); @method bool setVisibility($path, $visibility) @method array|false getMetadata($path) @method Handler get($path, Handler $handler = null) @method Filesystem flushCache() @method void assertPresent($path) @method void assertAbsent($path) @method Filesystem addPlugin(PluginInterface $plugin)

Definition at line 46 of file MountManager.php.

Constructor & Destructor Documentation

◆ __construct()

League\Flysystem\MountManager::__construct ( array  $filesystems = [])

Constructor.

Parameters
FilesystemInterface[]$filesystems[:prefix => Filesystem,]
Exceptions
InvalidArgumentException

Definition at line 62 of file MountManager.php.

63 {
65 }
mountFilesystems(array $filesystems)
Mount filesystems.

References League\Flysystem\MountManager\$filesystems, and League\Flysystem\MountManager\mountFilesystems().

+ Here is the call graph for this function:

Member Function Documentation

◆ __call()

League\Flysystem\MountManager::__call (   $method,
  $arguments 
)

Call forwarder.

Parameters
string$method
array$arguments
Exceptions
InvalidArgumentException
FilesystemNotFoundException
Returns
mixed

Definition at line 184 of file MountManager.php.

185 {
186 list($prefix, $arguments) = $this->filterPrefix($arguments);
187
188 return $this->invokePluginOnFilesystem($method, $arguments, $prefix);
189 }
invokePluginOnFilesystem($method, $arguments, $prefix)
Invoke a plugin on a filesystem mounted on a given prefix.
filterPrefix(array $arguments)
Retrieve the prefix from an arguments array.

References League\Flysystem\MountManager\filterPrefix(), and League\Flysystem\MountManager\invokePluginOnFilesystem().

+ Here is the call graph for this function:

◆ copy()

League\Flysystem\MountManager::copy (   $from,
  $to,
array  $config = [] 
)
Parameters
string$from
string$to
array$config
Exceptions
InvalidArgumentException
FilesystemNotFoundException
Returns
bool

Definition at line 201 of file MountManager.php.

202 {
203 list($prefixFrom, $from) = $this->getPrefixAndPath($from);
204
205 $buffer = $this->getFilesystem($prefixFrom)->readStream($from);
206
207 if ($buffer === false) {
208 return false;
209 }
210
211 list($prefixTo, $to) = $this->getPrefixAndPath($to);
212
213 $result = $this->getFilesystem($prefixTo)->writeStream($to, $buffer, $config);
214
215 if (is_resource($buffer)) {
216 fclose($buffer);
217 }
218
219 return $result;
220 }
$result
getFilesystem($prefix)
Get the filesystem with the corresponding prefix.
$from

References $config, $from, $result, League\Flysystem\MountManager\getFilesystem(), and League\Flysystem\MountManager\getPrefixAndPath().

Referenced by League\Flysystem\MountManager\move().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterPrefix()

League\Flysystem\MountManager::filterPrefix ( array  $arguments)

Retrieve the prefix from an arguments array.

Parameters
array$arguments
Exceptions
InvalidArgumentException
Returns
array [:prefix, :arguments]

Definition at line 133 of file MountManager.php.

134 {
135 if (empty($arguments)) {
136 throw new InvalidArgumentException('At least one argument needed');
137 }
138
139 $path = array_shift($arguments);
140
141 if ( ! is_string($path)) {
142 throw new InvalidArgumentException('First argument should be a string');
143 }
144
145 list($prefix, $path) = $this->getPrefixAndPath($path);
146 array_unshift($arguments, $path);
147
148 return [$prefix, $arguments];
149 }

References $path, and League\Flysystem\MountManager\getPrefixAndPath().

Referenced by League\Flysystem\MountManager\__call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilesystem()

League\Flysystem\MountManager::getFilesystem (   $prefix)

Get the filesystem with the corresponding prefix.

Parameters
string$prefix
Exceptions
FilesystemNotFoundException
Returns
FilesystemInterface

Definition at line 115 of file MountManager.php.

116 {
117 if ( ! isset($this->filesystems[$prefix])) {
118 throw new FilesystemNotFoundException('No filesystem mounted with prefix ' . $prefix);
119 }
120
121 return $this->filesystems[$prefix];
122 }
static filesystems()
Returns the loaded filesystems.

References ILIAS\Filesystem\filesystems().

Referenced by League\Flysystem\MountManager\copy(), League\Flysystem\MountManager\invokePluginOnFilesystem(), and League\Flysystem\MountManager\listContents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrefixAndPath()

League\Flysystem\MountManager::getPrefixAndPath (   $path)
protected
Parameters
string$path
Exceptions
InvalidArgumentException
Returns
string[] [:prefix, :path]

Definition at line 298 of file MountManager.php.

299 {
300 if (strpos($path, '://') < 1) {
301 throw new InvalidArgumentException('No prefix detected in path: ' . $path);
302 }
303
304 return explode('://', $path, 2);
305 }

References $path.

Referenced by League\Flysystem\MountManager\copy(), League\Flysystem\MountManager\filterPrefix(), League\Flysystem\MountManager\listContents(), and League\Flysystem\MountManager\listWith().

+ Here is the caller graph for this function:

◆ invokePluginOnFilesystem()

League\Flysystem\MountManager::invokePluginOnFilesystem (   $method,
  $arguments,
  $prefix 
)

Invoke a plugin on a filesystem mounted on a given prefix.

Parameters
string$method
array$arguments
string$prefix
Exceptions
FilesystemNotFoundException
Returns
mixed

Definition at line 276 of file MountManager.php.

277 {
278 $filesystem = $this->getFilesystem($prefix);
279
280 try {
281 return $this->invokePlugin($method, $arguments, $filesystem);
282 } catch (PluginNotFoundException $e) {
283 // Let it pass, it's ok, don't panic.
284 }
285
286 $callback = [$filesystem, $method];
287
288 return call_user_func_array($callback, $arguments);
289 }
invokePlugin($method, array $arguments, FilesystemInterface $filesystem)
Invoke a plugin by method name.

References League\Flysystem\MountManager\getFilesystem(), and League\Flysystem\Plugin\invokePlugin().

Referenced by League\Flysystem\MountManager\__call(), and League\Flysystem\MountManager\listWith().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listContents()

League\Flysystem\MountManager::listContents (   $directory = '',
  $recursive = false 
)
Parameters
string$directory
bool$recursive
Exceptions
InvalidArgumentException
FilesystemNotFoundException
Returns
array

Definition at line 160 of file MountManager.php.

161 {
162 list($prefix, $directory) = $this->getPrefixAndPath($directory);
163 $filesystem = $this->getFilesystem($prefix);
164 $result = $filesystem->listContents($directory, $recursive);
165
166 foreach ($result as &$file) {
167 $file['filesystem'] = $prefix;
168 }
169
170 return $result;
171 }
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, $result, League\Flysystem\MountManager\getFilesystem(), and League\Flysystem\MountManager\getPrefixAndPath().

+ Here is the call graph for this function:

◆ listWith()

League\Flysystem\MountManager::listWith ( array  $keys = [],
  $directory = '',
  $recursive = false 
)

List with plugin adapter.

Parameters
array$keys
string$directory
bool$recursive
Exceptions
InvalidArgumentException
FilesystemNotFoundException
Returns
array

Definition at line 234 of file MountManager.php.

235 {
236 list($prefix, $directory) = $this->getPrefixAndPath($directory);
237 $arguments = [$keys, $directory, $recursive];
238
239 return $this->invokePluginOnFilesystem('listWith', $arguments, $prefix);
240 }
$keys

References $keys, League\Flysystem\MountManager\getPrefixAndPath(), and League\Flysystem\MountManager\invokePluginOnFilesystem().

+ Here is the call graph for this function:

◆ mountFilesystem()

League\Flysystem\MountManager::mountFilesystem (   $prefix,
FilesystemInterface  $filesystem 
)

Mount filesystems.

Parameters
string$prefix
FilesystemInterface$filesystem
Exceptions
InvalidArgumentException
Returns
$this

Definition at line 95 of file MountManager.php.

96 {
97 if ( ! is_string($prefix)) {
98 throw new InvalidArgumentException(__METHOD__ . ' expects argument #1 to be a string.');
99 }
100
101 $this->filesystems[$prefix] = $filesystem;
102
103 return $this;
104 }

References ILIAS\Filesystem\filesystems().

Referenced by League\Flysystem\MountManager\mountFilesystems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mountFilesystems()

League\Flysystem\MountManager::mountFilesystems ( array  $filesystems)

Mount filesystems.

Parameters
FilesystemInterface[]$filesystems[:prefix => Filesystem,]
Exceptions
InvalidArgumentException
Returns
$this

Definition at line 76 of file MountManager.php.

77 {
78 foreach ($filesystems as $prefix => $filesystem) {
79 $this->mountFilesystem($prefix, $filesystem);
80 }
81
82 return $this;
83 }
mountFilesystem($prefix, FilesystemInterface $filesystem)
Mount filesystems.

References League\Flysystem\MountManager\$filesystems, and League\Flysystem\MountManager\mountFilesystem().

Referenced by League\Flysystem\MountManager\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move()

League\Flysystem\MountManager::move (   $from,
  $to,
array  $config = [] 
)

Move a file.

Parameters
string$from
string$to
array$config
Exceptions
InvalidArgumentException
FilesystemNotFoundException
Returns
bool

Definition at line 254 of file MountManager.php.

255 {
256 $copied = $this->copy($from, $to, $config);
257
258 if ($copied) {
259 return $this->delete($from);
260 }
261
262 return false;
263 }
copy($from, $to, array $config=[])

References $config, $from, and League\Flysystem\MountManager\copy().

+ Here is the call graph for this function:

Field Documentation

◆ $filesystems

League\Flysystem\MountManager::$filesystems = []
protected

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