Registers user-authentication extensions.

@param  Container $container The Pimple DI container.
@return void
359557
protected function registerAuthExtensions(Container $container)
    {
        /**
         * @param  Container $container The Pimple DI Container.
         * @return Authenticator
         */
        $container['admin/authenticator'] = function (Container $container) {
            return new Authenticator([
                'logger'        => $container['logger'],
                'user_type'     => User::class,
                'user_factory'  => $container['model/factory'],
                'token_type'    => AuthToken::class,
                'token_factory' => $container['model/factory']
            ]);
        };

        /**
         * For 'charcoal-ui'
         *
         * @todo   Do this right!
         * @param  Container $container The Pimple DI Container.
         * @return Authenticator
         */
        $container['authenticator'] = function (Container $container) {
            return $container['admin/authenticator'];
        };

        /**
         * @param  Container $container The Pimple DI container.
         * @return Authorizer
         */
        $container['admin/authorizer'] = function (Container $container) {
            return new Authorizer([
                'logger'   => $container['logger'],
                'acl'      => $container['admin/acl'],
                'resource' => 'admin'
            ]);
        };

        /**
         * For 'charcoal-ui'
         *
         * @todo   Do this right!
         * @param  Container $container The Pimple DI Container.
         * @return Authorizer
         */
        $container['authorizer'] = function (Container $container) {
            return $container['admin/authorizer'];
        };
    }
487527
public function register(Container $container)
    {
        /** @var string The default route controller for templates. */
        $container['route/controller/script/class'] = ScriptRoute::class;

        $this->registerScriptFactory($container);
        $this->registerClimate($container);
    }
531612
public function register(Container $container)
    {
        $closure = function (Container $container) {
            $tz = $container->get('config')->get('system.timezone', 'UTC');

            return new Chronos('now', new \DateTimeZone($tz));
        };

        $container->set(Chronos::class, $closure);
    }
167123
protected function registerFormats(Container $container)
    {
        foreach ($this->formats as $formatClass) {
            $container['format.'.$formatClass::getName()] = $container->factory(function() use ($formatClass) {
                return new $formatClass();
            });
        }
    }
1066607
public function register(Container $container)
    {
        /**
         * @param  Container $container A container instance.
         * @return LoggerConfig
         */
        $container['logger/config'] = function (Container $container) {
            $appConfig    = isset($container['config']) ? $container['config'] : [];
            $loggerConfig = isset($appConfig['logger']) ? $appConfig['logger'] : null;
            return new LoggerConfig($loggerConfig);
        };

        /**
         * @return FactoryInterface
         */
        $container['logger/processor/factory'] = function () {
            return new Factory([
                'map' => [
                    'memory-usage' => MemoryUsageProcessor::class,
                    'uid'          => UidProcessor::class
                ]
            ]);
        };

        /**
         * @param  Container $container A container instance.
         * @return StreamHandler|null
         */
        $container['logger/handler/stream'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.stream'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new StreamHandler($handlerConfig['stream'], $level);
        };

        /**
         * @param  Container $container A container instance.
         * @return BrowserConsoleHandler|null
         */
        $container['logger/handler/browser-console'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.console'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new BrowserConsoleHandler($level);
        };

        /**
         * @param  Container $container A container instance.
         * @return Container Collection of defined record handlers, in a service container.
         */
        $container['logger/handlers'] = function (Container $container) {
            $loggerConfig   = $container['logger/config'];
            $handlersConfig = $loggerConfig['handlers'];
            $handlerFactory = $container['logger/handler/factory'];

            $handlers = new Container();
            foreach ($handlersConfig as $handler) {
                $handlers[$handler['type']] = function () use ($handler, $handlerFactory) {
                    $type    = $handler['type'];
                    $handler = $handlerFactory->create($type);
                    return $handler;
                };
            }

            return $handlers;
        };

        /**
         * Fulfills the PSR-3 dependency with a Monolog logger.
         *
         * @param  Container $container A container instance.
         * @return LoggerInterface
         */
        $container['logger'] = function (Container $container) {
            $loggerConfig = $container['logger/config'];

            if ($loggerConfig['active'] !== true) {
                return new NullLogger();
            }

            $logger = new Logger($loggerConfig['channel']);

            $memProcessor = new MemoryUsageProcessor();
            $logger->pushProcessor($memProcessor);

            $uidProcessor = new UidProcessor();
            $logger->pushProcessor($uidProcessor);

            $consoleHandler = $container['logger/handler/browser-console'];
            if ($consoleHandler) {
                $logger->pushHandler($consoleHandler);
            }

            $streamHandler = $container['logger/handler/stream'];
            if ($streamHandler) {
                $logger->pushHandler($streamHandler);
            }

            return $logger;
        };
    }
141650
public function register(Container $pimple)
    {
        array_walk($this->filterArray, function ($filter, $key) use (&$pimple) {
            $pimple[$key] = function ($pimple) use ($filter,$key) {
                return new API($pimple['signature'], $key, $filter);
            };
        });
    }
71584
public function boot(Container $container)
    {
        $config = $container->get('config');

        if (!$config->get('system.debug')) {
            return;
        }

        $error = $container->get('error.handler');

        /**
         * @param \Exception|\Throwable $e
         *
         * @return  void
         */
        $handler = function ($e) use ($container) {
            /** @var Whoops $whoops */
            $whoops = $container->get('whoops');
            $whoops->allowQuit(false);
            $whoops->handleException($e);
        };

        $error->addHandler($handler, 'default');
    }
171023
public function register(Container $pimple)
    {
        $pimple["$this->prefix.config"] = $this->defineDefaultConfig();
        $pimple["$this->prefix.command_bus"] = $this->setUpCommandBus($pimple);
        $pimple["$this->prefix.event_bus"] = $this->setUpEventBus();
        $pimple["$this->prefix.event_store"] = $this->setUpEventStore($pimple);
        $pimple["$this->prefix.snapshot_store"] = $this->setUpSnapshotStore($pimple);
        $pimple["$this->prefix.snapshotter"] = $this->setUpSnapshotter($pimple);
        $pimple["$this->prefix.repository.aggregate"] = $this->setUpAggregateRepository();
        $pimple["$this->prefix.serializer"] = $this->setUpSerializer($pimple);
    }
365965
public function register(Container $pimple)
    {
        $pimple = $this->setupDefaultOptions($pimple);
        $pimple = $this->registerAlias($pimple);

        $pimple['http_client.builder'] = function() use ($pimple) {
            return $this->getBuilder($pimple);
        };

        $pimple['http_client.client'] = function() use ($pimple) {
            return $pimple['http_client.builder']->build();
        };
    }
690980
public function register(Container $container)
    {
        $this->registerViewConfig($container);
        $this->registerLoaderServices($container);
        $this->registerEngineServices($container);
        $this->registerMustacheTemplatingServices($container);
        $this->registerTwigTemplatingServices($container);
        $this->registerViewServices($container);
    }
397733
public function register(Container $container)
    {
        if (!isset($container->get('settings')['view'])) {
            throw new InvalidArgumentException('Template configuration not found');
        }

        $engine = new Plates(
            $container->get('settings')['view'],
            $container->get('response')
        );

        $engine->loadExtension(
            new PlatesExtension(
                $container->get('router'),
                $container->get('request')->getUri()
            )
        );

        $container['view'] = $engine;
    }
973301
protected function registerContextOptions(Container $container)
    {
        $defaultOptions = stream_context_get_options(stream_context_get_default());
        stream_context_set_default(array_merge(
            $defaultOptions,
            array($this->scheme => array('Container' => $container))
        ));
    }
415323
public function register(Container $container)
    {
        $container->prepareSharedObject(DatabaseService::class);

        $closure = function (Container $container) {
            $service = $container->get(DatabaseService::class);

            return $service->createConnection();
        };

        class_alias(AbstractDatabaseDriver::class, DatabaseAdapter::class);
        $container->share(AbstractDatabaseDriver::class, $closure)
            ->alias(DatabaseAdapter::class, AbstractDatabaseDriver::class);

        DatabaseContainer::setDb(function () use ($container) {
            return $container->get(AbstractDatabaseDriver::class);
        });

        // For Exporter
        $closure = function (Container $container) {
            $service = $container->get(DatabaseService::class);

            return $service->getExporter();
        };

        $container->share(AbstractExporter::class, $closure);
    }
773081
public function register(Container $pimple)
    {
        $pimple['logger'] = $pimple['log'] = function ($app) {
            $config = $this->formatLogConfig($app);

            if (!empty($config)) {
                $app->rebind('config', $app['config']->merge($config));
            }

            return new LogManager($app);
        };
    }
58832
public function authorisation(Container $container)
    {
        $auth   = new Authorisation();
        $config = $container->get('config');

        foreach ((array) $config->get('user.policies') as $name => $policy) {
            if ($policy instanceof ClassMeta || (is_string($policy) && class_exists($policy))) {
                $instance = $container->newInstance($policy);

                if (is_subclass_of($instance, PolicyInterface::class)) {
                    $auth->addPolicy($name, $instance);
                } elseif (is_subclass_of($instance, PolicyProviderInterface::class)) {
                    $auth->registerPolicyProvider($instance);
                }
            } elseif ($policy === false) {
                continue;
            } else {
                throw new \InvalidArgumentException(sprintf(
                    'Please register instance of %s or %s',
                    PolicyInterface::class,
                    PolicyProviderInterface::class
                ));
            }
        }

        /** @var EventDispatcher $dispatcher */
        $this->dispatcher->triggerEvent('onLoadAuthorisationPolicies', ['auth' => $auth]);

        return $auth;
    }
1279698
public function register(Container $container)
    {
        /** @var Config $configuration */
        $configuration = $container['config'];

        /** @var LoggerInterface $logger */
        $logger = $container['logger'];

        /** @var Client $http */
        $http = $container['http'];

        /** @var TierConfiguration $tierConfiguration */
        $tierConfiguration = $container['tierConfiguration'];

        /** @var Fulfillment $fulfillment */
        $fulfillment = $container['fulfillment'];

        return new Usage($configuration, $logger, $http, $tierConfiguration, $fulfillment);
    }
596755
public function register(Container $container)
    {
        $container["tplLoader.service"] = function (Container $container) {
            $loader = new \SlaxWeb\View\Loader\PHP($container["response.service"], $container["logger.service"]());
            return $loader->setTemplateExt($container["config.service"]["view.templateExtension"]);
        };
    }