You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of my classes that I'm serializing has a virtual property that I would like to see. I'm using yaml configuration.
Here's the yaml:
Namespace\Model\Keg:
exclusion_policy: ALL
properties:
A list of properties that work
virtual_properties:
getKegImage:
serialized_name: image
Here's the class:
namespace PintLabs\Service\SteadyServ\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'
];
}
}
When I serialize the model, I would expect the to see an image field in the json with the array as its value. Instead, the field is missing. I've tried many combinations of settings in the yaml file and I can't get it to show.
The text was updated successfully, but these errors were encountered:
As an update, I tried running the unit tests and the tests pertaining to the test fixtures with virtual properties passed. However, I deleted the yml virtual properties and the tests still passed so I doubt those fixtures actually had an impact on the tests.
From looking at the code, it looks like virtual properties aren't actually supported using yaml metadata. Luckily, you can mix metadata sources if you want. I simply added the @VirtualProperty Doctrine annotation to the method and it worked as expected.
One of my classes that I'm serializing has a virtual property that I would like to see. I'm using yaml configuration.
Here's the yaml:
Here's the class:
When I serialize the model, I would expect the to see an image field in the json with the array as its value. Instead, the field is missing. I've tried many combinations of settings in the yaml file and I can't get it to show.
The text was updated successfully, but these errors were encountered: