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

add option to alias field names #433

Closed
bazo opened this issue Jan 3, 2015 · 2 comments
Closed

add option to alias field names #433

bazo opened this issue Jan 3, 2015 · 2 comments

Comments

@bazo
Copy link

bazo commented Jan 3, 2015

in our doctrine entities we have remnants after the previous programmer who left fields with names as mobil(instead of mobile), comId and many other.

now we want to expose these entities via an api, but need to present the fields under different names
e.g.: mobil -> mobile
comId -> businessId, etc

refactoring is not really an option i would like to pursue, since we also serialize some objects to json and that complicates things

so i had an idea about an alias annotation

    /** @JMS\Alias(value='mobile') */
    private $mobil;

what do you think?

@oxidec
Copy link

oxidec commented Jan 26, 2015

You can use the @VirtualProperty annotation

/** @JMS\VirtualProperty */
public function getMobile() 
{
    return $this->mobil;
}

@k-k
Copy link

k-k commented Mar 30, 2015

SerializedName does this already

/** @JMS\SerializedName('mobile') */
private $mobil;

@goetas goetas closed this as completed Mar 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants