Skip to content

Commit

Permalink
Update to Laravel 10 & Flystem 3
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Dec 14, 2023
1 parent a4edf55 commit 85fde5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 48 deletions.
9 changes: 1 addition & 8 deletions app/src/Filesystem/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Filesystem\FilesystemManager as LaravelFilesystemManager;
use League\Flysystem\FilesystemInterface;
use UserFrosting\Config\Config;
use UserFrosting\UniformResourceLocator\ResourceLocatorInterface;

Expand Down Expand Up @@ -44,13 +43,7 @@ public function __construct(
*/
protected function callCustomCreator(array $config): Filesystem
{
$driver = $this->customCreators[$config['driver']]($this->config, $config);

if ($driver instanceof FilesystemInterface) {
return $this->adapt($driver);
}

return $driver;
return $this->customCreators[$config['driver']]($this->config, $config);
}

/**
Expand Down
15 changes: 9 additions & 6 deletions app/tests/Integration/Database/DatabaseTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,18 @@ public function testMorphsToManyUniqueWithTertiary(): void
'id' => 1,
'name' => 'Hatchery',
'pivot' => [
'location_id' => 1,
'task_id' => 2,
'location_id' => 1,
'task_id' => 2,
'assignable_type' => EloquentTestUser::class,
],
],
[
'id' => 2,
'name' => 'Nexus',
'pivot' => [
'location_id' => 2,
'task_id' => 2,
'location_id' => 2,
'task_id' => 2,
'assignable_type' => EloquentTestUser::class,
],
],
],
Expand All @@ -412,8 +414,9 @@ public function testMorphsToManyUniqueWithTertiary(): void
'id' => 2,
'name' => 'Nexus',
'pivot' => [
'location_id' => 2,
'task_id' => 3,
'location_id' => 2,
'task_id' => 3,
'assignable_type' => EloquentTestUser::class,
],
],
],
Expand Down
30 changes: 4 additions & 26 deletions app/tests/Integration/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
namespace UserFrosting\Sprinkle\Core\Tests\Integration\Filesystem;

use Illuminate\Filesystem\FilesystemAdapter;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter as LocalAdapter;
use Symfony\Component\HttpFoundation\StreamedResponse;
use UserFrosting\Config\Config;
use UserFrosting\Sprinkle\Core\Filesystem\FilesystemManager;
Expand Down Expand Up @@ -149,39 +149,17 @@ public function testNonExistingAdapter(): void

/**
* @depends testNonExistingAdapter
* @see https://github.com/thephpleague/flysystem/blob/13352d2303b67ecfc1306ef1fdb507df1a0fc79f/src/Adapter/Local.php#L47
*/
public function testAddingAdapter(): void
public function testCallCustomCreator(): void
{
$filesystemManager = $this->ci->get(FilesystemManager::class);
$filesystemManager->extend('localTest', function ($configService, $config) {
$locator = $this->ci->get(ResourceLocatorInterface::class);
$config['root'] = $locator->findResource($config['root'], all: true);
$adapter = new LocalAdapter($config['root']);
$filesystem = new Filesystem($adapter);

return new Filesystem($adapter);
});

$disk = $filesystemManager->disk('testingDriver');
$this->assertInstanceOf(FilesystemAdapter::class, $disk);

// Make sure the path was set correctly
$this->assertEquals(
Normalizer::normalizePath(__DIR__ . '/storage/testing/testingDriver/'),
Normalizer::normalizePath($disk->path(''))
);
}

public function testAddingDriver(): void
{
$filesystemManager = $this->ci->get(FilesystemManager::class);

$adapter = new LocalAdapter(__DIR__ . '/storage/testing/testingDriver');
$filesystem = new Filesystem($adapter);
$driver = new FilesystemAdapter($filesystem);

$filesystemManager->extend('localTest', function ($configService, $config) use ($driver) {
return $driver;
return new FilesystemAdapter($filesystem, $adapter, $config);
});

$disk = $filesystemManager->disk('testingDriver');
Expand Down
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
"require": {
"php": "^8.1",
"composer/semver": "^3.2.4",
"doctrine/dbal": "^3.3",
"doctrine/dbal": "^3.5",
"filp/whoops": "^2.14",
"illuminate/cache": "^8.5",
"illuminate/database": "^8.5",
"illuminate/events": "^8.5",
"illuminate/filesystem": "^8.5",
"illuminate/cache": "^10.0",
"illuminate/database": "^10.0",
"illuminate/events": "^10.0",
"illuminate/filesystem": "^10.0",
"league/csv": "^9.2.1",
"league/flysystem": "~1.0",
"league/flysystem-cached-adapter": "~1.0",
"league/flysystem-sftp": "~1.0",
"league/flysystem": "^3.22",
"lcharette/webpack-encore-twig": "^1.1",
"monolog/monolog": "^2.3",
"phpmailer/phpmailer": "^6.0.7",
Expand Down

0 comments on commit 85fde5f

Please sign in to comment.