Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

53 lines
1.7KB

  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. }