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

Additional MVC Translator BC fixes #5692

Conversation

weierophinney
Copy link
Member

  • Made MVC translator a proxy (added __call method)
  • Added a getTranslator() method to the MVC translator
  • Inject the Zend\I18n\Translator\TranslatorInterface service into the service manager if the MVC translator factory creates a new i18n Translator instance.

This PR also adds unit tests for both the MVC translator and its associated factory.

- Added `__call()` implementation to proxy unknown method calls to the
  underlying translator instance.
- Added a `getTranslator()` method to allow direct access to the
  underlying translator instance.
- Added unit tests for the above functionality.
- Ensure MVC implementation is an i18n translator implementation
- Ensure MVC implementation is a validator translator implementation
- Tested all behaviors
- Added a behavior: inject the i18n TranslatorInterface service if
  created via the Translator::factory
@weierophinney
Copy link
Member Author

Ping @dstockto - this PR is what will fix your issues.

{
public function setUp()
{
$this->i18nTranslator = $this->getMock('Zend\I18n\Translator\Translator');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you mock the interface instead here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mock the interface as, later, in one of the test methods, I mock one of the method calls (setLocale).

@DASPRiD
Copy link
Member

DASPRiD commented Jan 7, 2014

Apart from the CS failues, this looks good. Approved for merging.

@weierophinney weierophinney merged commit 1ce0cc2 into zendframework:develop Jan 7, 2014
@weierophinney weierophinney deleted the hotfix/mvc-translator-proxy-methods branch January 7, 2014 22:49
@ghost ghost assigned DASPRiD Jan 7, 2014
@dstockto
Copy link

dstockto commented Jan 8, 2014

@weierophinney The new code did not fix the issue without code changes in the application, but putting
'factories' => [
'Zend\I18n\Translator\TranslatorInterface' => 'Zend\I18n\Translator\TranslatorServiceFactory',
],

in my service_manager config did get it to go back to working and translations are working again with no more fatal error.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants