Register a service manager.

@param string         $name The name of the service manager for use in retrieving a reference to it
@param ServiceManager $service_manager

@return Core
352783
public function registerServiceManager(string $name, ServiceManager $service_manager): Core
    {
        $this->service_managers->register($name, $service_manager);
        return $this;
    }
718503
protected function getParameter(string $name)
    {
        if (!$this->container->has('parameter_bag')) {
            throw new ServiceNotFoundException('parameter_bag', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', \get_class($this)));
        }

        return $this->container->get('parameter_bag')->get($name);
    }
1037119
protected function _attainCService($name)
    {
        $name   = $this->getExtended($name);

        $cName  = $this->_normalizeName($name);
        $return = (isset($this->services[$cName])) ? $this->services[$cName] : false;

        // Aggregate Feature:
        if ($return === false) {
            ## Looking in Aggregate Feature Services
            /** @var iServiceFeatureAggregate $inService */
            foreach ($this->services_aggregate as $inService)
                if ($inService->canCreate($name))
                    return $inService->withServiceName($name);
        }

        return $return;
    }
566081
public function register($name, $service, $args = [], $params = false)
    {
        return $this->factory->register($name, $service, $args, $params);
    }
535935
public function loadService($service_name) {
    // Definimos el nombre de la clase completa del servicio.
    $class = 'BlenderDeluxe\Khipu\KhipuService\KhipuService' . $service_name;
    // Asignamos la ruta del archivo que contiene la clase.

    // Consultamos si existe el archivo.
    if (class_exists($class)) {
      // Si existe se llama.

      $services_name = self::getAllServicesName();

      if ($services_name[$service_name]) {
        // Es requerido identificarse para usar estos servicios.
        if ($this->receiver_id && $this->secret) {
          $service = new $class($this->receiver_id, $this->secret);
        } else {
            // Invocamos un Exception
            throw new Exception("Is necessary to authenticate to use the service \"$service_name\"");
        }
      }
      else {
        $service = new $class();
      }
        $service->setAgent($this->agent);
        return $service;
    }
    // Si no existe el servicio se invoca un Exception
    throw new Exception("The service \"$service_name\" does not exist");

  }
1132581
public function getServicePluginManager()
	{
	    if($this->servicePluginManager === null){
	        $this->servicePluginManager = new ServicePluginManager();
	        $that = $this;
	
	        $this->servicePluginManager->addInitializer(function ($instance, $serviceManager) use ($that) {
	             
	            $name     = $serviceManager->getCreationInstanceName();
	            $options  = $serviceManager->getCreationInstanceOptions();
	             
	            /**
	             * Configure service
	            */
	            if($options !== null && sizeof($options) &&
	               $instance instanceof Feature\ConfigurableInterface){
	
	                $instance->setConfig($options);
	            }
	        });
	    }
	     
	    return $this->servicePluginManager;
	}
74038
public function get($name)
    {
        if (isset($this->service_managers[$name])) {
            return $this->service_managers[$name];
        } else {
            throw new ServiceManagerNotFoundException('No service manager has been registered as ' . $name);
        }
    }
582362
static public function get($apiManager, $name)
	{
		if(!array_key_exists($name,self::$managerMap)){
            throw new \InvalidArgumentException('Error in Factory Manager. This manager ['.$name.']is not supported');
        }
        $className = self::$managerMap[$name];
        return self::factory($apiManager, $className);
	}
387583
protected function registerManager()
	{
		$me = $this;

		$this->app->bindShared('queue', function($app) use ($me)
		{
			// Once we have an instance of the queue manager, we will register the various
			// resolvers for the queue connectors. These connectors are responsible for
			// creating the classes that accept queue configs and instantiate queues.
			$manager = new QueueManager($app);

			$me->registerConnectors($manager);

			return $manager;
		});
	}
100933
public function service($name, $callable) {

        $this->registry[$name] = function($c) use($callable) {
            static $object;

            if (null === $object) {
                $object = $callable($c);
            }

            return $object;
        };

        return $this;
    }
1128509
public function init(ModuleManagerInterface $manager)
    {
        if (!$manager instanceof ModuleManager) {
            $errMsg =sprintf('Module manager not implement %s', ModuleManager::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }

        
        /** @var ServiceLocatorInterface $sm */
        $sm = $manager->getEvent()->getParam('ServiceManager');

        if (!$sm instanceof ServiceLocatorInterface) {
            $errMsg = sprintf('Service locator not implement %s', ServiceLocatorInterface::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }
        /** @var ServiceListenerInterface $serviceListener */
        $serviceListener = $sm->get('ServiceListener');
        if (!$serviceListener instanceof ServiceListenerInterface) {
            $errMsg = sprintf('ServiceListener not implement %s', ServiceListenerInterface::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }


        $serviceListener->addServiceManager(
            EntryNameResolverManagerInterface::class,
            EntryNameResolverManager::CONFIG_KEY,
            EntryNameResolverProviderInterface::class,
            'getEntryNameResolverConfig'
        );

    }
442536
public function createService(ServiceLocatorInterface $serviceManager)
    {
        $serviceLocator = $serviceManager->getServiceLocator();

        return $this->__invoke($serviceLocator, null);
    }
557109
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (array_key_exists($requestedName, $this->prototype)) {
            return false !== $this->prototype[$requestedName];
        }

        $appServiceLocator = $serviceLocator;
        if ($serviceLocator instanceof AbstractPluginManager) {
            $appServiceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var OrmEntityLocatorInterface $ormEntityLocator */
        $ormEntityLocator = $appServiceLocator->get(OrmEntityLocatorInterface::class);

        $hasOrmEntity = $ormEntityLocator->has($requestedName);
        if (false === $hasOrmEntity) {
            $this->prototype[$requestedName] = false;
        }

        return $hasOrmEntity;
    }
218237
public function getManager(?string $name = null) : ObjectManager
    {
        if ($name === null) {
            $name = $this->defaultManager;
        }

        if (! isset($this->managers[$name])) {
            throw new InvalidArgumentException(
                sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name)
            );
        }

        /** @var ObjectManager $objectManager */
        $objectManager = $this->getService($this->managers[$name]);

        return $objectManager;
    }
1212387
protected function getServiceManager()
    {
        try {
            $serviceManager = $this->getOriginalServiceManager();
        } catch (InvalidServiceManagerException $e) {
            $serviceManager = ServiceManager::getServiceManager();
        }
        return $serviceManager;
    }
1123632
private function service($name)
    {
        if (!isset($this->registry[$name])) {
            if (isset(self::$services[$name])) {
                $this->registry[$name] = new self::$services[$name]($this);
            } else {
                throw new InvalidArgumentException(sprintf('Service %s does not implement', $name));
            }
        }

        return $this->registry[$name];
    }
547288
private function getService(string $name, array $params = []): ?IService
    {
        if (array_key_exists($name, $this->servicesInstances)) {
            return $this->servicesInstances[$name];
        }

        $serviceConfig = $this->getServiceConfig($name);
        if ($serviceConfig === null) {
            return null;
        }

        $class = $serviceConfig['class'];
        unset($serviceConfig['class']);
        $serviceConfig = array_merge($serviceConfig, isset($params[0]) && \is_array($params[0]) ? $params[0] : []);

        if (!class_exists($class)) {
            throw new InvalidConfigException(sprintf('Class %s does not exists', $class));
        }

        if (\is_subclass_of($class, BaseModelService::class)
            || \is_subclass_of($class, BaseControllerService::class)
        ) {
            $service = new $class($this, $serviceConfig);
        } else {
            $service = new $class($serviceConfig);
        }

        if (!($service instanceof IService)) {
            throw new InvalidConfigException('Service class must implement `' . IService::class . '`.');
        }

        return $this->servicesInstances[$name] = $service;
    }