When trying to serialize a model that uses traits, JMSSerializer does not serialize properties included by that trait. I am using yaml to configure the serializer but it seems that it's not working.
trait IdentityTrait
{
protected $id;
public function setId($id)
{
$this->id = $id;
return $this;
}
public function getId()
{
return $this->id;
}
}
class OurClass {
use IdentityTrait;
protected $test;
public function getTest() {
$this->test;
}
}
JMSSerializerBundle is used and the following yaml is located in Resources/config/serializer/Model.Traits.IdentityTrait.yml
MyProject\Component\Core\Model\Traits\IdentityTrait:
exclusion_policy: NONE
properties:
id:
expose: true
And the OurClass
configuration is located in Resources/config/serializer/Model.OurClass.yml
MyProject\Component\Core\Model\OurClass:
exclusion_policy: NONE
properties:
test:
expose: true
Some code has been ignored to focus on the problem