From 033961844dda7e74ff2f9a268483dca4e34c294c 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 --- .../core/src/User/Command/UploadAvatarHandler.php | 2 +- framework/core/src/User/User.php | 2 +- framework/core/src/User/UserServiceProvider.php | 10 +--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/framework/core/src/User/Command/UploadAvatarHandler.php b/framework/core/src/User/Command/UploadAvatarHandler.php index b0dc60b6d..18fa84c00 100644 --- a/framework/core/src/User/Command/UploadAvatarHandler.php +++ b/framework/core/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/framework/core/src/User/User.php b/framework/core/src/User/User.php index 38a9f6900..577ab1dcb 100755 --- a/framework/core/src/User/User.php +++ b/framework/core/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/framework/core/src/User/UserServiceProvider.php b/framework/core/src/User/UserServiceProvider.php index be6da2d8a..1b1a52954 100644 --- a/framework/core/src/User/UserServiceProvider.php +++ b/framework/core/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); }