-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Description
Hello,
I don't understand how to use the annotation @RelationProvider. The current object is never available on all methods (exp(), object::static() or func() )
How to get the current object to iterate on elements from his method ?
example :
namespace App\Entity;
/*
* @Hateoas\Relation( ??? ... object.getOtherObjects() ... ??? )
*/
class MyObject
{
/**
* @ORM\ManyToMany(targetEntity=MyOtherObject::class, inversedBy="myObjects")
*/
private $otherObject;
...
public function getOtherObjects()
{
return $this->otherObject;
}
...
}
class MyObject
{
...
public function getId()
{
return $this->id;
}
...
}
To generate ...
{
"_links": {
"otherObjects": [
{"href": "/api/otherObject/1"},
{"href": "/api/otherObject/6"},
{"href": "/api/otherObject/78"}
]
}
}
thank's you
Activity
kryptychon commentedon Sep 27, 2021
Hi @TOTOleHero,
I've got the exact same question. As far as I understand the RelationProvider construct, it's not meant to provide
Relations
in realtime, but provide a single place where you can provide parsed Relation (expressions) which then can be cached.I did not read the code to the end, but I guess all a
RelationProvider
does is providing a collection of cachableRelation
metadata from one place.However I think you use case should be adressed with
@Embedded
.Please, someone correct me if I'm wrong.