protected function handle() { $request = $this->getRequest(); if ($request->getMethod() == 'POST') { $ids = $request->request->get('ids'); $session = $this->getSession(); $db = TagModel::getDb(); try { $db->transaction(); foreach ($ids as $id) { TagModel::deleteTag($id); } $db->commit(); $session->addFlash('success', '操作成功'); } catch (\Exception $e) { $db->rollback(); $session->addFlash('error', $e->getMessage()); } return new RedirectResponse($this->generateUrl('admin_www_tag')); } else { $ids = $request->query->get('ids'); $ids = json_decode($ids); if (!$ids) { return $this->render('@TachigoWWWAdmin/error-modal.html.twig', array('message' => '没有选中任何标签')); } else { $pager = TagModel::listTags(1, count($ids), function (QueryBuilder $qb) use($ids) { $qb->where($qb->expr()->in('id', $ids)); }); return $this->render('tag/delete.html.twig', array('tags' => $pager)); } } }