Can I overwrite the way the tag object gets serialized? Currently everything is returned, I'd like to exclude the id, created_at, updated_at and tagging. Im using the JMS Serializer bundle, Doctrine Extensions Taggable with FPN Tag Bundle.
This is my setup, I'm thinking setting the parent of the Tag Bundle to FPN when the namespace of the Entity is actually DoctrineExtensions could be the issue.
Most the entity parameters are in DoctrineExtensions\Taggable\Entity\Tag (id,name,created_at etc). I'm overwriting the FPN bundle which extends DoctrineExtensions. DoctrineExtensions is a library not a bundle.
How can I do this?
# app/config/config.yml
# ...
jms_serializer:
metadata:
auto_detection: true
directories:
TagBundle:
namespace_prefix: "FPN\\TagBundle"
path: "@MYTagBundle/Resources/config/serializer/fpn"
# MY\TagBundle\Resources\config\serializer\fpn\Entity.Tag.yml
FPN\TagBundle\Entity\Tag:
exclusion_policy: ALL
properties:
id:
expose: false
name:
expose: true
created_at:
expose: false
updated_at:
expose: false
tagging:
expose: false
# src/MY/TagBundle/Entity/Tag.php
<?php
namespace MY\TagBundle\Entity;
use FPN\TagBundle\Entity\Tag as BaseTag;
class Tag extends BaseTag
{
}
# vendor/fpn/tag-bundle/FPN/TagBundle/Entity/Tag.php
<?php
namespace FPN\TagBundle\Entity;
use DoctrineExtensions\Taggable\Entity\Tag as BaseTag;
class Tag extends BaseTag
{
....
}
# src/MY/TagBundle/MYTagBundle.php
<?php
namespace MY\TagBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MYTagBundle extends Bundle
{
// Is this unnecessary due to config.yml?
public function getParent()
{
return 'FPNTagBundle';
}
}