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

Process External Annotations #210

Closed
wodka opened this issue Aug 20, 2015 · 8 comments
Closed

Process External Annotations #210

wodka opened this issue Aug 20, 2015 · 8 comments

Comments

@wodka
Copy link
Contributor

wodka commented Aug 20, 2015

Hi,

with the addition of #209 it is possible to create Annotations outside of this bundle.

Example of this:

namespace Sonata\AdminBundle\Annotation;

use JMS\DiExtraBundle\Annotation\MetadataProcessorInterface;
use JMS\DiExtraBundle\Metadata\ClassMetadata;

/**
 * @Annotation
 */
class Admin extends MetadataProcessorInterface
{
  public function processMetadata(ClassMetadata $metadata)
  {
    // do something
  }
}

now I would like to use this by just using the new annotation:

namespace App\Admin;

use Sonata\AdminBundle\Annotation as Sonata;

/**
 * @Sonata\Admin
 */
class FooAdmin
{}

But I need to add at least the text "JMS\DiExtraBundle\Annotation" according to https://github.com/schmittjoh/JMSDiExtraBundle/blob/master/DependencyInjection/Compiler/AnnotationConfigurationPass.php#L54

Any Ideas how to extend the CompilerPass to include others as well?

I think it should first search for all classes that match MetadataProcessorInterface and then for the referenced annotations. (But this provides us with a new problem -> we would have to search for those in a typical vendor folder)

Or to add a new configuration option where we can provide Annotation Namespaces

@schmittjoh
Copy link
Owner

We can add an extension point to the compiler pass itself, an addAnnotationPattern method for example, which you can call from the other bundle to automatically register it.

Then, the user does not need to configure anything.

@wodka
Copy link
Contributor Author

wodka commented Aug 20, 2015

mhmm - sounds good, but how can I reference the CompilerPass of this bundle from some other CompilerPass?

@schmittjoh
Copy link
Owner

I would call the addAnnotationPattern method in the Bundle::build() method directly not from within a compiler pass.

@wodka
Copy link
Contributor Author

wodka commented Aug 20, 2015

I tried to implement it now - can you check it?

@wodka wodka mentioned this issue Aug 20, 2015
@wodka
Copy link
Contributor Author

wodka commented Jan 14, 2016

@schmittjoh does to implementation look fine?

@wodka
Copy link
Contributor Author

wodka commented Feb 9, 2016

@Ener-Getick are you the new maintainer?

@GuilhemN
Copy link
Collaborator

@wodka I'm a new collaborator of this bundle. I can take a look at your PRs but it's better if @schmittjoh validates them.

@GuilhemN
Copy link
Collaborator

GuilhemN commented Apr 7, 2016

Fixed in #211

@GuilhemN GuilhemN closed this as completed Apr 7, 2016
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

3 participants