Inject dependencies from a DI Container.

@param  ServiceContainer $container A dependencies container instance.
@return void
514774
protected function setDependencies(ServiceContainer $container)
    {
        parent::setDependencies($container);

        if (isset($container['attachments/config'])) {
            $this->setConfig($container['attachments/config']);
        } elseif (isset($container['config']['attachments'])) {
            $this->setConfig($container['config']['attachments']);
        }
    }
1043797
public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
        if ($container) {
            // Specifically inject translator for tryTranslate method
            $this->translator = $container->get('translator');
        }
    }
715435
public function registerProviders(Container $container)
    {
        $sysProvider = new PackageProvider($this);
        $container->registerServiceProvider($sysProvider);

        $sysProvider->boot();

        $providers = (array) $this->get('providers');

        foreach ($providers as $interface => &$provider) {
            if ($provider === false) {
                continue;
            }

            if (is_subclass_of($provider, ServiceProviderInterface::class)) {
                // Handle provider
                if ($provider instanceof ClassMeta || (is_string($provider) && class_exists($provider))) {
                    $provider = $container->newInstance($provider);
                }

                if ($provider === false) {
                    continue;
                }

                $container->registerServiceProvider($provider);

                if ($provider instanceof BootableProviderInterface || method_exists($provider, 'boot')) {
                    $provider->boot($container);
                }
            } else {
                // Handle Service
                if (is_numeric($interface)) {
                    $container->prepareSharedObject($provider);
                } else {
                    $container->bindShared($interface, $provider);
                }
            }
        }

        foreach ($providers as $provider) {
            if ($provider === false) {
                continue;
            }

            if (is_subclass_of($provider, ServiceProviderInterface::class) && (
                $provider instanceof BootableDeferredProviderInterface
                || method_exists($provider, 'bootDeferred')
            )) {
                $provider->bootDeferred($container);
            }
        }
    }
1317973
protected function bootstrapServiceProviders( $service_providers, Container $container ) {
		foreach ( $service_providers as $provider ) {
			$provider->bootstrap( $container );
		}
	}
1172780
protected function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        $this->setView($container['view']);
        $this->setPropertyFactory($container['property/factory']);
        $this->setPropertyInputFactory($container['property/input/factory']);
        $this->setPropertyDisplayFactory($container['property/display/factory']);
    }
1189704
protected function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        $this->setAppConfig($container['config']);
        $this->setModelFactory($container['model/factory']);
    }
444748
protected function injectServices(FactorableInterface $factorable)
    {
        if ($factorable instanceof DependenciesAwareInterface) {
            foreach ($factorable->getDependencies() as $prop => $value) {
                $reflectionProperty = new \ReflectionProperty(get_class($factorable), $prop);
                $reflectionProperty->setAccessible(true);
                $reflectionProperty->setValue($factorable, $this->container->get($value));
            }
        }
    }
1267863
public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
        $this->application = null !== $container ? $this->container->get('bbapp') : null;
    }
899892
private function inject($container, $object, ArrayResolver $serviceConfig)
    {
        if ($this->injectorFactory == null) {
            return true;
        }

        $injectors = $this->injectorFactory->getInjectors();

        foreach ($injectors as $injector) {
            $injector->inject($container, $serviceConfig, $object);
        }

        return true;
    }
1246859
public function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        $this->basePath = $container['config']['base_path'];
        $this->publicPath = $container['config']['public_path'];

        $this->setElfinderConfig($container['elfinder/config']);
        $this->setPropertyFactory($container['property/factory']);
        $this->setCallableResolver($container['callableResolver']);

        /** @see \Charcoal\App\ServiceProvide\FilesystemServiceProvider */
        $this->filesystemConfig = $container['filesystem/config'];
        $this->filesystems = $container['filesystems'];
    }
681722
public void addDependency(Service service) {
        assertDuringInitialization();
        LOG.info("Adding a dependency on {} to {}", service.getName(), getName());
        addDependsOn(service);
        service.addDependedBy(this);
    }
894465
public function initialize($object)
    {
        if (!is_object($object)) {
            return;
        }

        foreach ($this->knownDependencies as $interface => $dependencyInfo) {
            list($setterMethod, $serviceId) = $dependencyInfo;

            if (is_a($object, $interface)) {
                $object->$setterMethod($this->container->get($serviceId));
            }
        }
    }
895720
protected function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        if (isset($container['config']['templates'])) {
            $this->availableTemplates = $this->parseChoices($container['config']['templates']);
            $this->choices = $this->availableTemplates;
        }
    }
725538
private function collectServiceDependencies(string $serviceClass, ContainerBuilder $container, array &$servicesReference): void
    {
        $reflectionClass = new \ReflectionClass($serviceClass);

        foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod)
        {
            foreach ($reflectionMethod->getParameters() as $parameter)
            {
                if (false === $parameter->hasType())
                {
                    continue;
                }

                /** @var \ReflectionType $reflectionType */
                $reflectionType     = $parameter->getType();
                $reflectionTypeName = $reflectionType->getName();

                if (true === self::supportedType($parameter) && true === $container->has($reflectionTypeName))
                {
                    $servicesReference[$reflectionTypeName] = new ServiceClosureArgument(new Reference($reflectionTypeName));
                }
            }
        }
    }
388225
public function process(ContainerBuilder $container)
    {
        $this->loader = $container->get('sulu.content.path_cleaner.replacer_loader');

        $service = $container->getDefinition('sulu.content.path_cleaner');
        $replacers = $this->loader->load($this->filename);
        $service->addArgument($replacers);
    }
310226
private function _initDependencyInjectionContainer()
    {
        $this->_container = new Dic();

        $this->_container->addResource('Packages', $this->_packages);
        $this->_container->addResource('AppStage', $this->_appStage);
        $this->_container->addResource('AutoLoader', $this->_autoLoader);
        $this->_container->addResource('Request', $this->_request);
        $this->_container->addResource('Error', $this->_error);

        $this->_container->_initTheContainer();
    }
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;
        }
    }