/** * @param string $namespace * @param $responsibleHandler */ public function registerNamespace($namespace, $responsibleHandler) { $this->namespaces[$namespace] = $responsibleHandler; $this->application->singleton("{$this->iocRegistry}.{$namespace}", function () use($responsibleHandler) { return new $responsibleHandler($this->application); }); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { try { if ($this->validator->validateRequest($request)) { $this->app->singleton('Illuminate\\Contracts\\Debug\\ExceptionHandler', function ($app) { return $app['Dingo\\Api\\Exception\\Handler']; }); $request = $this->app->make('Dingo\\Api\\Contract\\Http\\Request')->createFromIlluminate($request); return $this->sendRequestThroughRouter($request); } } catch (Exception $exception) { return $this->exception->handle($exception); } return $next($request); }
/** * Bootstrap the translator. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function bootstrap(Application $app) { $app->singleton('translation.loader', function ($app) { return new FileLoader($app['files'], $app['path.lang']); }); $app->singleton('translator', function ($app) { $loader = $app['translation.loader']; // When registering the translator component, we'll need to set the default // locale as well as the fallback locale. So, we'll grab the application // configuration so we can easily get both of these values from there. $locale = $app['config']['app.locale']; $trans = new Translator($loader, $locale); $trans->setFallback($app['config']['app.fallback_locale']); return $trans; }); }
/** * Register the git client class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerGitlib(Application $app) { $app->singleton('gitlib', function ($app) { return new BaseClient(null); }); $app->alias('gitlib', BaseClient::class); }
/** * Specific features for OctoberCMS. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function bootstrap(Application $app) { /* * Register singletons */ $app->singleton('string', function () { return new \October\Rain\Support\Str(); }); /* * Change paths based on config */ if ($pluginsPath = $app['config']->get('cms.pluginsPathLocal')) { $app->setPluginsPath($pluginsPath); } if ($themesPath = $app['config']->get('cms.themesPathLocal')) { $app->setThemesPath($themesPath); } /* * Set execution context */ $requestPath = $this->normalizeUrl($app['request']->path()); $backendUri = $this->normalizeUrl($app['config']->get('cms.backendUri', 'backend')); if (starts_with($requestPath, $backendUri)) { $app->setExecutionContext('back-end'); } else { $app->setExecutionContext('front-end'); } }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('cachet', function ($app) { $config = $app['config']; return new CachetManager($config); }); $app->alias('cachet', CachetManager::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('telegram', function ($app) { $config = $app['config']; return new BotsManager($config, $app); }); $app->alias('telegram', BotsManager::class); }
/** * Register the helper class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerApiHelper(Application $app) { $app->singleton('apihelper', function ($app) { $request = $app['request']; $config = $app['config']; return new Factory($request, $config); }); }
/** * Register the security class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerSecurity(Application $app) { $app->singleton('security', function ($app) { $evil = $app->config->get('security.evil'); return new Security($evil); }); $app->alias('security', Security::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('cloudflareapi', function ($app) { $config = $app['config']; $factory = $app['cloudflareapi.factory']; return new CloudFlareAPIManager($config, $factory); }); $app->alias('cloudflareapi', 'GrahamCampbell\\CloudFlareAPI\\CloudFlareAPIManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('pusher', function ($app) { $config = $app['config']; $factory = $app['pusher.factory']; return new PusherManager($config, $factory); }); $app->alias('pusher', 'Vinkla\\Pusher\\PusherManager'); }
/** * Specific features for OctoberCMS. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function bootstrap(Application $app) { /* * Register singletons */ $app->singleton('string', function () { return new \October\Rain\Support\Str(); }); }
/** * @param Application $app */ private function registerUrlShortener($app) { $this->mergeConfigFrom(__DIR__ . '/../lj-shortener.php', 'lj-shortener'); $app->singleton('lj.shortener', function () { $cfg = config('lj-shortener'); return new Shortener(null, false, $cfg); }); $app->alias('lj.shortener', Shortener::class); }
/** * @param \Illuminate\Contracts\Foundation\Application $app */ private function registerManager($app) { $app->singleton('google-client', function ($app) { $config = $app['config']; $factory = $app['google-client.factory']; return new GoogleClientManager($config, $factory); }); $app->alias('google-client', GoogleClientManager::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('opensearch', function ($app) { $config = $app['config']; $factory = $app['opensearch.factory']; return new OpensearchManager($config, $factory); }); $app->alias('opensearch', 'Orzcc\\Opensearch\\OpensearchManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('twitter', function ($app) { $config = $app['config']; $factory = $app['twitter.factory']; return new TwitterManager($config, $factory); }); $app->alias('twitter', 'EliuFlorez\\Twitter\\TwitterManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('flysystem', function ($app) { $config = $app['config']; $factory = $app['flysystem.factory']; return new FlysystemManager($config, $factory); }); $app->alias('flysystem', 'GrahamCampbell\\Flysystem\\FlysystemManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('transip', function ($app) { $config = $app['config']; $factory = $app['transip.factory']; return new TransIPManager($config, $factory); }); $app->alias('transip', TransIPManager::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('vineq', function ($app) { $factory = $app['vineq.factory']; $manager = new VineQManager($factory); return $manager->createConnection(); }); $app->alias('vineq', VineQ::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('dropbox', function ($app) { $config = $app['config']; $factory = $app['dropbox.factory']; return new DropboxManager($config, $factory); }); $app->alias('dropbox', DropboxManager::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('vimeo', function ($app) { $config = $app['config']; $factory = $app['vimeo.factory']; return new VimeoManager($config, $factory); }); $app->alias('vimeo', 'Vinkla\\Vimeo\\VimeoManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('mailchimp', function ($app) { $config = $app['config']; $factory = $app['mailchimp.factory']; return new MailchimpManager($config, $factory); }); $app->alias('mailchimp', MailchimpManager::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('hashids', function ($app) { $config = $app['config']; $factory = $app['hashids.factory']; return new HashidsManager($config, $factory); }); $app->alias('hashids', 'Vinkla\\Hashids\\HashidsManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('googleq', function ($app) { $config = $app['config']; $factory = $app['googleq.factory']; return new GoogleQManager($config, $factory); }); $app->alias('googleq', GoogleQManager::class); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('instagram', function ($app) { $config = $app['config']; $factory = $app['instagram.factory']; return new InstagramManager($config, $factory); }); $app->alias('instagram', 'Vinkla\\Instagram\\InstagramManager'); }
/** * Register the manager class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerManager(Application $app) { $app->singleton('topclient', function ($app) { $config = $app['config']; $factory = $app['topclient.factory']; return new TopClientManager($config, $factory); }); $app->alias('topclient', 'Orzcc\\TopClient\\TopClientManager'); }
/** * Register the binput class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerBinput(Application $app) { $app->singleton('binput', function ($app) { $request = $app['request']; $security = $app['security']; $binput = new Binput($request, $security); $app->refresh('request', $binput, 'setRequest'); return $binput; }); $app->alias('binput', Binput::class); }
/** * Initialize Telegram Bot SDK Library with Default Config. * * @param Application $app */ protected function registerTelegram(Application $app) { $app->singleton(Api::class, function ($app) { $config = $app['config']; $telegram = new Api($config->get('telegram.bot_token', false), $config->get('telegram.async_requests', false), $config->get('telegram.http_client_handler', null)); // Register Commands $telegram->addCommands($config->get('telegram.commands', [])); return $telegram; }); $app->alias(Api::class, 'telegram'); }
/** * Register the logger class. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function registerLogger(Application $app) { $app->singleton('logger', function ($app) { $loggers = []; foreach ($app->config->get('logger.loggers', []) as $logger => $levels) { $loggers[] = new LevelAwareLogger($app->make($logger), (array) $levels); } return new LoggerWrapper($loggers); }); $app->alias('logger', LoggerWrapper::class); $app->alias('logger', LoggerInterface::class); $app->alias('logger', Log::class); }
public static function init(Application $app) { /** @var \Illuminate\Foundation\Application $app */ // replace default configurator $app->singleton(\Illuminate\Foundation\Bootstrap\ConfigureLogging::class, __CLASS__); $app->configureMonologUsing(function ($monolog) { $emalAddresses = config('logging.send_to_emails') ?: false; $emailSubject = config('logging.email_subject') ?: 'Error report'; self::configureEmails($monolog, $emalAddresses, $emailSubject); $logsFilePath = storage_path('logs/errors.log.html'); self::configureFileLogs($monolog, $logsFilePath); }); }