Set a provider.

@param mixed $name The name.
@param ThemeProviderInterface $provider The provider.
@return ManagerInterface Returns this manager.
@throws ReflectionException Throws a reflection exception if an error occurs.
4542
protected function setProvider($name, ThemeProviderInterface $provider) {
        $k = ObjectHelper::getShortName($name);
        $v = $this->getIndex()[$k];
        if (null !== $v) {
            $this->getProviders()[$v] = $provider;
            return $this;
        }
        $this->index[$k] = count($this->getProviders());
        return $this->addProvider($provider);
    }
669311
public function addProvider($provider) {
        $this->validateProvider($provider);

        if (is_object($provider)) {
            $class = get_class($provider);
            $instance = $provider;
        } else {
            $class = $provider;
            $instance = null;
        }

        if ( ! array_has($this->providers, $class)) {
            $this->providers[$class] = [
                'instance' => $instance,
                'tags' => [],
            ];
        }
    }
859847
protected function createCacheDriver(string $name): ProviderContract
    {
        $config = $this->config['cache'][$name] ?? [];
        $cache = $this->getCacheRepository($config);

        return $this->createProvider(new Cache($name, $config, $cache));
    }
483611
public function provider($name)
    {
        $slice = $this->slice->getSlice($name);

        $type  = $slice->getRequired('type');
        $class = $this->mapClasses[$type];

        return new $class($this, $slice);
    }
805459
protected function resolveSetter(\ReflectionClass $reflection, string $name)
    {
        $setter = 'set' . ucfirst($name);

        if ($reflection->hasMethod($setter) && $reflection->getMethod($setter)->isPublic()) {
            return $setter;
        }
    }
1168966
public Provider getProvider(String name) {
        ProviderConfig config = getProviderConfig(name);
        return (config == null) ? null : config.getProvider();
    }
362080
public function registerProvider(DataTablesProviderInterface $provider) {
        if (true === $this->exists($provider->getName())) {
            throw new AlreadyRegisteredDataTablesProviderException($provider->getName());
        }
        $this->index[$provider->getName()] = $this->size();
        return $this->addProvider($provider);
    }
489644
public function newProvider(\ReflectionClass $provider, string $context) : DependencyProvider
    {
        $dependency = $this->newAnnotatedDependency($provider);

        return new DependencyProvider($dependency, $context);
    }
17772
public function getProvider($provider)
    {
        $name = is_string($provider) ? $provider : get_class($provider);

        return Arr::first($this->serviceProviders, function ($key, $value) use ($name) {
            return $value instanceof $name;
        });
    }
760018
protected function createRuntimeDriver(string $name): ProviderContract
    {
        $config = $this->config['runtime'][$name] ?? [];

        return $this->createProvider(new Runtime($name, $config));
    }
357851
public function using($name)
    {
        if (isset($this->providers[$name])) {
            $this->provider = $this->providers[$name];
        }

        return $this;
    }
677920
protected function resolveProvider($provider): ServiceProviderInterface
    {
        // If the given "provider" is a string, we will resolve it.
        // This is simply a more convenient way of specifying your service provider classes.
        if (is_string($provider) && class_exists($provider)) {
            $provider = new $provider();
        }

        // TODO : voir si on garder ce throw car de toute facon le typehint va lever une exception.
        if (! $provider instanceof ServiceProviderInterface) {
            throw new InvalidArgumentException(
                sprintf('The provider must be an instance of "%s" or a valid class name.',
                    ServiceProviderInterface::class)
            );
        }

        return $provider;
    }
385806
public function getProvider($provider)
    {
        // Check if an instance has already been initiated. If not
        // build it and then add to the providers array.
        if (!isset($this->providers[$provider])) {
            $this->addProvider($provider);
        }

        return $this->providers[$provider];
    }
811359
public function removeProvider($name)
    {
        if ($this->hasProvider($name)) {
            unset($this->providers[$name]);

            return true;
        }

        return false;
    }
639175
protected function fromProvider($provider)
    {
        $provider = IOC::resolve($provider);
        $module = $provider->create();
        $this->add($provider->getName(), $module);
        return $module;
    }
506344
private function setProviders($providers) {
        foreach ($providers as $key => $value) {
            $this->provides[] = $value;
            $this->app->appProviders[] = [$key=>$value];
        }
    }
397225
public function getProvider($name)
    {
        if (!isset($this->providers[$name])) {
            throw new \LogicException(sprintf('The provider "%s" don\'t exists.', $name));
        }
        return $this->providers[$name];
    }