Primo Committ
This commit is contained in:
33
vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php
vendored
Normal file
33
vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
use LogicException;
|
||||
|
||||
trait NotSupportingVisibilityTrait
|
||||
{
|
||||
/**
|
||||
* Get the visibility of a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function getVisibility($path)
|
||||
{
|
||||
throw new LogicException(get_class($this) . ' does not support visibility. Path: ' . $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility for a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $visibility
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function setVisibility($path, $visibility)
|
||||
{
|
||||
throw new LogicException(get_class($this) . ' does not support visibility. Path: ' . $path . ', visibility: ' . $visibility);
|
||||
}
|
||||
}
|
||||
51
vendor/league/flysystem/src/Adapter/Polyfill/StreamedCopyTrait.php
vendored
Normal file
51
vendor/league/flysystem/src/Adapter/Polyfill/StreamedCopyTrait.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
|
||||
trait StreamedCopyTrait
|
||||
{
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $newpath
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($path, $newpath)
|
||||
{
|
||||
$response = $this->readStream($path);
|
||||
|
||||
if ($response === false || ! is_resource($response['stream'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->writeStream($newpath, $response['stream'], new Config());
|
||||
|
||||
if ($result !== false && is_resource($response['stream'])) {
|
||||
fclose($response['stream']);
|
||||
}
|
||||
|
||||
return $result !== false;
|
||||
}
|
||||
|
||||
// Required abstract method
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function readStream($path);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function writeStream($path, $resource, Config $config);
|
||||
}
|
||||
44
vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php
vendored
Normal file
44
vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
/**
|
||||
* A helper for adapters that only handle strings to provide read streams.
|
||||
*/
|
||||
trait StreamedReadingTrait
|
||||
{
|
||||
/**
|
||||
* Reads a file as a stream.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*
|
||||
* @see League\Flysystem\ReadInterface::readStream()
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
if ( ! $data = $this->read($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stream = fopen('php://temp', 'w+b');
|
||||
fwrite($stream, $data['contents']);
|
||||
rewind($stream);
|
||||
$data['stream'] = $stream;
|
||||
unset($data['contents']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array|false
|
||||
*
|
||||
* @see League\Flysystem\ReadInterface::read()
|
||||
*/
|
||||
abstract public function read($path);
|
||||
}
|
||||
9
vendor/league/flysystem/src/Adapter/Polyfill/StreamedTrait.php
vendored
Normal file
9
vendor/league/flysystem/src/Adapter/Polyfill/StreamedTrait.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
trait StreamedTrait
|
||||
{
|
||||
use StreamedReadingTrait;
|
||||
use StreamedWritingTrait;
|
||||
}
|
||||
60
vendor/league/flysystem/src/Adapter/Polyfill/StreamedWritingTrait.php
vendored
Normal file
60
vendor/league/flysystem/src/Adapter/Polyfill/StreamedWritingTrait.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\Util;
|
||||
|
||||
trait StreamedWritingTrait
|
||||
{
|
||||
/**
|
||||
* Stream fallback delegator.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
* @param string $fallback
|
||||
*
|
||||
* @return mixed fallback result
|
||||
*/
|
||||
protected function stream($path, $resource, Config $config, $fallback)
|
||||
{
|
||||
Util::rewindStream($resource);
|
||||
$contents = stream_get_contents($resource);
|
||||
$fallbackCall = [$this, $fallback];
|
||||
|
||||
return call_user_func($fallbackCall, $path, $contents, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write using a stream.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
*
|
||||
* @return mixed false or file metadata
|
||||
*/
|
||||
public function writeStream($path, $resource, Config $config)
|
||||
{
|
||||
return $this->stream($path, $resource, $config, 'write');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a file using a stream.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config Config object or visibility setting
|
||||
*
|
||||
* @return mixed false of file metadata
|
||||
*/
|
||||
public function updateStream($path, $resource, Config $config)
|
||||
{
|
||||
return $this->stream($path, $resource, $config, 'update');
|
||||
}
|
||||
|
||||
// Required abstract methods
|
||||
abstract public function write($pash, $contents, Config $config);
|
||||
abstract public function update($pash, $contents, Config $config);
|
||||
}
|
||||
Reference in New Issue
Block a user