POST request on many-to-many association

后端 未结 2 556
轻奢々
轻奢々 2021-01-28 18:55

I have two entities with a many-to-many association:

class User extends BaseUser

and

class Calendar
{
    /**
     * @var integ         


        
相关标签:
2条回答
  • 2021-01-28 19:32

    You should add addPublisher(User $publisher) and removePublisher(User $publisher) methods.

    API Platform internally uses the Symfony PropertyAccess component, and this component requires such methods to be able to access to the private property.

    0 讨论(0)
  • 2021-01-28 19:47

    It sounds like you should specify fetch="EAGER" in the relationship so that it always gets the related objects.

    see http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/annotations-reference.html#manytoone (and also the next paragraph)

    and some good info here: http://www.uvd.co.uk/blog/some-doctrine-2-best-practices/

    0 讨论(0)
提交回复
热议问题