/** * Create and return an RpcController instance. * * @param ContainerInterface $container * @param string $requestedName * @param null|array $options * @return RpcController * @throws ServiceNotCreatedException if the callable configuration value * associated with the controller is not callable. */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $config = $container->get('config'); $callable = $config['zf-rpc'][$requestedName]['callable']; if (!is_string($callable) && !is_callable($callable)) { throw new ServiceNotCreatedException('Unable to create a controller from the configured zf-rpc callable'); } if (is_string($callable) && strpos($callable, '::') !== false) { $callable = $this->marshalCallable($callable, $container); } $controller = new RpcController(); $controller->setWrappedCallable($callable); return $controller; }
/** * @param ServiceLocatorInterface $controllerManager * @param $name * @param $requestedName * @return mixed|RpcController * @throws \Exception */ public function createServiceWithName(ServiceLocatorInterface $controllerManager, $name, $requestedName) { $serviceLocator = $controllerManager->getServiceLocator(); $config = $serviceLocator->get('Config'); $callable = $config['zf-rpc'][$requestedName]['callable']; if (!is_string($callable) && !is_callable($callable)) { throw new InvalidArgumentException('Unable to create a controller from the configured zf-rpc callable'); } if (is_string($callable) && strpos($callable, '::') !== false) { $callable = $this->marshalCallable($callable, $controllerManager, $serviceLocator); } $controller = new RpcController(); $controller->setWrappedCallable($callable); return $controller; }