src/Controller/Api/MembershipAttrController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Api;
  3. use App\Entity\Membership;
  4. use App\Entity\MembershipAttr;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class MembershipAttrController extends ApiController
  9. {
  10.     /**
  11.      * @param Request $request
  12.      * @return JsonResponse
  13.      *
  14.      * @Route("/membership_attr/{membership}/list", name="api_membership_attr_list_chil", methods={"POST"})
  15.      */
  16.     public function listMembershipAttr(Membership $membershipRequest $request)
  17.     {
  18.         $prefixFile $this->getParameter("app.path.membership_images");
  19.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  20.         /** @var MembershipAttr $membershipAttr */
  21.         $membershipsAttr = [];
  22.         $filter = [
  23.             'membershipParent' => $membership
  24.         ];
  25.         foreach ($this->em->getRepository(MembershipAttr::class)->findBy($filter) as $membershipAttr){
  26.             $membershipsAttr[] = $membershipAttr->__toArray($baseurl $prefixFile "/");
  27.         }
  28.         return $this->response($membershipsAttr);
  29.     }
  30. }