I'm using the Gedmo SoftDeletable filter for Symfony2 and Doctrine (https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/softdeleteable.md)
I'm also using the JMSSerializerBundle to serialize reponses to JSON for my REST API.
How to tell jms serializer annotation group about softdeleteable filters ?
And when my response contain entity which have relation with entity which have deleted_at field not empty I have error
Entity of type 'AppBundle\Entity\Courses' for IDs id(2) was not found
because sub_cources, example id 1 have relation with courses in example id 2 and courses with id 2 have not empty deleted_at - removed entity
example I have
/**
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="sub_cources")
*@ORM\Entity(repositoryClass="AppBundle\Entity\Repository\SubCoursesRepository")
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
* @AssertBridge\UniqueEntity(
* groups={"post_sub_course", "put_sub_course"},
* fields="name",
* errorPath="not valid",
* message="This name is already in use."
* )
*/
class SubCourses
/**
* @var Courses
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Courses", inversedBy="subCourses")
* @Annotation\Groups({
* "get_sub_courses"
* })
* @Annotation\Type("AppBundle\Entity\Courses")
*/
private $courses;
my action
return $this->createSuccessResponse(
[
'sub_courses' => $subCourses->getEntitiesByParams($paramFetcher),
'total' => $subCourses->getEntitiesByParams($paramFetcher, true),
],
['get_sub_courses'],
true
);
And my response look like
/**
* @param $data
* @param null|array $groups
* @param null|bool $withEmptyField
*
* @return View
*/
protected function createSuccessResponse($data, array $groups = null, $withEmptyField = null)
{
$context = SerializationContext::create()->enableMaxDepthChecks();
if ($groups) {
$context->setGroups($groups);
}
if ($withEmptyField) {
$context->setSerializeNull(true);
}
return View::create()
->setStatusCode(self::HTTP_STATUS_CODE_OK)
->setData($data)
->setSerializationContext($context);
}
How to tell jms serializer annotation group about softdeleteable filters ?