/** * @param string $lang */ public function bindProductPresenter($lang) { if ($lang == 'zh-tw') { $this->app->bind(MoneyFormatInterface::class, ProductPresenterZHTW::class); } elseif ($lang == 'zh-cn') { $this->app->bind(MoneyFormatInterface::class, ProductPresenterZHCN::class); } else { $this->app->bind(MoneyFormatInterface::class, ProductPresenterDefault::class); } }
/** * Register the user verification. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerUserVerification(Application $app) { $app->bind('user.verification', function ($app) { return new UserVerification(app()->make('mailer'), app()->make('db')->connection()->getSchemaBuilder()); }); $app->alias('user.verification', UserVerification::class); }
/** * Bootstrap the given application. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function bootstrap(Application $app) { $logger = new Writer(new Monolog($app->environment()), $app['events']); // Daily files are better for production stuff $logger->useDailyFiles(storage_path('/logs/laravel.log')); $app->instance('log', $logger); // Next we will bind the a Closure to resolve 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(); }); $app->bind('Illuminate\\Contracts\\Logging\\Log', function ($app) { return $app['log']; }); }
/** * Initializes all the commands default */ protected function getDefaultCommands() { $commands = parent::getDefaultCommands(); $commands[] = new Command\AboutCommand($this->app); $commands[] = new Command\StopCommand($this->app); // Comandos da aplicacao $cmds = config('app.commands', []); foreach ($cmds as $cid => $cClass) { $cid = sprintf('command.%s', $cid); $this->app->bind($cid, $cClass); $commands[] = $this->app[$cid]; } // verificar se deve incluir o comando make:command if ('phar:' !== substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\MakeCommand')) { $commands[] = new \Consolle\Command\MakeCommand($this->app); } // verificar se deve incluir o comando optimize if ('phar:' !== substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\OptimizeCommand')) { $commands[] = new \Consolle\Command\OptimizeCommand($this->app); } // verificar se deve incluir o comando self-compiler if ('phar:' !== substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\SelfCompilerCommand')) { $commands[] = new \Consolle\Command\SelfCompilerCommand($this->app); } // Verificar se deve incluir o comando self-update if ('phar:' === substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\SelfCompilerCommand') && file_exists(base_path('update.json'))) { $commands[] = new \Consolle\Command\SelfUpdateCommand($this->app); } return $commands; }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('cachet.connection', function ($app) { $manager = $app['cachet']; return $manager->connection(); }); $app->alias('cachet.connection', CachetConnection::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('telegram.bot', function ($app) { $manager = $app['telegram']; return $manager->bot(); }); $app->alias('telegram.bot', Api::class); }
/** * Binds all interfaces to the IOC container */ protected function setupBinds() { /* * Tenant repository */ $this->app->bind('HynMe\\MultiTenant\\Contracts\\TenantRepositoryContract', function () { return new TenantRepository(new Tenant()); }); /* * Tenant hostname repository */ $this->app->bind('HynMe\\MultiTenant\\Contracts\\HostnameRepositoryContract', function () { return new HostnameRepository(new Hostname()); }); /* * Tenant website repository */ $this->app->bind('HynMe\\MultiTenant\\Contracts\\WebsiteRepositoryContract', function ($app) { return new WebsiteRepository(new Website(), $this->app->make('HynMe\\MultiTenant\\Contracts\\HostnameRepositoryContract')); }); }
protected function runMigrations() { $this->application->bind('Illuminate\\Database\\Schema\\Builder', function ($container) { return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder(); }); $migrator = $this->application->make('Flarum\\Database\\Migrator'); $migrator->getRepository()->createRepository(); $migrator->run(__DIR__ . '/../../../migrations'); foreach ($migrator->getNotes() as $note) { $this->info($note); } }
/** * Registers the server in the container. * * @return \Illuminate\Foundation\Application * @throws \Exception */ public function register() { // Auto register the support service provider if (!get_class($this) == SupportServiceProvider::class) { $this->app->register(SupportServiceProvider::class); } $this->viewsPath = Str::replace($this->viewsPath, '{resourcesPath}', $this->getResourcesPath()); $this->assetsPath = Str::replace($this->assetsPath, '{resourcesPath}', $this->getResourcesPath()); $router = $this->app->make('router'); $kernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel'); $this->registerConfigFiles(); foreach ($this->prependMiddleware as $middleware) { $kernel->prependMiddleware($middleware); } foreach ($this->middleware as $middleware) { $kernel->pushMiddleware($middleware); } foreach ($this->routeMiddleware as $key => $middleware) { $router->middleware($key, $middleware); } foreach ($this->providers as $provider) { $this->app->register($provider); } foreach ($this->deferredProviders as $provider) { $this->app->registerDeferredProvider($provider); } foreach ($this->bindings as $binding => $class) { $this->app->bind($binding, $class); } foreach ($this->singletons as $binding => $class) { if ($this->strict && !class_exists($class) && !interface_exists($class)) { throw new \Exception(get_called_class() . ": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled"); } $this->app->singleton($binding, $class); } foreach ($this->aliases as $alias => $full) { if ($this->strict && !class_exists($full) && !interface_exists($full)) { throw new \Exception(get_called_class() . ": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled"); } $this->app->alias($alias, $full); } if (is_array($this->commands) and count($this->commands) > 0) { $this->commands($this->commands); } AliasLoader::getInstance($this->facades)->register(); $this->requireHelpersFor('register'); return $this->app; }
/** * Mocks components that should not be part of any core test. * * @param Application $app * @return $this */ protected function mockBoundCoreExternalComponents(Application $app) { $app->bind('mock-cms-auth', function () { $mock = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $mock->method('version')->willReturn('1.2.3'); $mock->method('getRouteLoginAction')->willReturn('MockController@index'); $mock->method('getRouteLoginPostAction')->willReturn('MockController@index'); $mock->method('getRouteLogoutAction')->willReturn('MockController@index'); $mock->method('getRoutePasswordEmailGetAction')->willReturn('MockController@index'); $mock->method('getRoutePasswordEmailPostAction')->willReturn('MockController@index'); $mock->method('getRoutePasswordResetGetAction')->willReturn('MockController@index'); $mock->method('getRoutePasswordResetPostAction')->willReturn('MockController@index'); return $mock; }); return $this; }
/** * Handle the command. * * @param Application $application */ public function handle(Application $application, Laravel $laravel) { $app = env('APPLICATION_REFERENCE', 'default'); if (PHP_SAPI == 'cli') { $app = (new ArgvInput())->getParameterOption('--app', $app); $laravel->bind('path.public', function () use($laravel) { if ($path = env('PUBLIC_PATH')) { return base_path($path); } // Check default path. if (file_exists($path = base_path('public/index.php'))) { return dirname($path); } // Check common alternative. if (file_exists($path = base_path('public_html/index.php'))) { return dirname($path); } return base_path('public'); }); } /* * Set the reference to our default first. * When in a dev environment and working * with Artisan this the same as locating. */ $application->setReference($app); /* * If the application is installed * then locate the application and * initialize. */ if ($application->isInstalled()) { if (env('DB_CONNECTION', env('DB_DRIVER'))) { $application->locate(); $application->setup(); } return; } /* * If we're not installed just * assume default for now. */ $application->setReference('default'); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('pusher.connection', function ($app) { $manager = $app['pusher']; return $manager->connection(); }); $app->alias('pusher.connection', Pusher::class); }
/** * Bind addon classes. * * @param AddonServiceProvider $provider */ protected function bindClasses(AddonServiceProvider $provider) { foreach ($provider->getBindings() as $abstract => $concrete) { $this->application->bind($abstract, $concrete); } }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('mailchimp.connection', function ($app) { $manager = $app['mailchimp']; return $manager->connection(); }); $app->alias('mailchimp.connection', Mailchimp::class); }
/** * Bind the interfaces to their implementations. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ public function registerInterfaceBindings(Application $app) { $app->bind(ClientInterface::class, FluentClient::class); $app->bind(ScopeInterface::class, FluentScope::class); $app->bind(SessionInterface::class, FluentSession::class); $app->bind(AuthCodeInterface::class, FluentAuthCode::class); $app->bind(AccessTokenInterface::class, FluentAccessToken::class); $app->bind(RefreshTokenInterface::class, FluentRefreshToken::class); }
/** * Register the github document repository class. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ protected function registerGithubDocumentRepository(Application $app) { $app->bind('blogit.github.repository.document', function ($app) { $client = $app['blogit.github.client']; return new DocumentRepository($client); }); $app->alias('blogit.github.repository.document', DocumentRepositoryInterface::class); }
/** * @param \Illuminate\Contracts\Foundation\Application $app */ private function registerBindings($app) { $app->bind('google-client.connection', function ($app) { $manager = $app['google-client']; return $manager->connection(); }); $app->alias('google-client.connection', Google_Client::class); }
/** * Registers the Swap service. * * @param Application $app */ private function registerSwap(Application $app) { $app->singleton('swap', function ($app) { return new Swap($app['swap.provider'], $app['swap.cache']); }); $app->bind('Swap\\Swap', 'swap'); $app->bind('Swap\\SwapInterface', 'swap'); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('googleq.connection', function ($app) { $manager = $app['googleq']; return $manager->connection(); }); $app->alias('googleq.connection', GoogleQ::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('instagram.connection', function ($app) { $manager = $app['instagram']; return $manager->connection(); }); $app->alias('instagram.connection', Instagram::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('bitbucket.connection', function ($app) { $manager = $app['bitbucket']; return $manager->connection(); }); $app->alias('bitbucket.connection', Api::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('twitterq.connection', function ($app) { $manager = $app['twitterq']; return $manager->connection(); }); $app->alias('twitterq.connection', TwitterQ::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('vimeo.connection', function ($app) { $manager = $app['vimeo']; return $manager->connection(); }); $app->alias('vimeo.connection', Vimeo::class); }
/** * Set the correct repository binding on the fly for the current request * * @param $driver */ protected function bindUserRepositoryOnTheFly($driver) { $this->application->bind('Modules\\User\\Repositories\\UserRepository', "Modules\\User\\Repositories\\{$driver}\\{$driver}UserRepository"); $this->application->bind('Modules\\User\\Repositories\\RoleRepository', "Modules\\User\\Repositories\\{$driver}\\{$driver}RoleRepository"); $this->application->bind('Modules\\Core\\Contracts\\Authentication', "Modules\\User\\Repositories\\{$driver}\\{$driver}Authentication"); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('transip.connection', function ($app) { $manager = $app['transip']; return $manager->connection(); }); $app->alias('transip.connection', Client::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('hashids.connection', function ($app) { $manager = $app['hashids']; return $manager->connection(); }); $app->alias('hashids.connection', Hashids::class); }
/** * Registers Swap. * * @param Application $app */ private function registerSwap(Application $app) { $app->singleton('swap', function ($app) { return new Swap($app['swap.exchange_rate_provider']); }); $app->bind('Swap\\Swap', 'swap'); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('flysystem.connection', function ($app) { $manager = $app['flysystem']; return $manager->connection(); }); $app->alias('flysystem.connection', Filesystem::class); $app->alias('flysystem.connection', FilesystemInterface::class); }
/** * Register the bindings. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBindings(Application $app) { $app->bind('digitalocean.connection', function ($app) { $manager = $app['digitalocean']; return $manager->connection(); }); $app->alias('digitalocean.connection', DigitalOceanV2::class); }
/** * @param Application $app */ protected function registerEventStore(Application $app) { if ($app['config']->get('cqrses.laravel_eventstore_enabled')) { $app->bind(EventStore::class, function (Application $application) { return new LaravelEventStore($application->make(DatabaseManager::class), $application->make(Serializer::class), $application['config']->get('cqrses.eventstore_connection'), $application['config']->get('cqrses.eventstore_table')); }); } }