1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2017 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Bundle\Server\DependencyInjection\Source\Endpoint; |
15
|
|
|
|
16
|
|
|
use Fluent\PhpConfigFileLoader; |
17
|
|
|
use OAuth2Framework\Bundle\Server\DependencyInjection\Source\ActionableSource; |
18
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
19
|
|
|
use Symfony\Component\Config\FileLocator; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
|
22
|
|
|
final class ClientRegistrationSource extends ActionableSource |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* ClientRegistrationSource constructor. |
26
|
|
|
*/ |
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
$this->addSubSource(new ClientRegistrationInitialAccessTokenSource()); |
30
|
|
|
$this->addSubSource(new ClientRegistrationSoftwareStatementSource()); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
protected function continueLoading(string $path, ContainerBuilder $container, array $config) |
37
|
|
|
{ |
38
|
|
|
foreach ($config as $k => $v) { |
39
|
|
|
$container->setParameter($path.'.'.$k, $v); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$loader = new PhpConfigFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/endpoint')); |
43
|
|
|
$loader->load('client_registration.php'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
protected function name(): string |
50
|
|
|
{ |
51
|
|
|
return 'client_registration'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
protected function continueConfiguration(NodeDefinition $node) |
58
|
|
|
{ |
59
|
|
|
parent::continueConfiguration($node); |
60
|
|
|
$node |
|
|
|
|
61
|
|
|
->children() |
62
|
|
|
->scalarNode('path')->defaultValue('/client/management')->end() |
63
|
|
|
->end(); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: