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

Introduced skipNamespaceInPath and skipNamespacePartInPath properties #1356

Closed

Conversation

ancpru
Copy link

@ancpru ancpru commented Apr 1, 2015

Hi All,

I've extended the EntityGenerator in order to make handling of namespaces more flexible. Currently the EntityGenerator class creates a full tree based on the namespace under the output-directory. This causes problems in a PSR-4-like environment. Thus, i've introduced two properties in order to manipulate the target path:

skipNamespaceInPath: if true, every class file is put directly into the output-directory. if false (which is the default and equal to the current behaviour), subdirectories based on the namespace are generated.

skipNamespacePartInPath: the part of the namespace to skip, for example if the namespace is 'Foo\Bar\Entities\MyEntity', and skipNamespacePartInPath is set to 'Foo\Bar', the entity MyEntity is generated in the directory 'Entities' under the output-directory.

Andreas

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3649

We use Jira to track the state of pull requests and the versions they got
included in.

@billschaller
Copy link
Member

@ancpru This will probably need some new tests.

@ancpru
Copy link
Author

ancpru commented Apr 1, 2015

So i propably copy testGeneratedEntityClass() and testEntityUpdatingWorks() and perform them with the new options, right?

@billschaller
Copy link
Member

@ancpru that would be a good start I think.

@Ocramius
Copy link
Member

Ocramius commented Apr 2, 2015

As discussed multiple times in the past, the generator does not support PSR-4 style paths nor does need to: simply move the files after having generated them.

I'm very unlikely going to merge further generator overhauls unless it gets split into a separate project: this thing is already too big/complex and does more damage than what it solves.

@ancpru
Copy link
Author

ancpru commented Apr 3, 2015

Ok, I guess i will drop this under this circumstances.

IMO, the generate/move-approach is an unpleasant workaround because it does not work well with updates. Class updates would require copying the current source into the temporary directory, run the generator over them, and then copy them back.

The reason I made this change was, that the PSR-1 namespace does not fit into my projects and I needed to update entity classes quite often, esp. during the development process.

But I guess I will drop this change if it won't get merged and look for a seperate workaround. And yes, I agree that it's already quite complex.

@Ocramius
Copy link
Member

Ocramius commented Apr 3, 2015

@ancpru it could really be a good idea to start segregating the generator into its own project, heh...

@billschaller
Copy link
Member

@ancpru @Ocramius I don't think it's wise or necessary to bloat the entitygenerator further with this. I think adding the generateEntityPath method would be a decent compromise, as then users could extend the EntityGenerator and implement their own entity path generation.

@Majkl578
Copy link
Contributor

Closing this as we will be removing EntityGenerator in Doctrine 3.0.

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

Successfully merging this pull request may close these issues.

None yet

5 participants