選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ApiController.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Lc\ShopBundle\Controller;
  3. use Doctrine\ORM\EntityManager;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Lc\ShopBundle\Context\ProductCategoryInterface;
  6. use Lc\ShopBundle\Context\ProductInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Security\Core\Security;
  11. class ApiController extends AbstractController
  12. {
  13. protected $security;
  14. protected $userManager;
  15. protected $em ;
  16. protected $utils ;
  17. public function __construct(EntityManagerInterface $entityManager)
  18. {
  19. $this->em = $entityManager;
  20. }
  21. public function getEntity($entity, $id)
  22. {
  23. $repo = $this->em->getRepository(ProductCategoryInterface::class);
  24. $data = $repo->findBy(array());
  25. dump($data);
  26. if($entity == 'product'){
  27. $repo = $this->em->getRepository(ProductInterface::class);
  28. $data = $repo->find($id);
  29. $data= array(
  30. 'id' => $data->getId(),
  31. 'title' => $data->getTitleInherited(),
  32. 'price' => $data->getPriceInherited(),
  33. 'unit' => $data->getUnitInherited(),
  34. 'availableQuantity' => $data->getAvailableQuantityInherited(),
  35. 'taxRate' => $data->getTaxRateInherited(),
  36. );
  37. }
  38. return new Response('<html><body>NICHE</body></html>');
  39. }
  40. }