You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
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. }