function index($siteid, $slug, Request $request, Application $app) { $this->build($siteid, $slug, $request, $app); $form = $app['form.factory']->create(new ActionForm()); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid()) { $data = $form->getData(); $action = new ActionParser($data['action']); if ($action->getCommand() == 'delete' && !$this->parameters['media']->getIsDeleted()) { $mr = new MediaRepository(); $mr->delete($this->parameters['media'], $app['currentUser']); return $app->redirect('/sysadmin/site/' . $this->parameters['site']->getId() . '/media/' . $this->parameters['media']->getSlug()); } } } $this->parameters['form'] = $form->createView(); return $app['twig']->render('sysadmin/media/index.html.twig', $this->parameters); }