Ojs\JournalBundle\Controller\DesignController::deleteAction PHP Метод

deleteAction() публичный Метод

public deleteAction ( Request $request, integer $id ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$id integer
Результат Symfony\Component\HttpFoundation\RedirectResponse
    public function deleteAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $journal = $this->get('ojs.journal_service')->getSelectedJournal(false);
        if (!$this->isGranted('DELETE', $journal, 'design')) {
            throw new AccessDeniedException("You are not authorized for view this journal's sections!");
        }
        $requestedDesign = $em->getRepository('OjsJournalBundle:Design')->find($id);
        if ($journal->getDesign() !== null && $requestedDesign->getId() === $journal->getDesign()->getId()) {
            $this->errorFlashBag('journal.design.cannot_delete_active');
        } else {
            $csrf = $this->get('security.csrf.token_manager');
            $token = $csrf->getToken('ojs_journal_design' . $id);
            if ((string) $token !== $request->get('_token')) {
                throw new TokenNotFoundException("Token Not Found!");
            }
            $em->remove($requestedDesign);
            $em->flush();
            $this->successFlashBag('successful.remove');
        }
        return $this->redirectToRoute('ojs_journal_design_index', ['journalId' => $journal->getId()]);
    }