-
Notifications
You must be signed in to change notification settings - Fork 89
Added FQCN aliases to ServiceListenerFactory
so some could use e.g. ReflectionBasedAbstractFactories
#294
base: develop
Are you sure you want to change the base?
Conversation
…d added missing FQCN
…tting some services `manually`
@boesing However, I'm not sure if it would ever be merged, because @Xerkus has another PR for |
@thexpand Oh, didn't noticed. However, your changes supposed to be BC Break since you are moving the factories to alias and vice versa. |
There is no ZF3, actually. There won't be ZF4. Zend Framework is no longer a monolithic framework, but rather a component-based one, as it is now divided into separate repositories, each with its own versioning (i.e. So I guess you are talking about v4 of The only benefit from having class constants over service strings is to let developers prepare for the upcoming PS: @boesing you have wasted some time doing the same I did in my PR. |
Can you explain where do you see a BC break? Thanks! |
@froschdesign Actually, we have this configuration: public function testDelegatorIsBeingCalled()
{
$controllers = $this->prophesize(ControllerManager::class)->reveal();
$services = new ServiceManager();
$factory = function () use ($controllers) {
return $controllers;
};
$services->setFactory('ControllerManager', $factory);
$delegator = $this->createMock(DelegatorFactoryInterface::class);
$delegator->expects($this->once())->method('__invoke')->willReturn($controllers);
$services->addDelegator('ControllerManager', $delegator);
$this->assertSame($controllers, $services->get('ControllerManager'));
} If you change this to the following (which does that PR we are talking about [#292]), it will look like this: public function testDelegatorIsBeingCalled()
{
$controllers = $this->prophesize(ControllerManager::class)->reveal();
$services = new ServiceManager();
$factory = function () use ($controllers) {
return $controllers;
};
$services->setFactory(ControllerManager::class, $factory);
$services->setAlias('ControllerManager', ControllerManager::class);
$delegator = $this->createMock(DelegatorFactoryInterface::class);
$delegator->expects($this->once())->method('__invoke')->willReturn($controllers);
$services->addDelegator('ControllerManager', $delegator);
$this->assertSame($controllers, $services->get('ControllerManager'));
} Since there is no delegator registered for So, in fact, every project which implemented own delegators for the But if this PR (#294) will get merged, anything supposed to be fine until zend-mvc v4 (where we can swap aliases to make anything correct). public function testDelegatorIsBeingCalled()
{
$controllers = $this->prophesize(ControllerManager::class)->reveal();
$services = new ServiceManager();
$factory = function () use ($controllers) {
return $controllers;
};
$services->setFactory('ControllerManager', $factory);
$services->setAlias(ControllerManager::class, 'ControllerManager');
$delegator = $this->createMock(DelegatorFactoryInterface::class);
$delegator->expects($this->once())->method('__invoke')->willReturn($controllers);
$services->addDelegator('ControllerManager', $delegator);
$this->assertSame($controllers, $services->get(ControllerManager::class));
} |
@boesing I think that the main problem is that It worked okay, but I'm not sure that I am right. Anyone? EDIT: Extending a little bit more. However, when creating a service, the already resolved name is used to access its delegator. |
@froschdesign Delegators are added to the service manager by the actual name of the service and not by their aliases. Moving the actual service names in the aliases array will be a BC Break, as previously registered delegators to that service won't be called at all. What we can do is already implemented with this PR. The missing FQCN class constants are added as aliases to the actual service names, which we don't change to keep backwards compatibility. As we discusses, @boesing remembered doing a mistake more than an year ago with What I suggest is that we close my PR (#292) and leave this one, as it does not introduce a BC Break. As for the failing Travis build - I've created a hotfix on the master branch (#295). When accepted and merged to the |
On hold for now as it potentially conflicts with my work in progress for next major. |
This repository has been closed and moved to laminas/laminas-mvc; a new issue has been opened at laminas/laminas-mvc#10. |
This repository has been moved to laminas/laminas-mvc. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
The
ServiceListenerFactory
is actually missing some aliases.I've added the missing ones and fixed the old unit tests which provided non-matching configuration to the unit test either.
For ZF4 we should consider switching the FQCN to the
factories
and moving the old strings to thealiases
configuration.