本文整理汇总了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);
});
}
示例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);
}
示例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;
});
}
示例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);
}
示例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');
}
}
示例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);
}
示例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);
}
示例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);
});
}
示例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);
}
示例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');
}
示例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');
}
示例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();
});
}
示例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);
}
示例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);
}
示例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');
}