Get resolver with $name and register $services.

An exception will be thrown when a resolver for $name can not be found.

@param ResolverInterface|string $fqcn
@param iterable                 $services
@return ResolverInterface
@throws UnknownResolverType
190322
protected function getResolver(string $fqcn, iterable $services): ResolverInterface
    {
        if (is_subclass_of($fqcn, ResolverInterface::class, true) === false) {
            throw new UnknownResolverType($fqcn);
        }

        return $fqcn::factory($services);
    }
1370588
public function resolve($name)
        {
            if (!isset(self::$resources[$name])) {
                throw new Exception("[$name] is not a known resource.");
            }

            return isAke(self::$resources, $name);
        }
942082
public function resolveCallable(?string $name, callable $closure, ?array $parameters = null)
    {
        $definitions = isset($name) && $this->container->isDefined($name)
            ? $this->container->getDefiniition($name) : null;

        $callable = $this->getCallable($closure);
        $parameters = $parameters ?? $this->resolveParameters($callable->getParameters() ?? null, $definitions);

        return $callable->invokeArgs($parameters);
    }
1327670
public function overrideType($name, $fqcn)
    {
        if (false === $this->hasType($name)) {
            throw new InvalidArgumentException(sprintf('The type "%s" was not found.', $name));
        }
        return $this->setType($name, $fqcn);
    }
575715
public function get($key, array $parameters = [])
    {
        // If service is a factory, we should always
        // return new instance of the service.
        if (isset($this->factories[$key])) {
            return $this->resolve($this->factories[$key], $parameters);
        }

        // Otherwise, look for service
        // in services collection.
        if (isset($this->services[$key])) {
            // Resolve service jf we don't have
            // a deposit for this service.
            if ( ! isset($this->deposit[$key])) {
                $this->deposit[$key] = $this->resolve($this->services[$key], $parameters);
            }

            return $this->deposit[$key];
        }

        throw new BindingResolutionException("Unresolvable resolution. The [{$key}] binding is not registered.");
    }
932970
public final function resolve(string $className, CacheInterface $cache = null)
   {
       try {
           if (null !== $cache && $cache->has($className)) {
               return $cache->get($className);
           }
           $reflexion = $this->getReflection($className);
           $args = [];
           if (($constructor = $reflexion->getConstructor())) {
               foreach ($constructor->getParameters() as $param) {
                   $args[] = $this->getArg($param, $cache);
               }
           }
           $instance = $reflexion->newInstanceArgs($args);
           if (null !== $cache) {
               $cache->set($className, $instance);
           }
           return $instance;
       } catch (NotFoundException $e) {
           throw new NotFoundException(
               "Can't resolve " . $className . ": " . $e->getMessage());
       } catch (Throwable $e) {
           throw new ContainerException(
               "Can't resolve " . $className . ": " . $e->getMessage());
       }
   }
763394
public function getResolver()/*# : ParameterInterface */
    {
        if (!$this->hasResolver()) {
            throw new NotFoundException(
                Message::get(Message::PARAM_RESOLVER_MISS),
                Message::PARAM_RESOLVER_MISS
            );
        }
        return $this->resolver;
    }
1078021
public function fromStream(FilesystemStreamInterface $stream)
    {
        if (!$stream->isReadable()) {
            throw new \RuntimeException('Stream not readable');
        }

        $mimetype = null;

        foreach (array_reverse($this->__resolvers) as $name => $resolver)
        {
            //Lazy create the resolver
            if(!($resolver instanceof FilesystemMimetypeInterface))
            {
                $resolver = $this->getObject($resolver);

                if (!$resolver instanceof FilesystemMimetypeInterface) {
                    throw new \UnexpectedValueException('Resolver does not implement FilesystemMimetypeInterface');
                }

                $this->__resolvers[$name] = $resolver;
            }

            /* @var $resolver FilesystemMimetypeInterface */
            if (null !== $mimetype = $resolver->fromStream($stream)) {
                break;
            }
        }

        return $mimetype;
    }
48086
public function registerObject($service, $object)
    {
		if (!is_object($object)) {
			throw new ResolutionException("Service '$service' cannot be register as it's value is invalid");
		}

        $this->services[$service] = function () use ($object) { return $object; };
    }
106723
public function getResolver()
    {
        if ($this->resolver instanceof Resolver) {
            return $this->resolver;
        }

        $factory = new Factory();
        $this->resolver = $factory->createCached($this->getDnsServer(), $this->getLoop());

        return $this->resolver;
    }
859501
public function get($name,$default=null)
    {

        // Return null if the service is not in the container
        if(!isset($this->instances[$name]))
             return $default;

        if(array_key_exists($name,$this->bind))
            return $this->resolve($name);


        // Check if the service has been resolved in the container
        if(!$this->resolved[$name]){

            $this->instances[$name] = $this->resolve($name);
            

            return $this->instances[$name];
        }

        return $this->resolve($name);
    }
580477
public function converter(callable $callback, string ...$types): ResolverInterface
    {
        $rule = RuleFactory::converter($callback, ...$types);
        $this->addRule($rule, self::LOW_PRIORITY);

        return $this;
    }
898115
public function getRepository($name = null, $source = null, $forceNew = false)
    {
        $name = $name ?: $this->getName();

        $key = ModelResolver::getDIKey($name);

        // Let's prepare controller getter.
        if (!$this->container->exists($key)) {
            // Use resolver to find model class and create it.
            $this->container->share($key, function (Container $container) use ($name, $source) {
                $config    = clone $this->config;
                $modelName = ucfirst($name) . 'Model';
                $repoName  = ucfirst($name) . 'Repository';
                $source    = $source ?: $this->getDataSource();

                /*
                 * If the name of this model not same as this controller, we don't pass name into it,
                 * so that the model will keep it's own name.
                 * Otherwise we override the name in model config with ours.
                 */
                if ($name && strcasecmp($name, $this->getName()) !== 0) {
                    $config['name'] = null;
                }

                try {
                    $repoResolver = $this->getPackage()->getMvcResolver()->getRepositoryResolver();

                    // Use RepositoryResolver to fin Repository class
                    try {
                        $class = $repoResolver->resolve($repoName);
                    } catch (\DomainException $e) {
                        // Use ModelResolver to get legacy Model classes
                        // @deprecated
                        $class = $repoResolver->getModelResolver()->resolve($modelName);
                    }

                    // Create object by container, container will auto inject all necessary dependencies
                    return $container->createSharedObject($class, ['config' => $config]);
                } catch (\Exception $e) {
                    if (!$e instanceof \DomainException && !$e instanceof \UnexpectedValueException) {
                        throw $e;
                    }

                    // Guess the repository position
                    $class = MvcHelper::getPackageNamespace($this) . '\Repository\\' . ucfirst($repoName);

                    if (class_exists($class)) {
                        return $container->createSharedObject($class, ['source' => $source, 'config' => $config]);
                    }

                    // Guess the model position
                    // @deprecated
                    $class = MvcHelper::getPackageNamespace($this) . '\Model\\' . ucfirst($modelName);

                    if (class_exists($class)) {
                        return $container->createSharedObject($class, ['source' => $source, 'config' => $config]);
                    }

                    $config['name'] = $name;

                    return new Repository($config);
                }
            });
        }

        // Get model from controller.
        return $this->container->get($key, $forceNew);
    }
127363
protected function solve($type, $name, array $args = array())
    {
        if(!$this->services[$type]->has($name))
        {
            if($this->app[$type]->has('@'.$name))
            {
                return $this->app->dependencyCall($type, $name, $args);
            }
            else
            {
                $isShared = false;

                if($type == 'callable' && ($this->app['service']->has($name) || $isShared = $this->app['service']->has('@'.$name)))
                {
                    $service = $this->app->get($isShared ? '@'.$name : $name);

                    $this->invokables[$name] = $service;

                    if(is_callable($service))
                        return call_user_func_array($service, $args);
                }

                throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to find ['.$name.'] in the registered '.$type);
            }
        }
        else
        {
            $registry = $this->services[$type]->get($name);
        }

        return $this->filter($type, $name, $this->resolve($type, $name, $registry, $args));
    }
541714
public function get($name, array $parameters = [])
    {
        // Shared services are preserved through whole request
        if (isset($this->shared[$name])) {
            return $this->shared[$name];
        }

        if (!$this->has($name)) {
            throw new NotFoundException('No definition found for service "' . $name . '".');
        }

        $definition = $this->definitions[$name];

        // Alias is a link to another definition
        if (isset($definition['alias'])) {
            return $this->get($definition['alias']);
        }

        // "Init" directive is a function that returns instance of service
        if (isset($definition['init'])) {
            $service_class = call_user_func($definition['init'], $this, $parameters);

            if ($service_class === false) {
                throw new NotFoundException('"Init" directive for service "' . $name . '" did not produced any object.');
            }
        } else {
            $arguments = [];

            // Array of arguments which are given to constructor method
            if (isset($definition['arguments'])) {
                $arguments = $this->resolveArrayOfArguments($definition['arguments'], $parameters);
            }

            // Service is made by static method
            if (isset($definition['static'])) {
                $service_class = call_user_func_array([$definition['class'], $definition['static']], $arguments);

                if ($service_class === false) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }
            } else {
                // Service is made by normal constructor
                try {
                    $reflection_class = new \ReflectionClass($definition['class']);
                } catch (\ReflectionException $e) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }

                $service_class = $reflection_class->newInstanceArgs($arguments);
            }
        }

        // "After" directive is a function that is called after instantiation of service object
        if (isset($definition['after'])) {
            call_user_func($definition['after'], $this, $service_class, $parameters);
        }

        // Preserve shared service
        if (isset($definition['shared']) && $definition['shared'] === true) {
            $this->shared[$name] = $service_class;
        }

        return $service_class;
    }
893541
protected function resolve( $name )
	{
		$config = $this->getConfig( $name );

		if ( is_null( $config ) )
			throw new InvalidArgumentException( "Password resetter [{$name}] is not defined." );

		// The password broker uses a token repository to validate tokens and send user
		// password e-mails, as well as validating that password reset process as an
		// aggregate service of sorts providing a convenient interface for resets.
		return new PasswordBroker( $this->createTokenRepository( $config ), AccountManager::i()->resolveAuth( $config['provider'] ), Mailer::i(), $config['email'] );
	}
277559
public function addResolver(ResolverInterface $resolver, string $key): ServiceLocator
    {
        $this->resolvers[$key] = $resolver;

        return $this;
    }