From 183a22b5c513aa53b4ae1a628d8349ff0672d100 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers Date: Fri, 15 Dec 2017 09:29:20 +0100 Subject: [PATCH] - FilesystemInterface no longer needed in User related handlers - FilesystemInterface conditional ioc binding moved to AvatarUploader - User::getAvatarAtribute failed to use the UrlGenerator properly --- src/User/Command/UploadAvatarHandler.php | 2 +- src/User/User.php | 2 +- src/User/UserServiceProvider.php | 10 +--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/User/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php index b0dc60b6d..18fa84c00 100644 --- a/src/User/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -98,7 +98,7 @@ class UploadAvatarHandler $image = (new ImageManager)->make($tmpFile); $this->events->fire( - new AvatarSaving($user, $actor, $tmpFile) + new AvatarSaving($user, $actor, $image) ); $this->uploader->upload($user, $image); diff --git a/src/User/User.php b/src/User/User.php index 38a9f6900..577ab1dcb 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -316,7 +316,7 @@ class User extends AbstractModel return $this->avatar_path; } - return app(UrlGenerator::class)->toPath('assets/avatars/'.$this->avatar_path); + return app(UrlGenerator::class)->to('forum')->path('assets/avatars/'.$this->avatar_path); } } diff --git a/src/User/UserServiceProvider.php b/src/User/UserServiceProvider.php index be6da2d8a..1b1a52954 100644 --- a/src/User/UserServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -41,15 +41,7 @@ class UserServiceProvider extends AbstractServiceProvider return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver(); }; - $this->app->when('Flarum\User\Command\UploadAvatarHandler') - ->needs('League\Flysystem\FilesystemInterface') - ->give($avatarsFilesystem); - - $this->app->when(Command\DeleteAvatarHandler::class) - ->needs('League\Flysystem\FilesystemInterface') - ->give($avatarsFilesystem); - - $this->app->when(Command\RegisterUserHandler::class) + $this->app->when(AvatarUploader::class) ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); }