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

RFC: annotation to skip a field in entity #813

Closed
andrewtch opened this issue Feb 9, 2021 · 3 comments
Closed

RFC: annotation to skip a field in entity #813

andrewtch opened this issue Feb 9, 2021 · 3 comments
Labels

Comments

@andrewtch
Copy link
Contributor

andrewtch commented Feb 9, 2021

Can we add an annotation like @Maker\Skip to entity fields so getters / setters are not regenerated with --regenerate --overwrite command?

The use case applies to Gedmo PersonalTranslations, for example. If you use it you have a field in your entities, $object, which is defined like so:

/**
     * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="translations")
     * @ORM\JoinColumn(name="object_id", referencedColumnName="id", onDelete="CASCADE")
     */
    protected $object;

there are getters / setters without type in mapped superclass, so when maker bundle generates setObject(Product $object), it breaks inheritance.

Another option would be skipping getter / setter generation if there is one in parent class.

What do you think?

Edit: Oh, it seems like I've have had a similar issue with Traits couple years ago #181

@jrushlow jrushlow added the RFC label Feb 15, 2021
@jrushlow
Copy link
Collaborator

Howdy @andrewtch - not a bad idea and I can envision a use case for this. I don't foresee us shooting down a PR for this new functionality. Although, I do favor @Maker\Skip or some variation along those lines instead of skipping inherited methods / properties.

@andrewtch
Copy link
Contributor Author

@jrushlow - the only drawback in @maker\Skip is that Maker does not use any annotation :) introducing a single annotation with a pretty edge use case may be a bit too much.

The problem actually is not about the skipping fields, but about the incorrect typehint for inherited methods.

I'll take a look at this next week, hopefully.

@jrushlow
Copy link
Collaborator

We have no immediate plans to implement this into MakerBundle. However, PR's are always welcome!

Note - MakerBundle is moving towards only using attributes.

@jrushlow jrushlow closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2022
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

2 participants