Handles class instanciation

@param ArrayResolver $serviceConfig
@param string $serviceName
@param Container $container
@return object
334679
private function activate($container, ArrayResolver $serviceConfig, $serviceName)
    {
        $this->typeInitializer->initialize($container, $serviceConfig);

        $activator = $this->activatorFactory->getActivator($serviceName, $serviceConfig);

        return $activator->createInstance($container, $serviceConfig, $serviceName);
    }
1206654
private function createProxy($className, callable $serviceFactory, Container $app)
    {
        return $this->proxyFactory->createProxy(
            $className,
            function (&$wrappedObject, $proxy, $method, $parameters, &$initializer) use (
                $className,
                $serviceFactory,
                $app
            ) {
                $wrappedObject = $serviceFactory($app);
                $initializer = null;
                return true;
            }
        );
    }
816015
public function create($name, ...$params) {
        if (!isset($this->services[$name])) throw new ServiceNotFoundException('Service "'.$name.'" not found.');
        try {
            return $this->services[$name]->resolve($factory=true, $params);
        }
        catch (\Exception $ex) {
            throw new ContainerException($ex->getMessage(), $ex->getCode(), $ex);
        }
    }
373381
private function createResolvers(array $config, ContainerInterface $container)
    {
        $resolvers = [];

        foreach ($config as $resolver) {
            if ($resolver instanceof Resolver\ResolverInterface) {
                $resolvers[] = $resolver;
                continue;
            }

            if (! is_string($resolver)) {
                continue;
            }

            if ($container->has($resolver)) {
                $resolvers[] = $container->get($resolver);
                continue;
            }

            if (class_exists($resolver)) {
                $resolvers[] = new $resolver();
                continue;
            }
        }

        return $resolvers;
    }
443024
public function configureServiceManager(ServiceManager $serviceManager)
    {
        foreach ($this->config as $key => $value) {
            switch ($key) {
                case 'factories':
                    $this->configureFactories($serviceManager, $value);
                    break;
            }
        }
    }
1259175
protected function getConfigHelper($serviceName)
    {
        $storage = new HydraTokenStorage();
        $provider = new DefaultServiceProvider($storage);

        $className = $this->getConfigHelperClassName($serviceName);

        return new $className(
            $storage,
            $provider,
            $serviceName
        );
    }
1317000
public function createInstance(Container $container, ArrayResolver $serviceConfig, $serviceName)
    {
        if (! $this->initialized) {
            $this->initialize($container);
        }

        $sequence = $serviceConfig
            ->resolveStrict($this->activatorKey . '.sequence')
            ->extract();

        for ($i = 0; $i < count($sequence); $i++) {
            $sequence[$i] = array_merge(
                [
                    $sequence[$i]
                ],
                $serviceConfig->resolve($this->activatorKey . '.' . $sequence[$i], [], true)->extract()
            );
        }

        $nextLayerConfig = $serviceConfig->resolve($this->activatorKey . '.handler', null);
        $nextLayer = null;

        if ($nextLayerConfig !== null) {
            $nextLayer = $container->resolve($nextLayerConfig);
        }

        return $this->layerBuilder->build($nextLayer, $sequence);
    }
308861
protected function loadInstanceFromContainer($containerClass) {
        $this->containerInstance = $this->loadIntermediateContainerInstance($containerClass);

        try {
            $this->instance = $this->containerInstance->getInstance();
        } catch (BadConfigurationException $e) {
            $e = new ServiceException($e->getMessage(), $e->getCode(), $e);
            $e->setServiceName($this->serviceName);
            throw $e;
        }
    }
972979
private function overrideServices(ContainerBuilder $container, array $services)
    {
        $serviceConfig = array(
            'auth_handler' => 'ma27_api_key_authentication.auth_handler',
            'key_factory'  => 'ma27_api_key_authentication.key_factory',
        );

        foreach ($serviceConfig as $configIndex => $replaceableServiceId) {
            if (!isset($services[$configIndex]) || null === $serviceId = $services[$configIndex]) {
                continue;
            }

            $container->removeDefinition($replaceableServiceId);
            $container->setAlias($replaceableServiceId, new Alias($serviceId));
        }
    }
624837
public static function generalServiceManager(Iterable $serviceConfig = NULL, $selfRefNames= []) {
        if(!static::$serviceManager) {
            if(is_null($serviceConfig))
                throw new ServiceException(sprintf("First call of %s must pass a service configuration", __METHOD__), 13);

            /** @var ServiceManager $man */
            $man = static::$serviceManager = new static($serviceConfig);
            $man->selfReferenceNames = array_merge($man->selfReferenceNames, $selfRefNames);

            if($n = self::getGlobalVariableName())
                $GLOBALS[$n] = $man;
        }
        return static::$serviceManager;
    }
1006861
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
		if (! $container->has($config->service_identifier)) {
            $classname = $config->service_identifier->classname;
            $instance  = new $classname($config);
            $container->set($config->service_identifier, $instance);
        }

		$session = $container->get($config->service_identifier);

		if ($session->getState() === self::STATE_EXPIRED) {
			$session->restart();
		}

        return $session;
    }
589803
public function createService(ServiceLocatorInterface $container)
    {
        // Retrieve the parent container when under zend-servicemanager v2
        if (method_exists($container, 'getServiceLocator')) {
            $container = $container->getServiceLocator() ?: $container;
        }

        return $this($container, ErrorReference::class);
    }
1359229
public function createForService($serviceName) {
		if ($this->_basePath === null) {
			throw new ConfigError('Base path was not given');
		}
		
		$filename = $this->_filenameTemplate;
		
		if (strpos($filename, self::PATTERN_SERVICE) !== false) {
			$filename = str_replace(self::PATTERN_SERVICE, $serviceName, $filename);
		}
		
		if (strpos($filename, self::PATTERN_DATE) !== false) {
			$filename = str_replace(self::PATTERN_DATE, date($this->_dateFormat), $filename);
		}
		
		$path = $this->_basePath;
		
		if ($this->_separateDirs) {
			$path .= DIRECTORY_SEPARATOR . $serviceName;
			
			if ((! file_exists($path) || ! is_dir($path)) && ! mkdir($path)) {
				throw new NoDirectory('Directory does not exists and unable to create: "' . $path . '"');
			}
		}
		
		$path .= DIRECTORY_SEPARATOR . $filename;
		
		if (isset($this->_loggers[$serviceName])) {
			return $this->_loggers[$serviceName];
		}
		
		$adapter = $this->getCreateCallback()->__invoke($path);
		$logger  = new Logger($adapter);
		
		$this->_loggers[$serviceName] = $logger;
		return $logger;
	}
138205
private function _instanciateService($className, $resolvedDependencies) {
        $service = $this->_services[$className];
        switch ($service->constructorType) {
            case (serviceWrapper::SINGLETON_CONSTRUCTOR):
                if (!isset($this->_serviceCache[$className])) {
                    $classDef = $service->classDef;
                    $this->_serviceCache[$className] = $classDef->newInstanceArgs($resolvedDependencies);
                }
                return $this->_serviceCache[$className];
            case (serviceWrapper::FACTORY_CONSTRUCTOR):
                $classDef = $service->classDef;
                return $classDef->newInstanceArgs($resolvedDependencies);
        }
    }
102783
public function createService(ServiceLocatorInterface $container)
    {
        // Retrieve the parent container when under zend-servicemanager v2
        if (method_exists($container, 'getServiceLocator')) {
            $container = $container->getServiceLocator() ?: $container;
        }

        return $this($container, DoctrineWriter::class);
    }
180332
private function findServiceIdsByTag(ContainerBuilder $container, ServiceConfig $serviceConfig)
    {
        $tag = $serviceConfig->get(ServiceConfig::FIND_TAG);

        $serviceIds = array();

        foreach ($container->findTaggedServiceIds($tag) as $id => $services) {
            foreach ((array) $services as $service) {
                if (null === $name = $this->findName($service, $serviceConfig)) {
                    throw new \InvalidArgumentException(
                        sprintf(
                            'Service "%s" must define a name attribute like "key" or "type" for "%s" tags.',
                            $id,
                            $tag
                        )
                    );
                }

                $serviceIds[$service[$name]] = $id;
            }
        }

        return $serviceIds;
    }
504138
protected function encapsulate($class, $serviceConfig)
    {
        $encapsulators = $this->encapsulatorFactory->getEncapsulators();

        foreach ($encapsulators as $encapsulator) {
            $class = $encapsulator->encapsulate($this, $class, $serviceConfig);
        }

        return $class;
    }