14
14
use Yoanm \JsonRpcServer \Domain \JsonRpcMethodAwareInterface ;
15
15
16
16
/**
17
- * Class JsonRpcHttpServerExtension
17
+ * @see \Yoanm\SymfonyJsonRpcHttpServer\DependencyInjection\Configuration
18
18
*/
19
19
class JsonRpcHttpServerExtension implements ExtensionInterface, CompilerPassInterface
20
20
{
@@ -66,7 +66,8 @@ public function process(ContainerBuilder $container)
66
66
{
67
67
$ this ->bindJsonRpcServerDispatcher ($ container );
68
68
$ this ->bindValidatorIfDefined ($ container );
69
- $ this ->binJsonRpcMethods ($ container );
69
+ $ this ->bindJsonRpcMethods ($ container );
70
+ $ this ->bindDebug ($ container );
70
71
}
71
72
72
73
/**
@@ -102,17 +103,19 @@ private function compileAndProcessConfigurations(array $configs, ContainerBuilde
102
103
$ configuration = new Configuration ();
103
104
$ config = (new Processor ())->processConfiguration ($ configuration , $ configs );
104
105
105
- $ httpEndpointPath = $ config ['endpoint ' ];
106
+ $ container -> setParameter ( self :: ENDPOINT_PATH_CONTAINER_PARAM_ID , $ config ['endpoint ' ]) ;
106
107
107
- $ container ->setParameter (self ::ENDPOINT_PATH_CONTAINER_PARAM_ID , $ httpEndpointPath );
108
+ foreach ($ config ['debug ' ] as $ name => $ value ) {
109
+ $ container ->setParameter (self ::EXTENSION_IDENTIFIER .'.debug. ' .$ name , $ value );
110
+ }
108
111
}
109
112
110
113
/**
111
114
* @param ContainerBuilder $container
112
115
*/
113
116
private function bindJsonRpcServerDispatcher (ContainerBuilder $ container ) : void
114
117
{
115
- $ dispatcherRef = new Reference (' json_rpc_http_server .dispatcher.server ' );
118
+ $ dispatcherRef = new Reference (self :: EXTENSION_IDENTIFIER . ' .dispatcher.server ' );
116
119
$ dispatcherAwareServiceList = $ container ->findTaggedServiceIds (self ::JSONRPC_SERVER_DISPATCHER_AWARE_TAG );
117
120
foreach ($ dispatcherAwareServiceList as $ serviceId => $ tagAttributeList ) {
118
121
$ definition = $ container ->getDefinition ($ serviceId );
@@ -149,7 +152,7 @@ private function bindValidatorIfDefined(ContainerBuilder $container) : void
149
152
/**
150
153
* @param ContainerBuilder $container
151
154
*/
152
- private function binJsonRpcMethods (ContainerBuilder $ container ) : void
155
+ private function bindJsonRpcMethods (ContainerBuilder $ container ) : void
153
156
{
154
157
$ mappingAwareServiceDefinitionList = $ this ->findAndValidateMappingAwareDefinitionList ($ container );
155
158
@@ -166,7 +169,7 @@ private function binJsonRpcMethods(ContainerBuilder $container) : void
166
169
167
170
// Service locator for method resolver
168
171
// => first argument is an array of wanted service with keys as alias for internal use
169
- $ container ->getDefinition (' json_rpc_http_server .service_locator.method_resolver ' )
172
+ $ container ->getDefinition (self :: EXTENSION_IDENTIFIER . ' .service_locator.method_resolver ' )
170
173
->setArgument (0 , $ methodMappingList );
171
174
}
172
175
@@ -223,4 +226,12 @@ private function checkMethodAwareServiceIdList(
223
226
));
224
227
}
225
228
}
229
+
230
+ private function bindDebug (ContainerBuilder $ container ) : void
231
+ {
232
+ if ($ container ->getParameter (self ::EXTENSION_IDENTIFIER .'.debug.enabled ' )) {
233
+ $ container ->getDefinition ('json_rpc_server_sdk.app.serialization.jsonrpc_response_normalizer ' )
234
+ ->addArgument (new Reference ('json_rpc_server_sdk.app.serialization.jsonrpc_response_error_normalizer ' ));
235
+ }
236
+ }
226
237
}
0 commit comments