Register Logger Service Provider

Method used by the DIC to register a new service provider. This Service
Provider defines only the Logger service.

@param \Pimple\Container $app Pimple Dependency Injection Container
@return void
777610
public function register(App $app)
    {
        $app["logger.service"] = $app->protect(
            function (string $loggerName = "") use ($app) {
                $cacheName = "logger.service-{$loggerName}";
                if (isset($app[$cacheName])) {
                    return $app[$cacheName];
                }
                /*
                 * Check the config service has been defined and provides correct
                 * object
                 */
                if (isset($app["config.service"]) === false
                    || get_class($app["config.service"]) !== "SlaxWeb\\Config\\Container") {
                    throw new \SlaxWeb\Bootstrap\Exception\LoggerConfigException(
                        "Config component provider must be registered before you can use the Logger component."
                    );
                }

                $config = $app["config.service"];
                if ($loggerName === "") {
                    $loggerName = $config["logger.defaultLogger"];
                }

                $logger = new MLogger($loggerName);
                foreach ($config["logger.loggerSettings"][$loggerName] as $type => $settings) {
                    // load propper handler and instantiate the Monolog\Logger
                    $handler = null;
                    switch ($type) {
                        case Helper::L_TYPE_FILE:
                            $app["temp.logger.settings"] = $settings;
                            $handler = $app["logger.{$type}.service"];
                            unset($app["temp.logger.settings"]);
                            break;
                        default:
                            throw new \SlaxWeb\Bootstrap\Exception\UnknownLoggerHandlerException(
                                "The handler you are tring to use is not known or not supported."
                            );
                    }
                    $logger->pushHandler($handler);
                }

                return $app[$cacheName] = $logger;
            }
        );

        $app["logger.StreamHandler.service"] = $app->factory(
            function (App $cont) {
                $settings = $cont["temp.logger.settings"];

                // if the log file name does not begin with a dir separator, treat
                // it as relative path and prepend 'logFilePath'
                if ($settings[0][0] !== DIRECTORY_SEPARATOR) {
                    $settings[0] = ($cont["config.service"]["logger.logFilePath"] ?? "")
                        . $settings[0];
                }
                return new \Monolog\Handler\StreamHandler(...$settings);
            }
        );
    }
342547
public function bootstrap(Container $app)
    {
        foreach ($app->make('config')->get('app.providers') as $provider) {
            $app->register(new $provider($app));
        }
        
        foreach ($app->make('config')->get('app.theme.providers', []) as $provider) {
            $app->register(new $provider($app));
        }
    }
1291242
public function register(Application $app)
    {
        $app["loadController.service"] = $app->protect(
            function (string $name) use ($app) {
                $args = func_get_args();
                $cacheName = "loadController.service-{$name}";
                if (isset($app[$cacheName])) {
                    return $app[$cacheName];
                }

                $config = $app["config.service"];
                $class = rtrim($config["app.controllerNamespace"], "\\")
                    . "\\"
                    . str_replace("/", "\\", $name);
                $app[$cacheName] = new $class($app);

                if (method_exists($app[$cacheName], "init")) {
                    array_shift($args);
                    $app[$cacheName]->init(...$args);
                }

                return $app[$cacheName];
            }
        );
    }
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);
    }
677157
public function register(Container $app)
    {
        $app['console.name'] = 'Silex console';
        $app['console.version'] = 'UNKNOWN';
        // Assume we are in vendor/knplabs/console-service-provider/Knp/Provider
        $app['console.project_directory'] = __DIR__.'/../../../../..';
        $app['console.class'] = ConsoleApplication::class;
        // List of command service ids indexed by command name (i.e: array('my:command' => 'my.command.service.id'))
        $app['console.command.ids'] = [];

        // Maintain BC with projects that depend on the old behavior (application gets booted from console constructor)
        $app['console.boot_in_constructor'] = false;

        $app['console'] = function () use ($app) {
            /** @var ConsoleApplication $console */
            $console = new $app['console.class'](
                $app,
                $app['console.project_directory'],
                $app['console.name'],
                $app['console.version']
            );
            $console->setDispatcher($app['dispatcher']);

            foreach ($app['console.command.ids'] as $id) {
                $console->add($app[$id]);
            }

            if ($app['dispatcher']->hasListeners(ConsoleEvents::INIT)) {
                @trigger_error('Listening to the Knp\Console\ConsoleEvents::INIT event is deprecated and will be removed in v3 of the service provider. You should extend the console service instead.', E_USER_DEPRECATED);

                $app['dispatcher']->dispatch(ConsoleEvents::INIT, new ConsoleEvent($console));
            }

            return $console;
        };

        $commands = [];

        if (isset($app['twig']) && class_exists(TwigBridgeDebugCommand::class)) {
            $app['console.command.twig.debug'] = function (Container $container) {
                return new DebugCommand($container);
            };

            $app['console.command.twig.lint'] = function (Container $container) {
                return new LintCommand($container);
            };

            $commands['debug:twig'] = 'console.command.twig.debug';
            $commands['lint:twig'] = 'console.command.twig.lint';
        }

        if (class_exists(LintYamlCommand::class)) {
            $app['console.command.yaml.lint'] = function () {
                return new LintYamlCommand();
            };
            $commands['lint:yaml'] = 'console.command.yaml.lint';
        }

        $app['console.command.ids'] = $commands;
    }
449935
public function bootstrap(Application $app)
	{
		$this->configureHandlers($app, $this->registerLogger($app));

		// Next, we will bind a Closure that resolves the PSR logger implementation
		// as this will grant us the ability to be interoperable with many other
		// libraries which are able to utilize the PSR standardized interface.
		$app->bind('Psr\Log\LoggerInterface', function($app)
		{
			return $app['log']->getMonolog();
		});
	}
1024064
public function register(Application $app)
    {
        $app['social-login.controller'] = $app->share(function ($app) {
            $config = $app['config']->load('social-login');

            $controller = new SocialLoginController;
            $controller
                ->setSocialLoginService($app['social-login.service'])
                ->setConfig($config)
                ->setServiceFactory(new ServiceFactory())
                ->setSession($app['session']);

            return $controller;
        });

        $app['social-login.mapper'] = $app->share(function ($app) {
            return new SocialLoginMapper($app['db'], new SocialLoginEntity);
        });

        $app['social-login.service'] = $app->share(function ($app) {
            $service = new SocialLoginService;
            $service->setUserService($app['user.service'])
                ->setSocialLoginMapper($app['social-login.mapper'])
                ->setOAuthStorage($app['oauth.storage']);

            return $service;
        });

        $app->get('/social-login/{provider}', 'social-login.controller:login')
            ->bind('social-login-auth');

        $app->get('/social-login/{provider}/link', 'social-login.controller:link')
            ->bind('social-link-auth');

        $app->get('/social-login/{provider}/callback', 'social-login.controller:callback')
            ->bind('social-login-callback');

        $this->setFirewalls($app);
    }
1072462
public function register(App $app)
    {
        if (isset($app["guzzle.service"]) === false) {
            $app["guzzleClient.service"] = function() {
                return new \GuzzleHttp\Client;
            };
        }

        /*
         * This is only a temporary service definition to satisfy the install component
         * command and to load the service provider into it through the new params
         * as services method.
         *
         * @todo: remove when the component commands are refactored
         */
        $app["serviceProvider.service"] = function(App $app) {
            return $app;
        };

        $app["slaxerCommands"] = array_merge(
            $app["slaxerCommands"] ?? [],
            [
                \SlaxWeb\Bootstrap\Commands\Component\InstallCommand::class => [
                    "serviceProvider.service",
                    "guzzleClient.service"
                ]
            ]
        );
    }
21844
public function register(Container $app)
    {
        $app["cache.service"] = function(Container $app) {
            $handlerClass = ucfirst($app["config.service"]["cache.handler"]);

            return new \SlaxWeb\Cache\Manager(
                $app["cache{$handlerClass}Handler.service"]
            );
        };

        $app["cacheFileHandler.service"] = function(Container $app) {
            return new \SlaxWeb\Cache\Handler\File(
                $app["config.service"]["cache.location"],
                $app["config.service"]["cache.maxAge"]
            );
        };
    }
1190183
public static function registerServices(Application $app)
    {
        $file = $app['wise.options']['config']['services'];

        if ('prod' !== $app['wise.options']['mode']) {
            $file .= '_' . $app['wise.options']['mode'];
        }

        $file .= '.' . $app['wise.options']['type'];

        /** @var $wise Wise */
        $wise = $app['wise'];
        $services = $wise->load($file);

        unset($services['parameters']);
        unset($services['imports']);

        foreach ($services as $name => $service) {
            if (null === $service) {
                continue;
            }

            if (!isset($service['class'])) {
                throw InvalidArgumentException::format(
                    'The service "%s" did not specify its "class".',
                    $name
                );
            }

            if (!isset($service['parameters'])) {
                $service['parameters'] = array();
            }

            $app->register(new $service['class'](), $service['parameters']);
        }
    }
284762
public function register(Application $app)
    {
        parent::register($app);

        $app->register(
            new \Silex\Provider\DoctrineServiceProvider(),
            ['db.options' => $app['config']['db.options']]
        );
        $app->register(
            new DoctrineOrmServiceProvider(),
            $app['config']['orm.options']
        );

        if (getenv('MIGRATION_COMMANDS')) {
            $app->register(new MigrationServiceProvider(), [
                'db.migrations.path' =>$app['config']['migrations.directory'],
            ]);
        }

        $app['orm.em'] = $app->extend('orm.em', function(EntityManagerInterface $em) use($app) {
            if (file_exists(APP_PATH.'/vendor/apitude/apitude/src/Annotations/APIAnnotations.php')) {
                AnnotationRegistry::registerFile(APP_PATH.'/vendor/apitude/apitude/src/Annotations/APIAnnotations.php');
            }
            /** @var Configuration $config */
            $config = $em->getConfiguration();
            $config->setMetadataCacheImpl($app['cache']);
            $config->addCustomHydrationMode('simple', SimpleHydrator::class);

            /** @var MappingDriverChain $driver */
            $driver = $config->getMetadataDriverImpl();

            // gedmo initialization
            $reader = new AnnotationReader();
            $cache = new CachedReader($reader, $app['cache']);
            DoctrineExtensions::registerAbstractMappingIntoDriverChainORM(
                $driver,
                $cache
            );

            return $em;
        });
    }
325895
protected function registerAutoloader($app)
    {
        // now configure a new autoloader spl configuration
        $autoloaderApp = new Doozr_Loader_Autoloader_Spl_Config();
        $autoloaderApp
            ->_namespace($app->namespace)
            ->namespaceSeparator('_')
            ->addExtension('php')
            ->path(substr($app->path, 0, -1))
            ->description('Autoloader for App classes with namespace: "'.$app->namespace.'"')
            ->priority(0);

        Doozr_Loader_Autoloader_Spl_Facade::attach([$autoloaderApp]);
    }
434727
public function register(Container $app)
    {
        $app['singular.packs'] = function () use ($app) {
            return new Container();
        };

        $app['singular.service_map'] = function () use ($app) {
            return new Container();
        };

        $app['singular.config_loader'] = function () use ($app) {
            return new ConfigLoader($app);
        };

        $app['singular.service_locator'] = function () use ($app) {
            return new ServiceLocator(
                $app['singular.packs'],
                $app['singular.service_map'],
                $app['singular.resolver']
            );
        };

        $app['singular.service_resolver'] = function () use ($app) {
            return new ServiceResolver($app);
        };

        $app['singular.resolver'] = function () use ($app) {
            return new Resolver(
                $app['singular.controller_resolver'],
                $app['singular.service_resolver']
            );
        };

        $app['singular.controller_locator'] = function () use ($app) {
            return new ControllerLocator(
                $app['singular.resolver'],
                $app['singular.packs'],
                $app['singular.service_map']
            );
        };

        $app['singular.controller_resolver'] = function () use ($app) {
            return new ControllerResolver($app);
        };
    }
547533
protected function injectServices(Container $app)
    {
        if (isset($app['profiler'])) {
            $app['geocoder.logger'] = function($app) {
                return new \Geocoder\Logger\GeocoderLogger();
            };

            $app['geocoder'] = function($app) {
                $geocoder = new \Geocoder\LoggableGeocoder();
                $geocoder->setLogger($app['geocoder.logger']);
                $geocoder->registerProvider($app['geocoder.provider']);

                return $geocoder;
            };
        } else {
            $app['geocoder'] = function($app) {
                $geocoder = new \Geocoder\Geocoder();
                $geocoder->registerProvider($app['geocoder.provider']);

                return $geocoder;
            };
        }

        $app['geocoder.provider'] = function($app) {
            return new \Geocoder\Provider\FreeGeoIpProvider($app['geocoder.adapter']);
        };

        $app['geocoder.adapter'] = function($app) {
            return new \Geocoder\HttpAdapter\CurlHttpAdapter();
        };
    }
302627
public function register(Container $app)
    {
        // old session
        $app[Session::class] = $app->make(Session::class);

        // old config
        $app[Config::class] = $app->one(Config::class);

        // old text system
        $app[Text::class] = $app->once(function (Config $config) use ($app) {
            $args = [];
            if ($config->configExists('main', 'language_text')) {
                $args[] = $config->config('language_text');
            }
            return $app->make(Text::class, $args);
        });

        // Old database system
        $app[Database::class] = $app->one(Database::class);

        // Default style renderer
        $app[RendererInterface::class] = $app->one(Page::class);

        // Global Data
        $app[GlobalData::class] = new GlobalData($app);
    }
1212872
private function registerComponents($app)
    {
        foreach ($this->getModules() as $id => $module) {
            // set an alias for all user modules
            Yii::setAlias('@'.$id, $module->getBasePath());
            // see if the module has a registerComponents method
            foreach ($module->registerComponents() as $componentId => $definition) {
                if (!$app->has($componentId)) {
                    Yii::trace('Register component ' . $componentId, __METHOD__);
                    $app->set($componentId, $definition);
                }
            }
        }
    }
786492
public function register(Container $pimple)
    {
        $pimple['signature'] = function (Foundation $pimple) {
            return new Signature($pimple->getConfig('appKey'), $pimple->getConfig('appSecret'));
        };
    }