<?php
namespace App\Controller\Api;
use App\Entity\Membership;
use App\Entity\MembershipAttr;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class MembershipAttrController extends ApiController
{
/**
* @param Request $request
* @return JsonResponse
*
* @Route("/membership_attr/{membership}/list", name="api_membership_attr_list_chil", methods={"POST"})
*/
public function listMembershipAttr(Membership $membership, Request $request)
{
$prefixFile = $this->getParameter("app.path.membership_images");
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
/** @var MembershipAttr $membershipAttr */
$membershipsAttr = [];
$filter = [
'membershipParent' => $membership
];
foreach ($this->em->getRepository(MembershipAttr::class)->findBy($filter) as $membershipAttr){
$membershipsAttr[] = $membershipAttr->__toArray($baseurl . $prefixFile . "/");
}
return $this->response($membershipsAttr);
}
}