src/Controller/ING/NewsController.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\Controller\ING;
  3. use App\Controller\BaseController;
  4. use Empire\Core\News;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. /**
  9.  * Class NewsController
  10.  * @package App\Controller\ING
  11.  * @Route("/iis")
  12.  */
  13. class NewsController extends BaseController
  14. {
  15.     /**
  16.      * @param Request $request
  17.      * @param $page
  18.      * @param $type
  19.      * @return Response
  20.      * @Route("/{page}/{type}", requirements={"page"="\d+", "type"="\d+"}, defaults={"page"=1, "type"=News::NEWS_TYPE_INS}, name="ins.archive")
  21.      */
  22.     public function archive(Request $request$page$type) {
  23.         $term $request->get('s''');
  24.         return $this->render('ins/archive.twig', [
  25.             'title' => $type == 'IIS Archive' 'IHS Archive',
  26.             'gejs' => ['ajax'],
  27.             'news' => News::getArchiveNews($page$type$term),
  28.             'pages' => max(ceil(News::getNewsCount($type$term) / 10), 1),
  29.             'page' => $page,
  30.             'type' => $type,
  31.             'term' => $term,
  32.         ]);
  33.     }
  34.     /**
  35.      * @param $article
  36.      * @return mixed
  37.      * @Route("/arcticle/{article}", name="ins.article", requirements={"article"="\d+"})
  38.      */
  39.     public function article($article) {
  40.         $news News::load([$article]);
  41.         if(null === $news) {
  42.             return $this->createNotFoundException('Article does not exist.');
  43.         }
  44.         return $this->render('/ins/main.twig', [
  45.             'title' => $news->title,
  46.             'gejs' => ['ajax'],
  47.             'news' => [$news],
  48.             'recent' => $recent News::getLatestNews($news->newsType3),
  49.         ]);
  50.     }
  51. }