Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links get rendered multiple times #200

Open
Duske opened this issue May 10, 2015 · 1 comment
Open

Links get rendered multiple times #200

Duske opened this issue May 10, 2015 · 1 comment
Labels

Comments

@Duske
Copy link

Duske commented May 10, 2015

Hey guys,

does someone has had the problem that a link configured as an annotation gets rendered more than once? Do I need to configure something?

For example:
renderer:

$this->hateoas = HateoasBuilder::create()->build();
$bookDto = new BookDto('mybook', '7343-3243-3243');
echo $this->hateoas->serialize($bookDto, 'json');

the output

{
    "__identity": "7343-3243-3243",
    "name": "mybook",
    "_links": {
        "self": [
            {
                "href": "books/7343-3243-3243"
            },
            {
                "href": "books/7343-3243-3243"
            }
        ]
    }
}

The class:

<?php

use TYPO3\Flow\Annotations as Flow;
use JMS\Serializer\Annotation as Serializer;
use Hateoas\Configuration\Annotation as Hateoas;

/**
* @Hateoas\Relation("self", href = "expr('books/' ~ object.getIdentifier())")
*/
class BookDto {

    /**
    * @var string
    */
    protected $__identity;

    /**
    * @var string
    */
    protected $name;

    /**
     * @return string
     */
    public function getName() {

        return $this->name;
    }

    /**
     * @return string
     */
    public function getIdentifier() {

        return $this->__identity;
    }

    /**
    * @param string $name
    * @param string $__identity
    */
    public function __construct($name, $__identity = NULL) {
        $this->__identity = $__identity;
        $this->name       = $name;
    }
}

@willdurand willdurand added the bug label May 21, 2015
@jurrianvaniersel
Copy link

jurrianvaniersel commented Mar 27, 2018

Is there any update on this? I have an similar issue on a class with an RelationProvider. I am sure the relationprovider adds the relation only once, but in some conditions the link is added multiple times in the serialized result.

Problem found
In my case, the annotations where cached. Clearing the cache solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants