This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Controllers/UserController.php

58 lines
1.4 KiB
PHP
Raw Normal View History

2014-08-31 13:34:31 +02:00
<?php
namespace Szurubooru\Controllers;
final class UserController extends AbstractController
{
2014-08-31 14:07:46 +02:00
private $inputReader;
2014-08-31 17:42:48 +02:00
private $userService;
2014-08-31 13:34:31 +02:00
2014-08-31 14:07:46 +02:00
public function __construct(
\Szurubooru\Services\UserService $userService,
\Szurubooru\Helpers\InputReader $inputReader)
2014-08-31 13:34:31 +02:00
{
2014-08-31 14:07:46 +02:00
$this->inputReader = $inputReader;
2014-08-31 13:34:31 +02:00
$this->userService = $userService;
}
public function registerRoutes(\Szurubooru\Router $router)
{
2014-08-31 17:42:48 +02:00
$router->post('/api/users', [$this, 'register']);
2014-08-31 13:34:31 +02:00
$router->get('/api/users', [$this, 'getAll']);
$router->get('/api/users/:id', [$this, 'getById']);
$router->put('/api/users/:id', [$this, 'update']);
$router->delete('/api/users/:id', [$this, 'delete']);
}
2014-08-31 17:42:48 +02:00
public function register()
2014-08-31 13:34:31 +02:00
{
2014-08-31 17:42:48 +02:00
$input = new \Szurubooru\FormData\RegistrationFormData;
$input->name = $this->inputReader->userName;
$input->password = $this->inputReader->password;
$input->email = $this->inputReader->email;
2014-08-31 14:07:46 +02:00
2014-08-31 17:42:48 +02:00
$user = $this->userService->register($input);
return new \Szurubooru\ViewProxies\User($user);
2014-08-31 13:34:31 +02:00
}
public function update($id)
{
throw new \BadMethodCallException('Not implemented');
}
public function getAll()
{
throw new \BadMethodCallException('Not implemented');
}
public function getById($id)
{
throw new \BadMethodCallException('Not implemented');
}
public function delete($id)
{
throw new \BadMethodCallException('Not implemented');
}
}