protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine.orm.entity_manager'); /** @var GifRepository $gifRepo */ $gifRepo = $em->getRepository('LjdsBundle:Gif'); $gifState = GifState::fromName($input->getArgument('gifState')); if ($gifState == -1) { $output->writeln('Unknown gifState'); return; } $count = $gifRepo->getCountByGifState($gifState); $output->write($count); }
/** * @Route("/admin/{type}", name="admin") * @Route("/admin/") */ public function adminAction($type = 'submitted') { $em = $this->getDoctrine()->getManager(); /** @var GifRepository $gifRepo */ $gifRepo = $em->getRepository('LjdsBundle:Gif'); switch ($type) { case 'submitted': case 'accepted': case 'refused': case 'published': $gifState = GifState::fromName($type); $gifs = $gifRepo->findByGifState($gifState); break; case 'reported': $gifs = $gifRepo->getReportedGifs(); break; default: throw new NotFoundHttpException(); break; } $params = ['gifs' => $gifs, 'type' => $type, 'admin_api_key' => $this->getParameter('admin_api_key')]; return $this->render('LjdsBundle:Admin:index.html.twig', $params); }