use FOS\UserBundle\FOSUserEvents;
use JMS\Serializer\SerializationContext;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
-use Wallabag\UserBundle\Entity\User;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\ApiBundle\Entity\Client;
+use Wallabag\UserBundle\Entity\User;
class UserRestController extends WallabagRestController
{
public function putUserAction(Request $request)
{
if (!$this->getParameter('fosuser_registration') || !$this->get('craue_config')->get('api_user_registration')) {
- $json = $this->get('serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json');
+ $json = $this->get('jms_serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json');
return (new JsonResponse())
->setJson($json)
$view->setFormat('json');
// handle errors in a more beautiful way than the default view
- $data = json_decode($this->handleView($view)->getContent(), true)['children'];
+ $data = json_decode($this->handleView($view)->getContent(), true)['errors']['children'];
$errors = [];
if (isset($data['username']['errors'])) {
$errors['password'] = $this->translateErrors($data['plainPassword']['children']['first']['errors']);
}
- $json = $this->get('serializer')->serialize(['error' => $errors], 'json');
+ $json = $this->get('jms_serializer')->serialize(['error' => $errors], 'json');
return (new JsonResponse())
->setJson($json)
*/
private function sendUser(User $user, $group = 'user_api', $status = JsonResponse::HTTP_OK)
{
- $json = $this->get('serializer')->serialize(
+ $json = $this->get('jms_serializer')->serialize(
$user,
'json',
SerializationContext::create()->setGroups([$group])