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

Ability to eager-load possible metadata #19

Closed
j opened this issue Dec 14, 2012 · 5 comments · Fixed by #20
Closed

Ability to eager-load possible metadata #19

j opened this issue Dec 14, 2012 · 5 comments · Fixed by #20

Comments

@j
Copy link
Contributor

j commented Dec 14, 2012

Granted, this is a terrible idea and slow, I think I came across a use-case where I need this ability (in development of course).

Basically, I'm using the Symfony routing component and want to create routes based off metadata instead of loading all the files and suporting all metadata types in the routing component itself....

ie.)

User:
    name: user
Post:
    name: post
// User.php
/**
 * @SomeAnnotation(name="user")
 */
class User { /** ... */ }

// Post.php
/**
 * @SomeAnnotation(name="post")
 */
class Post { /** ... */ }

I'd create to routes based off the 'name' parameter '/user' and '/post'. I support other drivers too and would rather hook directly into the ClassMetadata::$myName property to get the path name instead of using Yaml::parse and other misc readers twice just to get the one property.

Of course routing will be cached in the end and there wouldn't be a need to eager load all the metadata files...

Or if you can think of a better way, I'm open to suggestions.

@j
Copy link
Contributor Author

j commented Dec 14, 2012

After trying to figure out the best way to go about this, I found that doctrine's drivers implement this.

https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php#L164

And non-annotations driver gives all the logic to the locators

https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php#L146

https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php#L148

Any chance to get this implemented? I can contribute of course, but only if you feel it belongs here. I'd hate to implement it on my side when you feel there's a better way of going about this.

@j
Copy link
Contributor Author

j commented Dec 14, 2012

So I attempted making a "DoctrineFileDriver" and "DoctrineFileLocator", but I don't see how I can re-use doctrine common code since everything in Common/Persistance/Metadata seems to have full dependencies on doctrine's ClassMetadata when I want to use this libraries metadata... Seems the only thing I can do is extend the AbstractMetadata and build in this functionality myself..

I still feel that this should belong in this library, no?

@j
Copy link
Contributor Author

j commented Dec 15, 2012

Hmm, another good use-case is this gives the ability to pre-cache before going live in production. Unless I'm wrong, I just realized the serializer and the bundle don't provide this and they cache on-the-fly. Where do you think pre-caching metadata belongs? Here or each man has to do it on their own?

@schmittjoh
Copy link
Owner

I agree, it would be a good addition to this library.

We should even be able to keep BC by using an advanced interface which extends the basic one.

@j
Copy link
Contributor Author

j commented Dec 15, 2012

Yes, I was thinking BC would be tough to keep, but that's a good idea.

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

Successfully merging a pull request may close this issue.

2 participants