21
21
class Driver implements MappingDriver
22
22
{
23
23
/**
24
- * @var bool
24
+ * @var string
25
25
*/
26
- private $ withCustomClientClass ;
26
+ private $ clientClass ;
27
27
28
- public function __construct (bool $ withCustomClientClass )
28
+ public function __construct (string $ clientClass )
29
29
{
30
- $ this ->withCustomClientClass = $ withCustomClientClass ;
30
+ $ this ->clientClass = $ clientClass ;
31
31
}
32
32
33
33
public function loadMetadataForClass ($ className , ClassMetadata $ metadata ): void
@@ -67,20 +67,19 @@ public function getAllClassNames(): array
67
67
AuthorizationCode::class,
68
68
RefreshToken::class,
69
69
],
70
- $ this ->withCustomClientClass ? [] : [Client::class ]
70
+ Client::class === $ this ->clientClass ? [Client::class ] : []
71
71
);
72
72
}
73
73
74
74
public function isTransient ($ className ): bool
75
75
{
76
- return AbstractClient::class !== $ className ;
76
+ return false ;
77
77
}
78
78
79
79
private function buildAbstractClientMetadata (ClassMetadata $ metadata ): void
80
80
{
81
81
(new ClassMetadataBuilder ($ metadata ))
82
82
->setMappedSuperClass ()
83
- ->createField ('identifier ' , 'string ' )->makePrimaryKey ()->length (32 )->build ()
84
83
->createField ('name ' , 'string ' )->length (128 )->build ()
85
84
->createField ('secret ' , 'string ' )->length (128 )->nullable (true )->build ()
86
85
->createField ('redirectUris ' , 'oauth2_redirect_uri ' )->nullable (true )->build ()
@@ -100,7 +99,7 @@ private function buildAccessTokenMetadata(ClassMetadata $metadata): void
100
99
->createField ('userIdentifier ' , 'string ' )->length (128 )->nullable (true )->build ()
101
100
->createField ('scopes ' , 'oauth2_scope ' )->nullable (true )->build ()
102
101
->addField ('revoked ' , 'boolean ' )
103
- ->createManyToOne ('client ' , Client::class )->addJoinColumn ('client ' , 'identifier ' , false , false , 'CASCADE ' )->build ()
102
+ ->createManyToOne ('client ' , $ this -> clientClass )->addJoinColumn ('client ' , 'identifier ' , false , false , 'CASCADE ' )->build ()
104
103
;
105
104
}
106
105
@@ -113,13 +112,16 @@ private function buildAuthorizationCodeMetadata(ClassMetadata $metadata): void
113
112
->createField ('userIdentifier ' , 'string ' )->length (128 )->nullable (true )->build ()
114
113
->createField ('scopes ' , 'oauth2_scope ' )->nullable (true )->build ()
115
114
->addField ('revoked ' , 'boolean ' )
116
- ->createManyToOne ('client ' , Client::class )->addJoinColumn ('client ' , 'identifier ' , false , false , 'CASCADE ' )->build ()
115
+ ->createManyToOne ('client ' , $ this -> clientClass )->addJoinColumn ('client ' , 'identifier ' , false , false , 'CASCADE ' )->build ()
117
116
;
118
117
}
119
118
120
119
private function buildClientMetadata (ClassMetadata $ metadata ): void
121
120
{
122
- (new ClassMetadataBuilder ($ metadata ))->setTable ('oauth2_client ' );
121
+ (new ClassMetadataBuilder ($ metadata ))
122
+ ->setTable ('oauth2_client ' )
123
+ ->createField ('identifier ' , 'string ' )->makePrimaryKey ()->length (32 )->build ()
124
+ ;
123
125
}
124
126
125
127
private function buildRefreshTokenMetadata (ClassMetadata $ metadata ): void
0 commit comments