Commit 8282d5ea authored by Daniel Król's avatar Daniel Król

Rename to Narrator

parent 93e0d344
#mleko\event-bundle
#narrator\narrator-bundle
[![Travis CI](https://travis-ci.org/mleko/event-bundle.svg?branch=master)](https://travis-ci.org/mleko/event-bundle)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mleko/event-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mleko/event-bundle/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/mleko/event-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/mleko/event-bundle/?branch=master)
[![Travis CI](https://travis-ci.org/mleko/narrator-bundle.svg?branch=master)](https://travis-ci.org/mleko/narrator-bundle)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mleko/narrator-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mleko/narrator-bundle/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/mleko/narrator-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/mleko/narrator-bundle/?branch=master)
##Installation
Using [Composer](http://getcomposer.org/):
```sh
$ composer require mleko/event-bundle
$ composer require narrator/narrator-bundle
```
{
"name": "mleko/event-bundle",
"name": "narrator/narrator-bundle",
"description": "Event library bundle",
"tags": [
"mleko",
"narrator",
"event",
"bundle",
"symfony"
],
"type": "library",
"require": {
"mleko/event": "~0.1.1",
"narrator/narrator": "^0.2",
"symfony/http-kernel": "^2.3|^3.0",
"symfony/config": "^2.3|^3.0",
"symfony/dependency-injection": "^2.3|^3.0"
......@@ -23,7 +24,7 @@
],
"autoload": {
"psr-4": {
"Mleko\\Event\\Bundle\\": "src/"
"Mleko\\Narrator\\Bundle\\": "src/"
}
}
}
<?php
/**
* @package event-bundle
* @package narrator-bundle
*/
namespace Mleko\Event\Bundle\DependencyInjection\Compiler;
namespace Mleko\Narrator\Bundle\DependencyInjection\Compiler;
class ListenerPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
......@@ -17,11 +17,11 @@ class ListenerPass implements \Symfony\Component\DependencyInjection\Compiler\Co
*/
public function process(\Symfony\Component\DependencyInjection\ContainerBuilder $container)
{
$services = $container->findTaggedServiceIds('mleko.event.listener');
$services = $container->findTaggedServiceIds('narrator.listener');
foreach ($services as $serviceId => $tags) {
foreach ($tags as $tag) {
if (!isset($tag['event'])) {
throw new \RuntimeException('The mleko.event.listener must have event attribute');
throw new \RuntimeException('The narrator.listener must have event attribute');
}
$eventName = $tag['event'];
$emitterName = isset($tag['emitter']) ? $tag['emitter'] : 'default';
......@@ -33,7 +33,7 @@ class ListenerPass implements \Symfony\Component\DependencyInjection\Compiler\Co
private function registerListener(\Symfony\Component\DependencyInjection\ContainerBuilder $container, $eventName, $emitterName, $listenerServiceId, $methodName)
{
$emitterDefinition = $container->getDefinition('mleko.event.emitter.' . $emitterName);
$emitterDefinition = $container->getDefinition('narrator.emitter.' . $emitterName);
$listeners = $emitterDefinition->getArgument(1);
$eventListeners = isset($listeners[$eventName]) ? $listeners[$eventName] : [];
$eventListeners[] = ['serviceId' => $listenerServiceId, 'methodName' => $methodName];
......
<?php
/**
* @package narrator-bundle
*/
namespace Mleko\Event\Bundle\DependencyInjection;
namespace Mleko\Narrator\Bundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
......@@ -18,7 +21,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('mleko_event');
$rootNode = $treeBuilder->root('narrator');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
......
<?php
/**
* @package narrator-bundle
*/
namespace Mleko\Event\Bundle\DependencyInjection;
namespace Mleko\Narrator\Bundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
......@@ -12,7 +15,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class MlekoEventExtension extends Extension
class NarratorExtension extends Extension
{
/**
* {@inheritdoc}
......
<?php
/**
* @package event-bundle
* @package narrator-bundle
*/
namespace Mleko\Event\Bundle;
namespace Mleko\Narrator\Bundle;
class EmitterFactory
......@@ -24,19 +24,19 @@ class EmitterFactory
}
/**
* @param \Mleko\Event\EventNameExtractor $nameExtractor
* @param \Mleko\Narrator\EventNameExtractor $nameExtractor
* @param $listenerDefinitions
* @return \Mleko\Event\SimpleEmitter
* @return \Mleko\Narrator\SimpleEmitter
*/
public function createEmitter(\Mleko\Event\EventNameExtractor $nameExtractor, $listenerDefinitions)
public function createEmitter(\Mleko\Narrator\EventNameExtractor $nameExtractor, $listenerDefinitions)
{
$listeners = [];
foreach ($listenerDefinitions as $eventName => $listenerDefinition) {
foreach ($listenerDefinition as $listenerData) {
$listeners[$eventName][] = new \Mleko\Event\Bundle\Listener\ListenerService($listenerData['serviceId'], $this->container, $listenerData['methodName']);
$listeners[$eventName][] = new Listener\ListenerService($listenerData['serviceId'], $this->container, $listenerData['methodName']);
}
}
return new \Mleko\Event\SimpleEmitter($nameExtractor, $listeners);
return new \Mleko\Narrator\SimpleEmitter($nameExtractor, $listeners);
}
}
<?php
/**
* @package event-bundle
* @package narrator-bundle
*/
namespace Mleko\Event\Bundle\Listener;
namespace Mleko\Narrator\Bundle\Listener;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ListenerService implements \Mleko\Event\Listener
class ListenerService implements \Mleko\Narrator\Listener
{
/** @var ContainerInterface */
......@@ -39,9 +39,9 @@ class ListenerService implements \Mleko\Event\Listener
* Handle an event
*
* @param object $event
* @param \Mleko\Event\Meta $meta
* @param \Mleko\Narrator\Meta $meta
*/
public function handle($event, \Mleko\Event\Meta $meta)
public function handle($event, \Mleko\Narrator\Meta $meta)
{
$listener = $this->container->get($this->serviceId);
call_user_func_array([$listener, $this->methodName], [$event, $meta]);
......
<?php
/**
* @package narrator-bundle
*/
namespace Mleko\Event\Bundle;
namespace Mleko\Narrator\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MlekoEventBundle extends Bundle
class NarratorBundle extends Bundle
{
public function build(\Symfony\Component\DependencyInjection\ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new \Mleko\Event\Bundle\DependencyInjection\Compiler\ListenerPass());
$container->addCompilerPass(new DependencyInjection\Compiler\ListenerPass());
}
}
......@@ -5,16 +5,16 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="mleko.event.emitter" alias="mleko.event.emitter.default"/>
<service id="mleko.event.emitter.default" class="Mleko\Event\SimpleEmitter">
<factory service="mleko.event.emitter_factory" method="createEmitter"/>
<argument type="service" id="mleko.event.name_extractor.class_name"/>
<service id="narrator.emitter" alias="narrator.emitter.default"/>
<service id="narrator.emitter.default" class="Mleko\Narrator\SimpleEmitter">
<factory service="narrator.emitter_factory" method="createEmitter"/>
<argument type="service" id="narrator.name_extractor.class_name"/>
<argument type="collection"/>
</service>
<service id="mleko.event.name_extractor.class_name" class="Mleko\Event\EventNameExtractor\ClassNameExtractor"/>
<service id="narrator.name_extractor.class_name" class="Mleko\Narrator\EventNameExtractor\ClassNameExtractor"/>
<service id="mleko.event.emitter_factory" class="Mleko\Event\Bundle\EmitterFactory">
<service id="narrator.emitter_factory" class="Mleko\Narrator\Bundle\EmitterFactory">
<argument type="service" id="service_container"/>
</service>
</services>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment