Upgrade framework
This commit is contained in:
30
vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php
vendored
Normal file
30
vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UrlGeneration;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\UnableToGeneratePublicUrl;
|
||||
|
||||
final class ChainedPublicUrlGenerator implements PublicUrlGenerator
|
||||
{
|
||||
/**
|
||||
* @param PublicUrlGenerator[] $generators
|
||||
*/
|
||||
public function __construct(private iterable $generators)
|
||||
{
|
||||
}
|
||||
|
||||
public function publicUrl(string $path, Config $config): string
|
||||
{
|
||||
foreach ($this->generators as $generator) {
|
||||
try {
|
||||
return $generator->publicUrl($path, $config);
|
||||
} catch (UnableToGeneratePublicUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnableToGeneratePublicUrl('No supported public url generator found.', $path);
|
||||
}
|
||||
}
|
||||
23
vendor/league/flysystem/src/UrlGeneration/PrefixPublicUrlGenerator.php
vendored
Normal file
23
vendor/league/flysystem/src/UrlGeneration/PrefixPublicUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UrlGeneration;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\PathPrefixer;
|
||||
|
||||
class PrefixPublicUrlGenerator implements PublicUrlGenerator
|
||||
{
|
||||
private PathPrefixer $prefixer;
|
||||
|
||||
public function __construct(string $urlPrefix)
|
||||
{
|
||||
$this->prefixer = new PathPrefixer($urlPrefix, '/');
|
||||
}
|
||||
|
||||
public function publicUrl(string $path, Config $config): string
|
||||
{
|
||||
return $this->prefixer->prefixPath($path);
|
||||
}
|
||||
}
|
||||
16
vendor/league/flysystem/src/UrlGeneration/PublicUrlGenerator.php
vendored
Normal file
16
vendor/league/flysystem/src/UrlGeneration/PublicUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UrlGeneration;
|
||||
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\UnableToGeneratePublicUrl;
|
||||
|
||||
interface PublicUrlGenerator
|
||||
{
|
||||
/**
|
||||
* @throws UnableToGeneratePublicUrl
|
||||
*/
|
||||
public function publicUrl(string $path, Config $config): string;
|
||||
}
|
||||
39
vendor/league/flysystem/src/UrlGeneration/ShardedPrefixPublicUrlGenerator.php
vendored
Normal file
39
vendor/league/flysystem/src/UrlGeneration/ShardedPrefixPublicUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\UrlGeneration;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\PathPrefixer;
|
||||
|
||||
use function array_map;
|
||||
use function count;
|
||||
use function crc32;
|
||||
|
||||
final class ShardedPrefixPublicUrlGenerator implements PublicUrlGenerator
|
||||
{
|
||||
/** @var PathPrefixer[] */
|
||||
private array $prefixes;
|
||||
private int $count;
|
||||
|
||||
/**
|
||||
* @param string[] $prefixes
|
||||
*/
|
||||
public function __construct(array $prefixes)
|
||||
{
|
||||
$this->count = count($prefixes);
|
||||
|
||||
if ($this->count === 0) {
|
||||
throw new InvalidArgumentException('At least one prefix is required.');
|
||||
}
|
||||
|
||||
$this->prefixes = array_map(static fn (string $prefix) => new PathPrefixer($prefix, '/'), $prefixes);
|
||||
}
|
||||
|
||||
public function publicUrl(string $path, Config $config): string
|
||||
{
|
||||
$index = abs(crc32($path)) % $this->count;
|
||||
|
||||
return $this->prefixes[$index]->prefixPath($path);
|
||||
}
|
||||
}
|
||||
16
vendor/league/flysystem/src/UrlGeneration/TemporaryUrlGenerator.php
vendored
Normal file
16
vendor/league/flysystem/src/UrlGeneration/TemporaryUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\UrlGeneration;
|
||||
|
||||
use DateTimeInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\UnableToGenerateTemporaryUrl;
|
||||
|
||||
interface TemporaryUrlGenerator
|
||||
{
|
||||
/**
|
||||
* @throws UnableToGenerateTemporaryUrl
|
||||
*/
|
||||
public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string;
|
||||
}
|
||||
Reference in New Issue
Block a user