- FilesystemInterface no longer needed in User related handlers

- FilesystemInterface conditional ioc binding moved to AvatarUploader
- User::getAvatarAtribute failed to use the UrlGenerator properly
This commit is contained in:
Daniel Klabbers 2017-12-15 09:29:20 +01:00
parent 654fca9c2c
commit 183a22b5c5
3 changed files with 3 additions and 11 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}