Thanks to visit codestin.com
Credit goes to github.com

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

Commit 51e49f6

Browse files
committed
[zendframework/zendframework#5406] Logic and order-of-ops cleanup
- Prefer the MvcTranslator service over the translator service - Applied object calisthenics and removed nested conditionals
1 parent 7fc80e0 commit 51e49f6

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src/HelperPluginManager.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,24 @@ public function injectRenderer($helper)
143143
*/
144144
public function injectTranslator($helper)
145145
{
146-
if ($helper instanceof TranslatorAwareInterface) {
147-
$locator = $this->getServiceLocator();
148-
if ($locator && $locator->has('translator')) {
149-
$helper->setTranslator($locator->get('translator'));
150-
} elseif ($locator && $locator->has('MvcTranslator')) {
151-
$helper->setTranslator($locator->get('MvcTranslator'));
152-
}
146+
if (!$helper instanceof TranslatorAwareInterface) {
147+
return;
148+
}
149+
150+
$locator = $this->getServiceLocator();
151+
152+
if (!$locator) {
153+
return;
154+
}
155+
156+
if ($locator->has('MvcTranslator')) {
157+
$helper->setTranslator($locator->get('MvcTranslator'));
158+
return;
159+
}
160+
161+
if ($locator->has('translator')) {
162+
$helper->setTranslator($locator->get('translator'));
163+
return;
153164
}
154165
}
155166

0 commit comments

Comments
 (0)