タグ オブジェクトがシリアル化される方法を上書きできますか? 現在、すべてが返されています。id、created_at、updated_at、およびタグ付けを除外したいと思います。JMSシリアライザーバンドル、Doctrine Extensions Taggable with FPN Tag Bundleを使用しています。
これが私のセットアップです。エンティティの名前空間が実際には DoctrineExtensions である場合に、タグ バンドルの親を FPN に設定すると問題になる可能性があると考えています。
ほとんどのエンティティ パラメータは DoctrineExtensions\Taggable\Entity\Tag (id、name、created_at など) にあります。DoctrineExtensions を拡張する FPN バンドルを上書きしています。DoctrineExtensions はバンドルではなくライブラリです。
これどうやってするの?
# 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';
}
}