ZfcUserAdmin
ZfcUserAdmin copied to clipboard
Fix "Please be aware that ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0"
Fixes deprecated warnings when using newer versions of Zend Framework
Not a fan actualy of this. You create all teh object and only use them in the required case. I think we need lazy factories over here.
Do you want me to merge this for now? And then you can do another ticket for the factories refactoring.
oh crap, I completely forgot about this!!
I'll create the factories tonight itself and update this PR. I'll post another comment once I finish
@Danielss89 done
Those factories are zf2 way. You must use the __invoke method for zf3
Don't think that is a good idea as we want to still keep supporting zf2 apps.
I think you are referring to Zend\ServiceManager\Factory\FactoryInterface which has __invoke but this has only been added in version 3.x.
I guess it comes down to weather we want to drop support for ServiceManager 2.x or not
With this change we support SM2 but ot SM3 But you can implement fallback in the create service method and support v2 and v3
@rahuldroy create the __invoke method, and inside, call the other Create method.
@Danielss89 I think it's better to do the other way around because in that case you just have to drop the createService method when zf2 support is dropped. Also better with the parameters that are passed to those functions
So what is the final verdict then?
Agree with @stijnhau
Not tested or not sure about it but in the createService methiod i think u don't pass the SM but rather an other manager where you first have to call the getService Manageror Locator method on.
@stijnhau, Can you please elaborate on it. I did a very quick test before pushing my changes and it seems to be working fine
Can't reley elaborate on it dont know the exact details of it. and cant find it on the web(and no time now to luk deeper) But it has something to do with it not always the service manager that is passed. Sometimes, its a plginmanager or a controllermanager or something like that. maybe @Danielss89 knows more about it.
/* @var ServiceLocatorInterface $serviceLocator */ $serviceLocator = $serviceLocator->getServiceLocator();
Yes, when you are inside a factory for a controller, viewhelper, pluginhelper or formhelper, it is not a service manager being passed, but a pluginmanager. And on that you would have to do $pluginManager->getServiceLocator(); and pass that to the __invoke method. For example in the UserControllerFactory this is true.
@Danielss89 Thats the reason. I'm just doing it everwhere so i'm sure i always get one ;)
Havn't had any time to test it but most of it seems good.
Any chance, that this gets merged? I think that the composer update and the ::class changes could then be done in another PR. But at least we would get rid of the deprecated warnings
@rahuldroy Trying to use your versions but getting fatal ;(
Fatal error: Declaration of ZfcUserAdmin\Factory\Service\UserMapperFactory::__invoke($container, $requestedName, ?array $options = NULL) must be compatible with Zend\ServiceManager\Factory\FactoryInterface::__invoke(Interop\Container\ContainerInterface $container, $requestedName, ?array $options = NULL) in C:\Program Files (x86)\Zend\ZendServer\data\apps\http\__default__\0\True-Life\1.0.0_32\vendor\danielss89\zfc-user-admin\src\ZfcUserAdmin\Factory\Service\UserMapperFactory.php on line 9
Seems like you're not setting the typehint for the first paramater. Can you fix asap so i can continue testing?