|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sylius\Bundle\AdminApiBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Sylius\Bundle\AdminApiBundle\Controller\TokenController; |
|
15
|
|
|
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; |
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
21
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
|
22
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
final class SyliusAdminApiExtension extends AbstractResourceExtension implements PrependExtensionInterface |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* {@inheritdoc} |
|
31
|
|
|
*/ |
|
32
|
|
|
public function load(array $config, ContainerBuilder $container) |
|
33
|
|
|
{ |
|
34
|
|
|
$config = $this->processConfiguration($this->getConfiguration([], $container), $config); |
|
|
|
|
|
|
35
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
36
|
|
|
|
|
37
|
|
|
$this->registerResources('sylius', $config['driver'], $config['resources'], $container); |
|
38
|
|
|
|
|
39
|
|
|
$loader->load('services.xml'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritdoc} |
|
44
|
|
|
* |
|
45
|
|
|
* @throws ServiceNotFoundException |
|
46
|
|
|
*/ |
|
47
|
|
|
public function prepend(ContainerBuilder $container) |
|
48
|
|
|
{ |
|
49
|
|
|
if (!$container->hasExtension('fos_oauth_server')) { |
|
50
|
|
|
throw new ServiceNotFoundException('FOSOAuthServerBundle must be registered in kernel.'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$config = $this->processConfiguration(new Configuration(), $container->getExtensionConfig($this->getAlias())); |
|
54
|
|
|
$resourcesConfig = $config['resources']; |
|
55
|
|
|
|
|
56
|
|
|
$container->prependExtensionConfig('fos_oauth_server', [ |
|
57
|
|
|
'db_driver' => 'orm', |
|
58
|
|
|
'client_class' => $resourcesConfig['api_client']['classes']['model'], |
|
59
|
|
|
'access_token_class' => $resourcesConfig['api_access_token']['classes']['model'], |
|
60
|
|
|
'refresh_token_class' => $resourcesConfig['api_refresh_token']['classes']['model'], |
|
61
|
|
|
'auth_code_class' => $resourcesConfig['api_auth_code']['classes']['model'], |
|
62
|
|
|
'service' => [ |
|
63
|
|
|
'user_provider' => 'sylius.admin_user_provider.email_or_name_based', |
|
64
|
|
|
'client_manager' => 'sylius.oauth_server.client_manager', |
|
65
|
|
|
], |
|
66
|
|
|
]); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: