当前位置: 首页>>代码示例>>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;未经允许,请勿转载。