1414use Yoanm \JsonRpcServer \Domain \JsonRpcMethodAwareInterface ;
1515
1616/**
17- * Class JsonRpcHttpServerExtension
17+ * @see \Yoanm\SymfonyJsonRpcHttpServer\DependencyInjection\Configuration
1818 */
1919class JsonRpcHttpServerExtension implements ExtensionInterface, CompilerPassInterface
2020{
@@ -66,7 +66,8 @@ public function process(ContainerBuilder $container)
6666 {
6767 $ this ->bindJsonRpcServerDispatcher ($ container );
6868 $ this ->bindValidatorIfDefined ($ container );
69- $ this ->binJsonRpcMethods ($ container );
69+ $ this ->bindJsonRpcMethods ($ container );
70+ $ this ->bindDebug ($ container );
7071 }
7172
7273 /**
@@ -102,17 +103,19 @@ private function compileAndProcessConfigurations(array $configs, ContainerBuilde
102103 $ configuration = new Configuration ();
103104 $ config = (new Processor ())->processConfiguration ($ configuration , $ configs );
104105
105- $ httpEndpointPath = $ config ['endpoint ' ];
106+ $ container -> setParameter ( self :: ENDPOINT_PATH_CONTAINER_PARAM_ID , $ config ['endpoint ' ]) ;
106107
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+ }
108111 }
109112
110113 /**
111114 * @param ContainerBuilder $container
112115 */
113116 private function bindJsonRpcServerDispatcher (ContainerBuilder $ container ) : void
114117 {
115- $ dispatcherRef = new Reference (' json_rpc_http_server .dispatcher.server ' );
118+ $ dispatcherRef = new Reference (self :: EXTENSION_IDENTIFIER . ' .dispatcher.server ' );
116119 $ dispatcherAwareServiceList = $ container ->findTaggedServiceIds (self ::JSONRPC_SERVER_DISPATCHER_AWARE_TAG );
117120 foreach ($ dispatcherAwareServiceList as $ serviceId => $ tagAttributeList ) {
118121 $ definition = $ container ->getDefinition ($ serviceId );
@@ -149,7 +152,7 @@ private function bindValidatorIfDefined(ContainerBuilder $container) : void
149152 /**
150153 * @param ContainerBuilder $container
151154 */
152- private function binJsonRpcMethods (ContainerBuilder $ container ) : void
155+ private function bindJsonRpcMethods (ContainerBuilder $ container ) : void
153156 {
154157 $ mappingAwareServiceDefinitionList = $ this ->findAndValidateMappingAwareDefinitionList ($ container );
155158
@@ -166,7 +169,7 @@ private function binJsonRpcMethods(ContainerBuilder $container) : void
166169
167170 // Service locator for method resolver
168171 // => 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 ' )
170173 ->setArgument (0 , $ methodMappingList );
171174 }
172175
@@ -223,4 +226,12 @@ private function checkMethodAwareServiceIdList(
223226 ));
224227 }
225228 }
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+ }
226237}
0 commit comments