Moved user avatar controller to routes
This commit is contained in:
parent
2195b2c9a1
commit
e38152b921
2 changed files with 14 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Szurubooru\Controllers;
|
namespace Szurubooru\Routes\Users;
|
||||||
use Szurubooru\Dao\PublicFileDao;
|
use Szurubooru\Dao\PublicFileDao;
|
||||||
use Szurubooru\Entities\User;
|
use Szurubooru\Entities\User;
|
||||||
use Szurubooru\Router;
|
use Szurubooru\Router;
|
||||||
|
@ -7,7 +7,7 @@ use Szurubooru\Services\NetworkingService;
|
||||||
use Szurubooru\Services\ThumbnailService;
|
use Szurubooru\Services\ThumbnailService;
|
||||||
use Szurubooru\Services\UserService;
|
use Szurubooru\Services\UserService;
|
||||||
|
|
||||||
final class UserAvatarController extends AbstractController
|
class GetUserAvatar extends AbstractUserRoute
|
||||||
{
|
{
|
||||||
private $fileDao;
|
private $fileDao;
|
||||||
private $userService;
|
private $userService;
|
||||||
|
@ -26,13 +26,21 @@ final class UserAvatarController extends AbstractController
|
||||||
$this->thumbnailService = $thumbnailService;
|
$this->thumbnailService = $thumbnailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerRoutes(Router $router)
|
public function getMethods()
|
||||||
{
|
{
|
||||||
$router->get('/api/users/:userName/avatar/:size', [$this, 'getAvatarByName']);
|
return ['GET'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvatarByName($userName, $size)
|
public function getUrl()
|
||||||
{
|
{
|
||||||
|
return '/api/users/:userName/avatar/:size';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function work()
|
||||||
|
{
|
||||||
|
$userName = $this->getArgument('userName');
|
||||||
|
$size = $this->getArgument('size');
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$user = $this->userService->getByName($userName);
|
$user = $this->userService->getByName($userName);
|
|
@ -57,7 +57,6 @@ return [
|
||||||
|
|
||||||
'controllers' => DI\factory(function (DI\container $container) {
|
'controllers' => DI\factory(function (DI\container $container) {
|
||||||
return [
|
return [
|
||||||
$container->get(\Szurubooru\Controllers\UserAvatarController::class),
|
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -99,6 +98,7 @@ return [
|
||||||
$container->get(\Szurubooru\Routes\Users\FinishActivation::class),
|
$container->get(\Szurubooru\Routes\Users\FinishActivation::class),
|
||||||
$container->get(\Szurubooru\Routes\Users\FinishPasswordReset::class),
|
$container->get(\Szurubooru\Routes\Users\FinishPasswordReset::class),
|
||||||
$container->get(\Szurubooru\Routes\Users\GetUser::class),
|
$container->get(\Szurubooru\Routes\Users\GetUser::class),
|
||||||
|
$container->get(\Szurubooru\Routes\Users\GetUserAvatar::class),
|
||||||
$container->get(\Szurubooru\Routes\Users\GetUsers::class),
|
$container->get(\Szurubooru\Routes\Users\GetUsers::class),
|
||||||
$container->get(\Szurubooru\Routes\Users\PasswordReset::class),
|
$container->get(\Szurubooru\Routes\Users\PasswordReset::class),
|
||||||
$container->get(\Szurubooru\Routes\Users\UpdateUser::class),
|
$container->get(\Szurubooru\Routes\Users\UpdateUser::class),
|
||||||
|
|
Loading…
Reference in a new issue