Closed flo-sch closed 4 years ago
You can use the link
expression from the Hateoas library and set the third parameter to true.
/**
* @Hateoas\Relation(
* "filepath",
* href = "expr(link(object.getWebPath(), "self", true))"
* )
*/
I have an entity with a
$filepath
property, And I have agetWebPath()
method which gives the relative web path (currently,uploads/some/sub/folders/the-file-name.extension
)But instead of serializing this relative web path :
I would prefer to serialize the absolute web one :
So I was just wondering, would it be a good practice to register a new method (
asset()
for instance) inside expr() ?Then how to register it in expr() ?