Example #1
0
 /**
  * @param Request $request
  * @return PartialHtmlResponse
  */
 public function run(Request $request)
 {
     $now = $this->serviceContainer->getCurrentDate();
     $userSession = $this->serviceContainer->getUserSession();
     $urlBuilder = $this->serviceContainer->getUrlBuilder();
     $formMapper = $this->serviceContainer->getUrlFormMapper();
     $csrfHandler = $this->serviceContainer->getCsrfHandler();
     if ($csrfHandler->requestIsValid($request) == false) {
         return new CompleteHtmlResponse($csrfHandler->getErrorMessage());
     }
     $urlDataObject = $formMapper->mapToDataObject($request, $userSession->getUserId());
     $formMapper->initValues($urlDataObject, $now);
     $this->addUrlToDb($urlDataObject);
     return new HttpRedirectResponse($urlBuilder->createActionUrl('listUrls'));
 }