Polyglot\PolyglotServiceProvider::register PHP Метод

register() публичный Метод

Register the service provider.
public register ( ) : void
Результат void
    public function register()
    {
        $this->app['config']->package('anahkiasen/polyglot', __DIR__ . '/config');
        // Bind services
        $this->app->singleton('polyglot.translator', 'Polyglot\\Services\\Lang');
        $this->app->singleton('polyglot.router', function ($app) {
            return new Router($app['events'], $app);
        });
        $this->app->singleton('polyglot.url', function ($app) {
            $routes = $app['polyglot.router']->getRoutes();
            return new UrlGenerator($routes, $app->rebinding('request', function ($app, $request) {
                $app['url']->setRequest($request);
            }));
        });
        // Bind extractors and compilers
        $this->app->bind('polyglot.compiler', 'Polyglot\\Localization\\Services\\Compiler');
        $this->app->bind('polyglot.extractor', 'Polyglot\\Localization\\Services\\Extractor');
        $this->app->bind('polyglot.extract', 'Polyglot\\Localization\\Commands\\ExtractTranslations');
        $this->app->bind('polyglot.compile', 'Polyglot\\Localization\\Commands\\CompileTranslations');
        $this->commands(['polyglot.extract', 'polyglot.compile']);
    }

Usage Example

Пример #1
0
 /**
  * Set up the tests
  */
 public function setUp()
 {
     parent::setUp();
     // Bind Polyglot classes
     $provider = new PolyglotServiceProvider($this->app);
     $provider->register();
     $provider->boot();
     $this->app['translator'] = $this->app['polyglot.translator'];
     // Configure facades
     Config::setFacadeApplication($this->app);
 }
PolyglotServiceProvider