Skip to content

Commit

Permalink
Merge pull request #4 from mleko/feature/bus-visibility
Browse files Browse the repository at this point in the history
Go with private by default
  • Loading branch information
mleko authored Aug 1, 2018
2 parents 5c58094 + 03e4e34 commit bee55be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ narrator:
This configuration defines two buses: "default" and "named". These buses will be registered as `narrator.event_bus.default` and `narrator.event_bus.named`.
`narrator.event_bus.default` will use `InstanceOf` resolver, therefore it will support event inheritance;
`narrator.event_bus.named` will use default configuration based on strict event name comparison.
By default all buses are registered as public services, it is possible to change that on per-bus basis using `public` parameter.
By default all buses are registered as private services, it is possible to change that on per-bus basis using `public` parameter.
4 changes: 2 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->arrayNode('event_bus')
->defaultValue(['default' => ['resolver' => ['type' => 'name', "name_extractor" => "narrator.name_extractor.class_name"], 'public' => true]])
->defaultValue(['default' => ['resolver' => ['type' => 'name', "name_extractor" => "narrator.name_extractor.class_name"], 'public' => false]])
->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->prototype("array")
->children()
->booleanNode('public')
->defaultValue(true)
->defaultValue(false)
->end()
->arrayNode('resolver')
->children()
Expand Down
15 changes: 14 additions & 1 deletion tests/Integration/SimpleEventListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class SimpleEventListenerTest extends IntegrationTest
{
public function testDefaultEventBus()
{
$config = vfsStream::newFile("config.yml");
$config->setContent(<<<'EOF'
imports:
- { resource: services.xml }
narrator:
event_bus:
default:
public: true
EOF
);
$servicesConfig = vfsStream::newFile("services.xml");
$servicesConfig->setContent(<<<'EOF'
<?xml version="1.0" encoding="UTF-8" ?>
Expand All @@ -38,8 +48,9 @@ public function testDefaultEventBus()
</container>
EOF
);
$this->root->addChild($config);
$this->root->addChild($servicesConfig);
$this->kernel->setConfigPath($servicesConfig->url());
$this->kernel->setConfigPath($config->url());
$this->kernel->boot();

$container = $this->kernel->getContainer();
Expand Down Expand Up @@ -71,6 +82,7 @@ public function testCustomEventBus()
inheritance:
resolver:
type: instanceof
public: true
EOF
);
$this->root->addChild($servicesConfig);
Expand Down Expand Up @@ -99,6 +111,7 @@ class: stdClass
resolver:
type: service
service_id: custom_resolver
public: true
EOF
);
$this->root->addChild($servicesConfig);
Expand Down

0 comments on commit bee55be

Please sign in to comment.