proxyFactory = $proxyFactory; $this->servicesMap = $servicesMap; } /** * {@inheritDoc} * * @return \ProxyManager\Proxy\VirtualProxyInterface */ public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) { $initializer = function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($callback) { $proxy->setProxyInitializer(null); $wrappedInstance = $callback(); return true; }; if (isset($this->servicesMap[$name])) { return $this->proxyFactory->createProxy($this->servicesMap[$name], $initializer); } throw new Exception\ServiceNotFoundException( sprintf('The requested service "%s" was not found in the provided services map', $name) ); } }