シリアライズしているクラスの 1 つに、確認したい仮想プロパティがあります。私はyaml構成を使用しています。
yaml は次のとおりです。
Namespace\Model\Keg:
exclusion_policy: ALL
properties:
A list of properties that work
virtual_properties:
getKegImage:
serialized_name: image
クラスは次のとおりです。
namespace Namespace\Model;
class Keg extends ModelAbstract
{
/** Some properties + accessors **/
/**
* @param bool $asImgTag Whether or not to return the URL in an <img> tag
* @return array
*/
public function getKegImage ($asImgTag = false)
{
return [
'Key' => 'value',
'Key' => 'value',
'Key' => 'value'
];
}
}
モデルをシリアル化すると、配列を値として持つ json の画像フィールドが表示されることが期待されます。代わりに、フィールドがありません。yaml ファイルでさまざまな設定の組み合わせを試しましたが、表示できません。