Open jscssphtml opened 9 years ago
But since the
injectTranslator
method needs the serviceLocator and the serviceLocator isn't injected at this point of time, the result of$this->getServiceLocator()
ininjectTranslator
will always be null. And that's why there will be never a translator injected.
The code you are referring to adds initializers, it does not execute them at that point. This is what happens:
Zend\ServiceManager\AbstractPluginManager::__construct
is called and adds an initializer which sets the ServiceLocator
(so it does not run that code at that point)Zend\Validator\ValidatorPluginManager
adds the injectTranslator
initializer on line 141The initializers are executed in the same order they are added and thus the ServiceLocator
is set before the translator is injected.
@jscssphtml Is this (still) an issue? If so could you provide a simple reproducing test case to demonstrate it?
This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at https://github.com/laminas/laminas-validator/issues/47.
In Line 141 of /src/ValidatorPluginManager.php a new Initializer is added by the line:
after parent::__construct() is called. Which means, that on creation of a new validator the method `injectTranslator()' is called before the closure:
of the AbstractPluginManager is called.
But since the
injectTranslator
method needs the serviceLocator and the serviceLocator isn't injected at this point of time, the result of$this->getServiceLocator()
ininjectTranslator
will always be null. And that's why there will be never a translator injected.