-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Make I18n component completely optional for Mvc #5406
Make I18n component completely optional for Mvc #5406
Conversation
@@ -12,6 +12,23 @@ | |||
use Zend\I18n\Translator\Translator as I18nTranslator; | |||
use Zend\Validator\Translator\TranslatorInterface as ValidatorTranslatorInterface; | |||
|
|||
class Translator extends I18nTranslator implements ValidatorTranslatorInterface | |||
class Translator implements ValidatorTranslatorInterface |
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.
The problem with this change is it means that the MvcTranslator can no longer be dropped in when you need a Translator instance.
I'm honestly not sure how to proceed, however -- if you create an interface in the Zend\I18n\Translator
namespace, we then have the problem of PHP <= 5.3.8 not being able to allow implementing two interfaces with the same signature.
This begs a question, then: should we up our minimum required version starting with 2.3.0 to PHP 5.3.9? This might solve a number of lingering issues such as this one, as well as some with ArrayObject.
Could you start a thread on the dev mailing list asking about this?
Excuse me, are just two question.
|
@dphn ZF2 remainst 5.3 compatible - ZF3 is where we'd target 5.4. No breakage on that side within 2.x |
Now php 5.4 is even available for free hosting |
yep, but not available by default on redhat like distros :( Even if alternative repos like Remi's ones are the first thing to implement when using CentOS IMHO |
What a pity! Have to wait until ZF ~ 2.7 - 2.8 But I think, a better one stride than several small ones. |
@dphn Please keep discussion on the mailing list, not comments on the issue tracker. |
$helper->setTranslator($locator->get('translator')); | ||
} elseif ($locator && $locator->has('MvcTranslator')) { | ||
$helper->setTranslator($locator->get('MvcTranslator')); |
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.
I would argue we should prefer the MvcTranslator over the Translator service here. The assumption is that the MvcTranslator service is the "bridge" implementation, and would be the one shared between all translator-aware services.
Make I18n component completely optional for Mvc
- Prefer the MvcTranslator service over the translator service - Applied object calisthenics and removed nested conditionals
@@ -17,14 +17,14 @@ | |||
* Overrides the translator factory from the i18n component in order to | |||
* replace it with the bridge class from this namespace. | |||
*/ | |||
class TranslatorServiceFactory extends I18nTranslatorServiceFactory | |||
class TranslatorServiceFactory |
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.
I am getting
Zend\ServiceManager\Exception\ServiceNotCreatedException
While attempting to create mvctranslator(alias: MvcTranslator) an invalid factory was registered for this instance type.
Should you not implement FactoryInterface?
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.
Yeah, now it's an invalid factory.
- Covers zendframework#5406, and the changes also present in this PR.
…ix/mvc-translator-wrapper Make I18n component completely optional for Mvc
…ix/mvc-translator-wrapper Make I18n component completely optional for Mvc
…ix/mvc-translator-wrapper Make I18n component completely optional for Mvc
- Prefer the MvcTranslator service over the translator service - Applied object calisthenics and removed nested conditionals
Should be fully functional by now. Closes #5108