-
Notifications
You must be signed in to change notification settings - Fork 3
Fix invokable configuration when key is not provided and docs update #7
Conversation
| { | ||
| $dependencies = [ | ||
| 'invokables' => [ | ||
| TestAsset\Service::class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work in other containers at this time?
In zend-servicemanager currently, it doesn't; omitting the key means an alias is created, regardless of whether that alias is an integer. From what I can read of zend-auradi-config, it will not handle this, either.
The same behaviour we have in zend-servicemanager.
Proper configuration should be:
'invokables' => [
Name\Service::class => Name\Service::class,
],
or when we want to use alias:
'invokables' => [
'alias' => Name\Service::class,
],
then serivce will be available on:
- alias: $container->get('alias');
- class name: $container->get(Name\Service::class);
and it will be exactly the same instance.
test/ConfigTest.php
Outdated
| } | ||
|
|
||
| public function testInvokablesWithoutAlias() | ||
| public function testInvokableWithAlias() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be testInvokableWithoutAlias?
test/ConfigTest.php
Outdated
| self::assertTrue($this->container->offsetExists('0')); | ||
| } | ||
|
|
||
| public function testInvokableWithoutAlias() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be testInvokableWithAlias?
|
I've create new repo with container common tests: https://github.com/webimpress/zend-container-test and added these test cases there. |
Forward port #7 Conflicts: CHANGELOG.md
Fixed invokable configuration - if key is different than class name the key is used as an alias.