當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::singleton方法代碼示例

本文整理匯總了PHP中Illuminate\Contracts\Foundation\Application::singleton方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::singleton方法的具體用法?PHP Application::singleton怎麽用?PHP Application::singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Contracts\Foundation\Application的用法示例。


在下文中一共展示了Application::singleton方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: registerNamespace

 /**
  * @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);
     });
 }
開發者ID:laravel-commode,項目名稱:bladed,代碼行數:11,代碼來源:BladedCompiler.php

示例2: handle

 /**
  * 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);
 }
開發者ID:rlacerda83,項目名稱:api,代碼行數:23,代碼來源:Request.php

示例3: bootstrap

 /**
  * 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;
     });
 }
開發者ID:jBOKA,項目名稱:library,代碼行數:22,代碼來源:LoadTranslation.php

示例4: registerGitlib

 /**
  * 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);
 }
開發者ID:phecho,項目名稱:Gitlib,代碼行數:14,代碼來源:GitlibServiceProvider.php

示例5: bootstrap

 /**
  * 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');
     }
 }
開發者ID:mechiko,項目名稱:staff-october,代碼行數:34,代碼來源:RegisterOctober.php

示例6: registerManager

 /**
  * 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);
 }
開發者ID:nikkiii,項目名稱:laravel-cachet,代碼行數:15,代碼來源:CachetServiceProvider.php

示例7: registerManager

 /**
  * 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);
 }
開發者ID:emayk,項目名稱:telegram-bot-sdk,代碼行數:15,代碼來源:TelegramServiceProvider.php

示例8: registerApiHelper

 /**
  * 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);
     });
 }
開發者ID:jenky,項目名稱:laravel-api-helper,代碼行數:15,代碼來源:ApiServiceProvider.php

示例9: registerSecurity

 /**
  * 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);
 }
開發者ID:ssomenzi,項目名稱:silence,代碼行數:15,代碼來源:SecurityServiceProvider.php

示例10: registerManager

 /**
  * 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');
 }
開發者ID:hoopyfrood,項目名稱:Laravel-CloudFlare-API,代碼行數:16,代碼來源:CloudFlareAPIServiceProvider.php

示例11: registerManager

 /**
  * 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');
 }
開發者ID:huseyinbabal,項目名稱:RealtimeChatLaravel,代碼行數:16,代碼來源:PusherServiceProvider.php

示例12: bootstrap

 /**
  * 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();
     });
 }
開發者ID:janusnic,項目名稱:23copperleaf,代碼行數:15,代碼來源:RegisterOctober.php

示例13: registerUrlShortener

 /**
  * @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);
 }
開發者ID:laravel-junkies,項目名稱:url-shortener,代碼行數:12,代碼來源:UrlShortenerProvider.php

示例14: registerManager

 /**
  * @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);
 }
開發者ID:websightgmbh,項目名稱:l5-google-client,代碼行數:12,代碼來源:GoogleApiClientServiceProvider.php

示例15: registerManager

 /**
  * 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');
 }
開發者ID:orzcc,項目名稱:aliyun-opensearch,代碼行數:16,代碼來源:OpensearchServiceProvider.php


注:本文中的Illuminate\Contracts\Foundation\Application::singleton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。