PHPackages                             mpoiriert/nucleus-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mpoiriert/nucleus-bundle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mpoiriert/nucleus-bundle
========================

Reusable library

0801PHP

Since Mar 26Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mpoiriert/nucleus-bundle)[ Packagist](https://packagist.org/packages/mpoiriert/nucleus-bundle)[ RSS](/packages/mpoiriert-nucleus-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Nucleus-Bundle
==============

[](#nucleus-bundle)

[![Build Status](https://camo.githubusercontent.com/db96a0099f1c4b9a3beeedf992509a8869f7d16740570317d64b795815f63ccb/68747470733a2f2f6170692e7472617669732d63692e6f72672f6d706f6972696572742f6e75636c6575732d62756e646c652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/mpoiriert/nucleus-bundle)

This is a base bundle that is use by other bundle Nucleus bundle.

By itself it have a generic compiler pass to help modifying the container for annotation.

Also it does implement the [Nucleus\\Invoker\\IInvoker](https://github.com/mpoiriert/invoker) as a service.

It also redefined the event\_dispatcher service for the class Nucleus\\Bundle\\CoreBundle\\EventDispatcher\\InvokerEventDispatcher.

NucleusCompilerPass
-------------------

[](#nucleuscompilerpass)

If you need to do something base on annotation you can use the NucleusCompilerPass to simplify your life.

You must define a annotation like documented in the [doctrine annotation project](http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html).

Once this is done you must create a class that will implements Nucleus\\Bundle\\CoreBundle\\DependencyInjection\\IAnnotationContainerGenerator that will receive a Nucleus\\Bundle\\CoreBundle\\GenerationContext

Than you need to add a mapping between your annotation and the generator in the nucleus\_core configuration.

```
nucleus_core:
    annotation_container_generators:
        test_annotation:
            annotationClass: Nucleus\Bundle\CoreBundle\Tests\DependencyInjection\Annotation
            generatorClass: Nucleus\Bundle\CoreBundle\Tests\DependencyInjection\AnnotationTagGenerator

```

From there you can do what ever you want like you were in a compiler pass.

You also have some static method in Nucleus\\Bundle\\CoreBundle\\DependencyInjection\\Definition that could help you.

If you want a example you can check the test class Nucleus\\Bundle\\CoreBundle\\Tests\\DependencyInjection\\AnnotationTagGenerator and also the [mpoiriert/binder-bundle](https://github.com/mpoiriert/binder-bundle)

Nucleus\\Bundle\\CoreBundle\\EventDispatcher\\InvokerEventDispatcher
--------------------------------------------------------------------

[](#nucleusbundlecorebundleeventdispatcherinvokereventdispatcher)

The way you must should use the new event dispatcher is by using the InvokerEventDispatcher::notify() method who does receive a $subject, $eventName and $parameters as parameter. The Invoker will map the parameters to the "listeners" of the event. The created "Event" object is the return value. You should not create typed Event by this means since the service should not manipulate the event by itself (unless you want to stop the propagation). It does work like the Request and a controller but with event.

You must also think about the way you will do unit test, no more Event faking just plane call. Also you could reuse a method of a service to be call directly without having to redefine another method or a mediator for the event itself.

```
