protected function createServiceFactory(
        $requestedName, ReflectionClass $reflection, ContainerInterface $container
    ) {
        /** @var array $mappings */
        $mappings = $this->getServiceMapping($container, $requestedName);

        if ($reflection->implementsInterface(Factory\FactoryInterface::class)) {
            $factory = $reflection->newInstance($mappings['namespace'], $mappings['service'], $this->namespace);
        } else {
            $factory = $reflection->newInstance();
        }

        $this->lookupCache[$requestedName]['factoryInstance'] = $factory;

        if ($factory instanceof Factory\FactoryInterface) {
            /** @var Factory\FactoryInterface $factory */
            $factory->setContainer($container);
        }

        return $factory($container, $requestedName);
    }
protected function createServiceFactory(
        $requestedName, ReflectionClass $reflection, ContainerInterface $container
    ) {
        /** @var array $mappings */
        $mappings = $this->getServiceMapping($container, $requestedName);

        if ($reflection->implementsInterface(Factory\FactoryInterface::class)) {
            $factory = $reflection->newInstance($mappings['namespace'], $mappings['service'], $this->namespace);
        } else {
            $factory = $reflection->newInstance();
        }

        $this->lookupCache[$requestedName]['factoryInstance'] = $factory;

        if ($factory instanceof Factory\FactoryInterface) {
            /** @var Factory\FactoryInterface $factory */
            $factory->setContainer($container);
        }

        return $factory($container, $requestedName);
    }
protected function createServiceFactory ( $ requestedName , ReflectionClass $ reflection , ContainerInterface $ container ) { /** @var array $mappings */ $ mappings = $ this -> getServiceMapping ( $ container , $ requestedName ) ; if ( $ reflection -> implementsInterface ( Factory \ FactoryInterface :: class ) ) { $ factory = $ reflection -> newInstance ( $ mappings [ 'namespace' ] , $ mappings [ 'service' ] , $ this -> namespace ) ; } else { $ factory = $ reflection -> newInstance ( ) ; } $ this -> lookupCache [ $ requestedName ] [ 'factoryInstance' ] = $ factory ; if ( $ factory instanceof Factory \ FactoryInterface ) { /** @var Factory\FactoryInterface $factory */ $ factory -> setContainer ( $ container ) ; } return $ factory ( $ container , $ requestedName ) ; }
Initiate service factory from the ReflectionClass.

@param string             $requestedName
@param ReflectionClass    $reflection
@param ContainerInterface $container

@return mixed
@throws \ReflectionException
@throws \Psr\Container\ContainerExceptionInterface
@throws \Psr\Container\NotFoundExceptionInterface
@throws \Xloit\Std\Exception\RuntimeException
Initiate service factory from the ReflectionClass .