Reputation: 104
Hello everyone m working on a project there is a bundle CustomerBundle when i call a function following errors are display can anyone tell me why this error coccured..
message": "Resources are not supported in serialized data. Path: Monolog\Handler\StreamHandler -> Symfony\Bridge\Monolog\Logger -> Symfony\Component\Cache\Adapter\FilesystemAdapter -> Symfony\Component\Cache\Adapter\TraceableAdapter -> Symfony\Component\Cache\DoctrineProvider -> Doctrine\Common\Annotations\CachedReader -> Doctrine\ORM\Mapping\Driver\AnnotationDriver -> Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain -> Doctrine\ORM\Configuration -> Doctrine\ORM\EntityManager -> CustomerBundle\Repository\CustomerRepository", "class": "JMS\Serializer\Exception\RuntimeException",
this is my Customer entity page
/**
* @ORM\ManyToOne(targetEntity="CompanyBundle\Entity\Company", inversedBy="company_customer")
* @ORM\JoinColumn(name="company_id", referencedColumnName="id")
*/
private $companyId;
/**
* @var \DateTime
*
* @ORM\Column(name="created_time", type="datetimetz")
*/
private $createdTime;
/**
* @var \DateTime
*
* @ORM\Column(name="modified_time", type="datetime")
*/
private $modifiedTime;
/**
* @ORM\OneToMany(targetEntity="SalesBundle\Entity\SalesAccount", mappedBy="customerId" )
*/
private $sales_customer_id;
CustomerApiController controller
namespace CustomerBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use FOS\RestBundle\View\View;
use CustomerBundle\Entity\Customer;
class CustomerapiController extends FOSRestController
{
/**
* @Rest\Post("/api/customer")
*/
public function customerAction(Request $request)
{
$data = $this->getDoctrine()->getRepository(Customer::class);
$data->find(1);
return $data;
}
}
Upvotes: 1
Views: 2009
Reputation: 247
I think you should have a look at this post. Similar problem can be solved in the same way.
Write a custom repository function and do the following instead of your "find(1)" :
public function findFirstElement()
{
$qb = $this->createQueryBuilder('e');
$qb->where('e.id = 1');
return $qb->getQuery()->getArrayResult();
}
Upvotes: 0