di = $di; $this->container = $container; $this->diInstanceManagerProxy = $diInstanceManagerProxy ?: new DiInstanceManagerProxy( $di->instanceManager(), $container ); } /** * Initialize an instance via zend-di. * * @param mixed|ContainerInterface $first Container when under * zend-servicemanager v3, instance to initialize otherwise. * @param ContainerInterface|mixed $second Instance to initialize when * under zend-servicemanager v3, container otherwise. * @return void */ public function __invoke($first, $second) { if ($first instanceof AbstractPluginManager || $second instanceof ContainerInterface ) { $instance = $first; } else { $instance = $second; } $instanceManager = $this->di->instanceManager; $this->di->instanceManager = $this->diInstanceManagerProxy; try { $this->di->injectDependencies($instance); } catch (Exception $e) { throw $e; } finally { $this->di->instanceManager = $instanceManager; } } }