I'm having an issue with a Hateoas library for PHP.
I have a Doctrine Entity where I want add an exclusion annotation to the relation annotation as shown by an example in the documentation If I do this I get the following error:
[Semantical Error] Annotation @Hateoas\Exclusion is not allowed to be declared on class My\Entity\Order. You may only use this annotation on these code elements: ANNOTATION
Does anybody know how to fix this? Or is it a bug or bad documentation?
The Entity:
<?php
namespace My\Entity;
use Doctrine\ORM\Mapping as ORM;
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
* @ORM\Table(name="`order`")
* @ORM\HasLifecycleCallbacks
*
* @Hateoas\Relation(
* "self",
* href = "expr('/order/' ~ object.getId())"),
* exclusion = @Hateoas\Exclusion(
* groups = {"production"}
* )
* )
* @Hateoas\Relation(
* "self",
* href = "expr('/production/' ~ object.getId())"),
* exclusion = @Hateoas\Exclusion(
* groups = {"order"}
* )
* )
*/
class Order
{
}
It seemed that I closed the Relation annotation to early.
Updated entity:
<?php
namespace My\Entity;
use Doctrine\ORM\Mapping as ORM;
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
* @ORM\Table(name="`order`")
* @ORM\HasLifecycleCallbacks
*
* @Hateoas\Relation(
* "self",
* href = "expr('/order/' ~ object.getId())",
* exclusion = @Hateoas\Exclusion(
* groups = {"production"}
* )
* )
* @Hateoas\Relation(
* "self",
* href = "expr('/production/' ~ object.getId())",
* exclusion = @Hateoas\Exclusion(
* groups = {"order"}
* )
* )
*/
class Order
{
}