<?php

namespace KupShop\UserBundle\Controller;

use KupShop\KupShopBundle\Context\UserContext;
use KupShop\KupShopBundle\Routing\SimpleTranslatedRoute;
use KupShop\KupShopBundle\Util\Contexts;
use KupShop\UserBundle\View\PasswordView;
use KupShop\UserBundle\View\UserView;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class UserController extends AbstractController
{
    /**
     * @SimpleTranslatedRoute("user_new", name="register")
     * @SimpleTranslatedRoute("user_edit", name="settings")
     */
    public function userAction(Request $request, UserView $view)
    {
        $view->setRequest($request);

        if (Contexts::get(UserContext::class)->isActive()) {
            $view->setType('edit'); // new - create user, edit - edit user
            $view->setUserId(Contexts::get(UserContext::class)->getActiveId());
        } else {
            $view->setType('new'); // new - create user, edit - edit user
            $view->setUserId(-1);
        }

        return $view->getResponse();
    }

    /**
     * @Route("/uzivatel/heslo/")
     */
    public function passwordAction(Request $request, PasswordView $view)
    {
        return $view->getResponse();
    }
}
