|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
-
- namespace Lc\ShopBundle\Controller;
-
- use Doctrine\ORM\EntityManager;
- use Doctrine\ORM\EntityManagerInterface;
- use Lc\ShopBundle\Context\ProductCategoryInterface;
- use Lc\ShopBundle\Context\ProductInterface;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Security\Core\Security;
-
- class ApiController extends AbstractController
- {
- protected $security;
- protected $userManager;
- protected $em ;
- protected $utils ;
-
- public function __construct(EntityManagerInterface $entityManager)
- {
- $this->em = $entityManager;
- }
-
- public function getEntity($entity, $id)
- {
-
- $repo = $this->em->getRepository(ProductCategoryInterface::class);
- $data = $repo->findBy(array());
- dump($data);
-
-
-
- if($entity == 'product'){
- $repo = $this->em->getRepository(ProductInterface::class);
- $data = $repo->find($id);
- $data= array(
- 'id' => $data->getId(),
- 'title' => $data->getTitleInherited(),
- 'price' => $data->getPriceInherited(),
- 'unit' => $data->getUnitInherited(),
- 'availableQuantity' => $data->getAvailableQuantityInherited(),
- 'taxRate' => $data->getTaxRateInherited(),
- );
- }
-
- return new Response('<html><body>NICHE</body></html>');
- }
-
- }
-
|