| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 15 | class TranslationRetriever implements ApiResourceRetrieverInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var Translator |
||
| 19 | */ |
||
| 20 | private $translator; |
||
| 21 | /** |
||
| 22 | * @var Application |
||
| 23 | */ |
||
| 24 | private $application; |
||
| 25 | |||
| 26 | public function __construct(Translator $translator, Application $application) |
||
| 27 | { |
||
| 28 | $this->translator = $translator; |
||
| 29 | $this->application = $application; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function retrieve(string $resourceClass, $id, array $context) |
||
| 33 | { |
||
| 34 | if ($resourceClass !== Translation::class) { |
||
| 35 | throw new BadConfigurationException(__CLASS__ . ' only works with Translation'); |
||
| 36 | } |
||
| 37 | return new Translation($id, $this->translator->get($id, [], $this->application->getLocale()), new Locale($this->application->getLocale())); |
||
|
|
|||
| 38 | } |
||
| 39 | |||
| 40 | public function retrieveAll(string $resourceClass, array $context, SearchFilterRequest $searchFilterRequest |
||
| 43 | } |
||
| 44 | } |
||
| 45 |