2016-07-26 4 views
1

私はSyliusを新しくしました。私はRest APIを使用しています。 私の質問:ファイルをより多く公開するためにファイルをシリアライズする方法をオーバーライドするにはどうすればよいですか?例えば :Sylius:シリアライザ設定 "Model.Product.yml"をオーバーライドしてより多くのファイルを公開する

ベンダー/ sylius/sylius/SRC/Sylius /バンドル/ ProductBundle /リソース/設定/シリアライザ/ Model.Product.yml

私が原型と翻訳などのいくつかのフィールドを追加することによって、テストしています彼らは完全に動作します

Sylius\Component\Product\Model\Product: 
exclusion_policy: ALL 
xml_root_name: product 
properties: 
    id: 
     expose: true 
     type: integer 
     xml_attribute: true 
    name: 
     expose: true 
     type: string 
    description: 
     expose: true 
     type: string 
    attributes: 
     expose: true 
     max_depth: 2 
    createdAt: 
     expose: true 
     type: DateTime 
    updatedAt: 
     expose: true 
     type: DateTime 
    archetype: 
     expose: 
     serialized_name: archetypes 
    translations: 
     expose: true 
     serialized_name: translations 
virtual_properties: 
    getVariants: 
     serialized_name: variants 

どのようにこの設定を上書きできますか? > YourBundle \エンティティ\製品に配置する必要があります -

答えて

1

あなたはまず、コア1、そして、製品モデルをオーバーライド

(あなたがSylius標準版を使用していると仮定)http://docs.sylius.org/en/latest/customization/model.htmlを以下のように拡張し、独自のバンドルを作成する必要があります.php

最後に、Resources \ config \ serializer \ Entity.Product.ymlを作成して、何でもしてください。

関連する問題