/** * Serializes single entity * * @param mixed $id Entity id * * @return array|null */ public function serializeOne($id) { $qb = $this->getItemQueryBuilder($id); $config = $this->getCachedSerializationConfig(); $this->entitySerializer->prepareQuery($qb, $config); $entity = $qb->getQuery()->getResult(); if (!$entity) { return null; } $this->checkFoundEntity($entity[0]); $serialized = $this->entitySerializer->serializeEntities((array) $entity, $this->class, $config); return $serialized[0]; }
/** * Serializes single entity * * @param mixed $id Entity id * * @return array|null */ public function serializeOne($id) { $qb = $this->getRepository()->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', $id); $config = $this->getSerializationConfig(); $this->entitySerializer->prepareQuery($qb, $config); $entity = $qb->getQuery()->getResult(); if (!$entity) { return null; } $this->checkFoundEntity($entity[0]); $serialized = $this->entitySerializer->serializeEntities((array) $entity, $this->class, $config); return $serialized[0]; }