Beispiel #1
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function deleteAction(Request $request)
 {
     if (!$request->isMethod(Request::METHOD_DELETE)) {
         throw new MethodNotAllowedHttpException([Request::METHOD_DELETE], 'This action requires a DELETE request.');
     }
     $idUrlRedirect = $this->castId($request->request->get(self::REQUEST_ID_URL_REDIRECT));
     if ($idUrlRedirect === 0) {
         $this->addErrorMessage('Id redirect url not set');
         return $this->redirectResponse('/cms/redirect');
     }
     $redirectTransfer = new RedirectTransfer();
     $redirectTransfer->setIdUrlRedirect($idUrlRedirect);
     $this->getFactory()->getUrlFacade()->deleteUrlRedirect($redirectTransfer);
     return $this->redirectResponse('/cms/redirect');
 }
Beispiel #2
0
 /**
  * @return void
  */
 public function testSaveRedirectUpdatesSomething()
 {
     $redirect = new RedirectTransfer();
     $redirect->setToUrl('/pageToUrl2');
     $redirect->setStatus(301);
     $redirect = $this->urlFacade->saveRedirect($redirect);
     $redirectQuery = $this->urlQueryContainer->queryRedirectById($redirect->getIdUrlRedirect());
     $this->assertEquals('/pageToUrl2', $redirectQuery->findOne()->getToUrl());
     $redirect->setToUrl('/redirectingToUrl');
     $this->urlFacade->saveRedirect($redirect);
     $this->assertEquals('/redirectingToUrl', $redirectQuery->findOne()->getToUrl());
 }
Beispiel #3
0
 /**
  * @param \Generated\Shared\Transfer\RedirectTransfer $redirectTransfer
  *
  * @return void
  */
 protected function touchDeleted(RedirectTransfer $redirectTransfer)
 {
     $this->touchFacade->touchDeleted(self::ITEM_TYPE_REDIRECT, $redirectTransfer->getIdUrlRedirect());
 }