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

@Attribute name annotation giving NULL when the class parameter name is different #13

Closed
leroy0211 opened this issue Feb 17, 2016 · 9 comments
Labels

Comments

@leroy0211
Copy link
Contributor

First of all let me define my resouces.

I use this Hydra API: http://www.markus-lanthaler.com/hydra/event-api/events/41
I created a class Event like:

/**
 * Class Event
 *
 * @package Acme\DemoBundle\Entity
 * @Rest\Entity(key="events", client="Acme\DemoBundle\Command\BasicClient")
 */
class Event
{
    /**
     * @var int
     * @Rest\Id()
     */
    protected $id;

    /**
     * @var string
     * @Rest\Attribute(name="name", type="string")
     */
    protected $firstName;

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param mixed $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return string
     */
    public function getFirstName()
    {
        return $this->firstName;
    }

    /**
     * @param string $firstName
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;
    }

}

Now when I try to get the Event Entity the Id is correct. But the $firstName attribute gives me back NULL.

When I change the $firstName attribute to $name, everything works like a charm.

It looks like the @Attribute name annotation doesn't seem to work as it should.

@jdeniau jdeniau added the bug label Feb 17, 2016
@rubiodamian
Copy link

This is still happening in the lastest version.

@jdeniau
Copy link
Member

jdeniau commented Apr 12, 2018

@rubiodamian Can you copy the class you are using ? thanks

@jdeniau jdeniau reopened this Apr 12, 2018
@rubiodamian
Copy link

rubiodamian commented Apr 12, 2018

Yes, sorry!

/**
 * Agentes
 * @Rest\Entity(key="agentes")
 */
class Agentes
{
    /**
     * @Rest\Id
     * @Rest\Attribute(name="@id", type="string")
     */
    private $iri;
    /**
     * @var integer
     *
     * @Rest\Attribute(name="id", type="string")
     */
    private $codigo;
    /**
     * @var integer
     *
     * @Rest\Attribute(name="legajo", type="integer")
     */
    private $legajo;
    /**
     * @var array
     *
     * @Rest\Attribute(name="tipoCuil", type="array")
     */
    private $tipo_cuil;

the api responds with tipoCuil (array)
when the Entity attribute is tipoCuil and the field is $tipo_cuil, the field remains null. If i change the field to $tipoCuil the field fills up.

@jdeniau
Copy link
Member

jdeniau commented Apr 12, 2018

Ok it's probably due to the fact that it's an array (the code is pretty ugly for arrays, because it can be a relation or an array), I will try to look at it tomorrow

@jdeniau
Copy link
Member

jdeniau commented Apr 13, 2018

@rubiodamian Do you think it's related to #75 or not ?

@rubiodamian
Copy link

Maybe it is related because it's in the same part of code i think

@jdeniau
Copy link
Member

jdeniau commented Apr 17, 2018

Can you see if the bug is still present in the 0.29.0 ?

@rubiodamian
Copy link

bug fixed!! 👍

@jdeniau
Copy link
Member

jdeniau commented Apr 18, 2018

Great, I'm closing this

@jdeniau jdeniau closed this as completed Apr 18, 2018
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