/**
* @ORM\Column(type="integer")
* @JMS\Expose
*/
private int $type;
I want to represent this field as string during serialization with some mapped value like
[0 => 'OK', 1 => 'FAIL']
How to achieve this with JMS?
/**
* @ORM\Column(type="integer")
* @JMS\Expose
*/
private int $type;
I want to represent this field as string during serialization with some mapped value like
[0 => 'OK', 1 => 'FAIL']
How to achieve this with JMS?
I couldn't find a native JMS way of doing it so I used @Accessor
public const TYPE = [
0 => 'OK',
1 => 'FAIL'
];
/**
* @ORM\Column(type="integer")
* @JMS\Expose
* @JMS\Type("string")
* @JMS\Accessor(getter="getTypeString")
*/
private int $type;
/**
* @return string
*/
public function getTypeString(): string
{
return self::TYPE[$this->type];
}