1
0
mirror of https://github.com/flarum/core.git synced 2025-08-12 03:14:33 +02:00

Simplify uploads, inject filesystem instances

This avoids injecting the Application god class and assembling default
file locations in multiple places.

In addition, we no longer use the `MountManager` for these uploads. It
only added complexity (by moving tmp files around) and will not be
available in the next major release of Flysystem.

Note: Passing PSR upload streams to Intervention Image requires an
explicit upgrade of the library. (Very likely, users have already
updated to the newer versions, as the old constraint allowed it, but
we should be explicit for correctness' sake.)
This commit is contained in:
Franz Liedke
2020-04-03 16:47:55 +02:00
parent 1cbb2a365e
commit 1fa37a7a6a
7 changed files with 68 additions and 92 deletions

View File

@@ -9,8 +9,15 @@
namespace Flarum\Settings;
use Flarum\Api\Controller\DeleteFaviconController;
use Flarum\Api\Controller\DeleteLogoController;
use Flarum\Api\Controller\UploadFaviconController;
use Flarum\Api\Controller\UploadLogoController;
use Flarum\Foundation\AbstractServiceProvider;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Filesystem\Factory;
use Illuminate\Database\ConnectionInterface;
use League\Flysystem\FilesystemInterface;
class SettingsServiceProvider extends AbstractServiceProvider
{
@@ -28,5 +35,18 @@ class SettingsServiceProvider extends AbstractServiceProvider
});
$this->app->alias(SettingsRepositoryInterface::class, 'flarum.settings');
$assets = function (Container $app) {
return $app->make(Factory::class)->disk('flarum-assets')->getDriver();
};
$this->app->when([
DeleteFaviconController::class,
DeleteLogoController::class,
UploadFaviconController::class,
UploadLogoController::class,
])
->needs(FilesystemInterface::class)
->give($assets);
}
}