/** * Fetch a single RPC service * * @todo get route details? * @param string $controllerServiceName * @return DoctrineRpcServiceEntity|false */ public function fetch($controllerServiceName) { $data = array('controller_service_name' => $controllerServiceName); $config = $this->configResource->fetch(true); if (isset($config['zf-rpc']) && isset($config['zf-rpc'][$controllerServiceName])) { $rpcConfig = $config['zf-rpc'][$controllerServiceName]; if (isset($rpcConfig['route_name'])) { $data['route_name'] = $rpcConfig['route_name']; $data['route_match'] = $this->getRouteMatchStringFromModuleConfig($data['route_name'], $config); } if (isset($rpcConfig['http_methods'])) { $data['http_methods'] = $rpcConfig['http_methods']; } } else { return false; } if (isset($config['zf-content-negotiation'])) { $contentNegotiationConfig = $config['zf-content-negotiation']; if (isset($contentNegotiationConfig['controllers']) && isset($contentNegotiationConfig['controllers'][$controllerServiceName])) { $data['selector'] = $contentNegotiationConfig['controllers'][$controllerServiceName]; } if (isset($contentNegotiationConfig['accept_whitelist']) && isset($contentNegotiationConfig['accept_whitelist'][$controllerServiceName])) { // @codeCoverageIgnoreStart // Is this handled differently in recent versions of Apigility // FIXME: verify this\ $data['accept_whitelist'] = $contentNegotiationConfig['accept_whitelist'][$controllerServiceName]; } // @codeCoverageIgnoreEnd if (isset($contentNegotiationConfig['content_type_whitelist']) && isset($contentNegotiationConfig['content_type_whitelist'][$controllerServiceName])) { // @codeCoverageIgnoreStart // Is this handled differently in recent versions of Apigility // FIXME: verify this\ $data['content_type_whitelist'] = $contentNegotiationConfig['content_type_whitelist'][$controllerServiceName]; } // @codeCoverageIgnoreEnd } $service = new DoctrineRpcServiceEntity(); $service->exchangeArray($data); return $service; }
/** * Inject the class name of the controller, if it can be resolved. * * @param DoctrineRpcServiceEntity $service */ protected function injectControllerClass(DoctrineRpcServiceEntity $service) { $controllerServiceName = $service->controllerServiceName; if (!$this->controllerManager->has($controllerServiceName)) { // @codeCoverageIgnoreStart return; // @codeCoverageIgnoreEnd } $controller = $this->controllerManager->get($controllerServiceName); $service->exchangeArray(array('controller_class' => get_class($controller))); }