Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Conversation

@michalbundyra
Copy link
Member

Fixed invokable configuration - if key is different than class name the key is used as an alias.

{
$dependencies = [
'invokables' => [
TestAsset\Service::class,
Copy link
Member

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.
}

public function testInvokablesWithoutAlias()
public function testInvokableWithAlias()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be testInvokableWithoutAlias?

self::assertTrue($this->container->offsetExists('0'));
}

public function testInvokableWithoutAlias()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be testInvokableWithAlias?

@michalbundyra
Copy link
Member Author

I've create new repo with container common tests: https://github.com/webimpress/zend-container-test and added these test cases there.

weierophinney added a commit that referenced this pull request Mar 15, 2018
weierophinney added a commit that referenced this pull request Mar 15, 2018
Forward port #7

Conflicts:
	CHANGELOG.md
@weierophinney weierophinney merged commit de1504c into master Mar 15, 2018
@michalbundyra michalbundyra deleted the hotfix/invokable-alias branch March 21, 2018 14:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants