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\Component\Server\Schema; |
15
|
|
|
|
16
|
|
|
use League\JsonGuard\Exceptions\SchemaLoadingException; |
17
|
|
|
use League\JsonGuard\Loader; |
18
|
|
|
|
19
|
|
|
final class DomainUriLoader implements Loader |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string[] |
23
|
|
|
*/ |
24
|
|
|
private $mappings; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* EventUriRetriever constructor. |
28
|
|
|
*/ |
29
|
|
|
public function __construct() |
30
|
|
|
{ |
31
|
|
|
$this->mappings = [ |
|
|
|
|
32
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/token/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/Token/Token-1.0.json'), |
33
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/client/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/Client/Client-1.0.json'), |
34
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/access-token/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/AccessToken/AccessToken-1.0.json'), |
35
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/refresh-token/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/RefreshToken/RefreshToken-1.0.json'), |
36
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/auth-code/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/AuthCode/AuthCode-1.0.json'), |
37
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/pre-configured-authorization/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/PreConfiguredAuthorization/PreConfiguredAuthorization-1.0.json'), |
38
|
|
|
'oauth2-framework.spomky-labs.com/schemas/model/initial-access-token/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Model/InitialAccessToken/InitialAccessToken-1.0.json'), |
39
|
|
|
'oauth2-framework.spomky-labs.com/schemas/event/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/Event-1.0.json'), |
40
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/access-token/created/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/AccessToken/AccessTokenCreatedEvent-1.0.json'), |
41
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/access-token/revoked/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/AccessToken/AccessTokenRevokedEvent-1.0.json'), |
42
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/auth-code/created/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/AuthCode/AuthCodeCreatedEvent-1.0.json'), |
43
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/auth-code/marked-as-used/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/AuthCode/AuthCodeMarkedAsUsedEvent-1.0.json'), |
44
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/auth-code/revoked/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/AuthCode/AuthCodeRevokedEvent-1.0.json'), |
45
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/client/created/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/Client/ClientCreatedEvent-1.0.json'), |
46
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/client/deleted/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/Client/ClientDeletedEvent-1.0.json'), |
47
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/client/owner-changed/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/Client/ClientOwnerChangedEvent-1.0.json'), |
48
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/client/parameters-updated/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/Client/ClientParametersUpdatedEvent-1.0.json'), |
49
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/initial-access-token/created/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/InitialAccessToken/InitialAccessTokenCreatedEvent-1.0.json'), |
50
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/initial-access-token/revoked/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/InitialAccessToken/InitialAccessTokenRevokedEvent-1.0.json'), |
51
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/pre-configured-authorization/created/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/PreConfiguredAuthorization/PreConfiguredAuthorizationCreatedEvent-1.0.json'), |
52
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/pre-configured-authorization/revoked/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/PreConfiguredAuthorization/PreConfiguredAuthorizationRevokedEvent-1.0.json'), |
53
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/refresh-token/created/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/RefreshToken/RefreshTokenCreatedEvent-1.0.json'), |
54
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/refresh-token/access-token-added/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/RefreshToken/AccessTokenAddedToRefreshTokenEvent-1.0.json'), |
55
|
|
|
'oauth2-framework.spomky-labs.com/schemas/events/refresh-token/revoked/1.0/schema' => sprintf('file://%s%s', __DIR__, '/Event/RefreshToken/RefreshTokenRevokedEvent-1.0.json'), |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function load($path) |
60
|
|
|
{ |
61
|
|
|
if (array_key_exists($path, $this->mappings)) { |
62
|
|
|
$content = file_get_contents($this->mappings[$path]); |
63
|
|
|
|
64
|
|
|
return json_decode($content); |
65
|
|
|
} |
66
|
|
|
throw SchemaLoadingException::notFound(sprintf('The schema \'%s\' is not supported.', $path)); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..