src/Controller/Groups/IndexController.php line 60

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Groups;
  3. use App\Security\ApiUser;
  4. use App\Service\Client\Groups\GroupListingService;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. /**
  9.  * Class IndexController
  10.  * @package App\Controller\Groups
  11.  * @Route("/gruppen")
  12.  */
  13. class IndexController extends AbstractController
  14. {
  15.     /**
  16.      * @var GroupListingService
  17.      */
  18.     protected GroupListingService $service;
  19.     const ITEMS_PER_PAGE 15;
  20.     /**
  21.      * IndexController constructor.
  22.      * @param GroupListingService $service
  23.      */
  24.     public function __construct(GroupListingService $service)
  25.     {
  26.         $this->service $service;
  27.     }
  28.     /**
  29.      * @Route("/beliebte-gruppen/{category}/{page}", requirements={"category": "\d+", "page": "\d+"}, defaults={"page": 1, "category": 0})
  30.      * @Template()
  31.      * @param int $category
  32.      * @param int $page
  33.      * @return array
  34.      * @throws \Psr\Cache\InvalidArgumentException
  35.      * @throws \ReflectionException
  36.      */
  37.     public function top(int $categoryint $page): array
  38.     {
  39.         return [
  40.             'groups' => $this->service->getTopRatedGroups($category$page),
  41.             'page' => $page
  42.         ];
  43.     }
  44.     /**
  45.      * @Route("/oeffentliche-gruppen/{category}/{page}", requirements={"category": "\d+", "page": "\d+"}, defaults={"page": 1, "category": 0})
  46.      * @Template()
  47.      * @param int $category
  48.      * @param int $page
  49.      * @return array
  50.      * @throws \Psr\Cache\InvalidArgumentException
  51.      * @throws \ReflectionException
  52.      */
  53.     public function publicindex(int $categoryint $page): array
  54.     {
  55.         return [
  56.             'groups' => $this->service->getPublicGroups($category$page),
  57.             'page' => $page
  58.         ];
  59.     }
  60.     /**
  61.      * @Route("/private-gruppen/{category}/{page}", requirements={"category": "\d+", "page": "\d+"}, defaults={"page": 1, "category": 0})
  62.      * @Template()
  63.      * @param int $category
  64.      * @param int $page
  65.      * @return array
  66.      * @throws \Psr\Cache\InvalidArgumentException
  67.      * @throws \ReflectionException
  68.      */
  69.     public function inviteonly(int $categoryint $page): array
  70.     {
  71.         $this->denyAccessUnlessGranted('ROLE_MEMBER');
  72.         return [
  73.             'groups' => $this->service->getInviteOnlyGroups($category$page),
  74.             'page' => $page
  75.         ];
  76.     }
  77.     /**
  78.      * @Route("/meine-gruppen/{category}/{page}", requirements={"category": "\d+", "page": "\d+"}, defaults={"page": 1, "category": 0})
  79.      * @Template()
  80.      * @param int $category
  81.      * @param int $page
  82.      * @return array
  83.      * @throws \Psr\Cache\InvalidArgumentException
  84.      * @throws \ReflectionException
  85.      */
  86.     public function mygroups(int $categoryint $page): array
  87.     {
  88.         $this->denyAccessUnlessGranted('ROLE_MEMBER');
  89.         /**
  90.          * @var $me ApiUser
  91.          */
  92.         $me $this->getUser();
  93.         return [
  94.             'groups' => $this->service->getMyGroups($me->getMemberId(), $category$page),
  95.             'page' => $page
  96.         ];
  97.     }
  98. }