1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Translation\PlatformAdapter\PhraseApp\Bridge\Symfony\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use FAPI\PhraseApp\HttpClientConfigurator; |
6
|
|
|
use FAPI\PhraseApp\PhraseAppClient; |
7
|
|
|
use FAPI\PhraseApp\RequestBuilder; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
9
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
10
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
11
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
12
|
|
|
use Translation\PlatformAdapter\PhraseApp\PhraseApp; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author Sascha-Oliver Prolic <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class TranslationAdapterPhraseAppExtension extends Extension |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* {@inheritdoc} |
21
|
|
|
*/ |
22
|
|
|
public function load(array $configs, ContainerBuilder $container) |
23
|
|
|
{ |
24
|
|
|
$configuration = new Configuration($container); |
|
|
|
|
25
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
26
|
|
|
|
27
|
|
|
$requestBuilder = (new Definition(RequestBuilder::class)) |
28
|
|
|
->addArgument(new Reference($config['httplug_message_factory'])); |
29
|
|
|
|
30
|
|
|
$clientConfigurator = (new Definition(HttpClientConfigurator::class)) |
31
|
|
|
->addArgument($config['token']) |
32
|
|
|
->addArgument(new Reference($config['httplug_client'])) |
33
|
|
|
->addArgument(new Reference($config['httplug_uri_factory'])); |
34
|
|
|
|
35
|
|
|
$apiDef = $container->register('php_translation.adapter.loco.raw'); |
36
|
|
|
$apiDef->setClass(PhraseAppClient::class) |
37
|
|
|
->setFactory([PhraseAppClient::class, 'configure']) |
38
|
|
|
->addArgument($clientConfigurator) |
39
|
|
|
->addArgument(null) |
40
|
|
|
->addArgument($requestBuilder); |
41
|
|
|
|
42
|
|
|
$adapterDef = $container->register('php_translation.adapter.phrase_app'); |
43
|
|
|
$adapterDef |
44
|
|
|
->setClass(PhraseApp::class) |
45
|
|
|
->addArgument($apiDef) |
46
|
|
|
->addArgument($config['project_id']) |
47
|
|
|
->addArgument($config['locale_to_id_mapping']) |
48
|
|
|
->addArgument($config['domains']); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.