protected function buildSortableFieldActions(AbstractAdminListConfigurator $configurator) { // Check if Sortable interface is implemented if ($configurator instanceof SortableInterface) { $route = function (EntityInterface $item) use($configurator) { return array('path' => $configurator->getPathByConvention() . '_move_up', 'params' => array('id' => $item->getId())); }; $action = new SimpleItemAction($route, 'arrow-up', 'Move up'); $configurator->addItemAction($action); $route = function (EntityInterface $item) use($configurator) { return array('path' => $configurator->getPathByConvention() . '_move_down', 'params' => array('id' => $item->getId())); }; $action = new SimpleItemAction($route, 'arrow-down', 'Move down'); $configurator->addItemAction($action); } }
/** * Delete the Entity using its ID * * @param AbstractAdminListConfigurator $configurator The adminlist configurator * @param integer $entityId The id to delete * @param null|Request $request * * @throws NotFoundHttpException * @throws AccessDeniedHttpException * * @return Response */ protected function doDeleteAction(AbstractAdminListConfigurator $configurator, $entityId, Request $request = null) { /* @var $em EntityManager */ $em = $this->getEntityManager(); if (is_null($request)) { $request = $this->getRequest(); } $helper = $em->getRepository($configurator->getRepositoryName())->findOneById($entityId); if ($helper === null) { throw new NotFoundHttpException("Entity not found."); } if (!$configurator->canDelete($helper)) { throw new AccessDeniedHttpException('You do not have sufficient rights to access this page.'); } $indexUrl = $configurator->getIndexUrl(); if ($request->isMethod('POST')) { $em->remove($helper); $em->flush(); } return new RedirectResponse($this->generateUrl($indexUrl['path'], isset($indexUrl['params']) ? $indexUrl['params'] : array())); }