Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions modules/creation/module-translation/new-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,19 @@ class SomeAdminController extends PrestaShopAdminController

Other classes will need to retrieve the module's translator instance somehow. We recommend passing it as a parameter in the constructor and storing it for later use.

Type the parameter as `PrestaShopBundle\Translation\TranslatorInterface`, not as any of the concrete translator classes: the container decides which implementation the module receives and the debug environment decorates it, so naming a concrete class makes the module work in one environment and fail in the other.

```php
<?php
use PrestaShopBundle\Translation\TranslatorInterface;

class CustomModuleClass
{
private $translator;

public function __construct(Translator $translator)
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator
$this->translator = $translator;
}

public function foo()
Expand Down
Loading