I need return full response with Document
model. I have response but there are absent some fields, which are defined in entity. For example I need to have in response both 'campaign' and 'template' properties - but actually 'campaign' is absent.
Below are my controller and entity.
I have such action in my controller:
/**
* @REST\View(serializerGroups={"Default", "DocumentDetails"})
* @REST\Get("/{id}", requirements={"id" = "\d+"})
* @ParamConverter("document", class="AppBundle:Document");
*/
public function showAction(Request $request, Document $document)
{
return $document;
}
But the Document entity has relations:
/**
* Document entity
*
* @ORM\Entity(repositoryClass="AppBundle\Repository\DocumentRepository")
* @ORM\Table(name="document")
* @ORM\HasLifecycleCallbacks()
*
* @Serializer\ExclusionPolicy("all")
*/
class Document
{
.......
/**
* @var campaign
* @ORM\ManyToOne(targetEntity="Campaign", inversedBy="documents")
* @ORM\JoinColumn(name="campaign", referencedColumnName="id")
*
* @Serializer\Expose()
*/
protected $campaign; // **THIS FIELD IS ABSENT - WHY !???**
/**
* @var DocumentTemplate Szablon dokumentu
*
* @ORM\ManyToOne(targetEntity="DocumentTemplate")
* @ORM\JoinColumn(name="template_id", referencedColumnName="id")
*
* @Serializer\Expose()
*/
protected $template; // **THIS PROPERTY IS DISPLAYED**
.......
$document->template
is present in $document response. But $document->campaign
is absent. What is wrong ? Probably it is related somehow to serializerGroups
?? Thanks for any help.