Register a container initializer if it has not been registered yet.

@param ContainerInitializerInterface $initializer
@return ContainerInitializerLoader
514976
public function registerInitializer(ContainerInitializerInterface $initializer)
	{
		$key = get_class($initializer);
		
		if(empty($this->initializers[$key]))
		{
			$this->initializers[$key] = $initializer;
		}
		
		return $this;
	}
776884
public static function createObserver(
        ContainerInterface $container
    ): ObserverInterface {
        /**
         * @var Observer
         */
        $observer = new Observer($container->get(ObservedFactoryInterface::class));
        $observer->addEventDispatcher($container->get(EventDispatcherBridgeInterface::class));
        $observer->setTokenizer($container->get(TokenizerInterface::class));

        return $observer;
    }
1171112
public function register(ContainerInterface $container, Configurable $config)
    {
        if ( ! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }

        $entityManager = EntityManager::create(
            $config->database,
            Setup::createAnnotationMetadataConfiguration(
                $config->annotationDirs, $config->dev, $config->proxyDir, $config->cache, false
            )
        );

        $container->add($config->getServiceName(), $entityManager);
    }
992780
public function register(ServiceProviderInterface $provider, array $values = array())
    {
        $this->providers[] = $provider;
        $container = $this->container;
        $container->register($provider, $values);

        return $container;
    }
1670
protected static function prepareSerializer(SerializerInterface $serializer = null)
    {
        if (null === $serializer) {
            $serializer = SerializerFactory::create();
        }

        return $serializer;
    }
1246902
public function registerLoader(InputLoaderInterface $loader) {
        foreach ($loader->getSupportedMimeTypes() as $mime => $extensions) {
            if (!isset($this->loaders[$mime])) {
                $this->loaders[$mime] = [];
            }

            if (!isset($this->mimeTypeToExtension[$mime])) {
                $this->mimeTypeToExtension[$mime] = [];
            }

            if (!is_array($extensions)) {
                $extensions = [$extensions];
            }

            foreach ($extensions as $extension) {
                $this->mimeTypeToExtension[$mime][] = $extension;
            }

            array_unshift($this->loaders[$mime], $loader);
        }

        return $this;
    }
1017017
public function register(ContainerInterface $container, Configurable $config)
    {
        if ( ! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }

        $requestFilter = new RequestFilter($config);

        $container->add($config->getServiceName(), $requestFilter);
    }
821110
public function build() : ContainerInterface
    {
        try{
            // call bootstrap code
            $startup = $this->bootstrap;
            
            $startup($this->container);
        }
        catch(\Throwable $e)
        {
            throw new ContainerBuildingException($e);
        }
        return $this->container;
    }
428442
private function processContextInitializers(ContainerBuilder $container)
    {
        $references = $this->processor->findAndSortTaggedServices($container, self::INITIALIZER_TAG);
        $definition = $container->getDefinition(self::FACTORY_ID);

        foreach ($references as $reference) {
            $definition->addMethodCall('registerContextInitializer', array($reference));
        }
    }
29573
public function register(ContainerInterface $container)
    {
        if (! isset($container['session'])) {
            $container['session'] = function (ContainerInterface $container) {
                return new Session;
            };
        }

        if (! isset($container['router'])) {
            /**
             * This service MUST return a SHARED instance
             * of Mbh\Interfaces\RouterInterface.
             *
             * @param Container $container
             * @return RouterInterface
             */
            $container['router'] = function (ContainerInterface $container) {
                $routerCacheFile = false;
                if (isset($container->get('settings')['routerCacheFile'])) {
                    $routerCacheFile = $container->get('settings')['routerCacheFile'];
                }

                $router = (new Router)->setCacheFile($routerCacheFile);
                if (method_exists($router, 'setContainer')) {
                    $router->setContainer($container);
                }

                if (method_exists($router, 'setCallableResolver')) {
                    $router->setCallableResolver($container['callableResolver']);
                }

                return $router;
            };
        }
    }
927453
public function addActionLoader(LoaderInterface $loader)
    {
        if ($this->handler) {
            throw new AlreadyBuildedException('The handler already builded.');
        }

        $this->actionLoaders[spl_object_hash($loader)] = $loader;

        return $this;
    }
661228
protected function init(ServiceLocatorInterface $serviceLocator)
    {
        if (true === $this->isInit) {
            return $this->isInit;
        }

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

        /** @var DoctrineObjectHydratorLocatorInterface $doctrineObjectHydratorLocator */
        $doctrineObjectHydratorLocator = $appServiceLocator->get(DoctrineObjectHydratorLocatorInterface::class);
        $this->setDoctrineObjectHydratorLocator($doctrineObjectHydratorLocator);


        $this->isInit = true;
        return $this->isInit;
    }
297236
public function createRepositoryFactory(ContainerInterface $container)
    {
        if (empty($this->configFile)) {
            $this->configFile = $container->get('ConfigDirectory') . '/config/database.ini';
        }

        $config = parse_ini_file($this->configFile, true);

        $configuration = new Configuration;

        // Add logger
        $logger = new DebugStack;
        $configuration->setSQLLogger($logger);

        $connection = DriverManager::getConnection(
            [
                'url'     => $config['databaseUrl'],
                'charset' => 'utf8',
            ],
            $configuration
        );
        $transactor = new DoctrineTransactor($connection);

        $repositoryFactory = new RepositoryFactory($config, $connection, $transactor);

        if ($container->has('dispatcher')) {
            $repositoryFactory->setDispatcher($container->get('dispatcher'));
        }

        return $repositoryFactory;
    }
1237959
public function add(ProviderInterface $provider)
    {
        $container = $this->container;

        $this->container = $provider->register($container);

        $this->providers[] = (string) get_class($provider);

        return $this;
    }
1306751
private function registerInitializers(array $initializers)
    {
        foreach ($initializers as $initializer) {
            if (is_string($initializer) && class_exists($initializer)) {
                $initializer = new $initializer();
                if (! ($initializer instanceof InitializerInterface)) {
                    throw InvalidArgumentException::fromInvalidInitializer($initializer);
                }
            }
            if (is_callable($initializer)) {
                $this->initializers[] = $initializer;
            } else {
                throw InvalidArgumentException::fromInvalidInitializer($initializer);
            }
        }
    }
31969
public function getSerializer(string $serializer): SerializerInterface
    {
        $class = class_exists($serializer)
            ? $serializer
            : sprintf('Windwalker\Cache\Serializer\%sSerializer', StringNormalise::toCamelCase($serializer));

        if (!class_exists($class)) {
            throw new \DomainException(sprintf('Cache Serializer: %s not supported.', ucfirst($serializer)));
        }

        return $this->container->newInstance($class);
    }
1271447
public function container(string $containerClass = Container::class): ContainerInterface
    {
        if (($source = $this->getDefinitionSource()) instanceof MutableDefinitionSource) {
            return new $containerClass($source, $this->getProxyFactory(), $this->getWrapperContainer());
        }
        return $source;
    }