ndex < count($callbacks)) { $callbacks[$index]($this); $index++; } } /** * {@inheritdoc} * * @return \Symfony\Component\HttpFoundation\Response */ public function handle(SymfonyRequest $request, int $type = self::MASTER_REQUEST, bool $catch = true) { return $this[HttpKernelContract::class]->handle(Request::createFromBase($request)); } /** * Determine if middleware has been disabled for the application. * * @return bool */ public function shouldSkipMiddleware() { return $this->bound('middleware.disable') && $this->make('middleware.disable') === true; } /** * Get the path to the cached services.php file. * * @return string */ public function getCachedServicesPath() { return $this->normalizeCachePath('APP_SERVICES_CACHE', 'cache/services.php'); } /** * Get the path to the cached packages.php file. * * @return string */ public function getCachedPackagesPath() { return $this->normalizeCachePath('APP_PACKAGES_CACHE', 'cache/packages.php'); } /** * Determine if the application configuration is cached. * * @return bool */ public function configurationIsCached() { return is_file($this->getCachedConfigPath()); } /** * Get the path to the configuration cache file. * * @return string */ public function getCachedConfigPath() { return $this->normalizeCachePath('APP_CONFIG_CACHE', 'cache/config.php'); } /** * Determine if the application routes are cached. * * @return bool */ public function routesAreCached() { return $this['files']->exists($this->getCachedRoutesPath()); } /** * Get the path to the routes cache file. * * @return string */ public function getCachedRoutesPath() { return $this->normalizeCachePath('APP_ROUTES_CACHE', 'cache/routes-v7.php'); } /** * Determine if the application events are cached. * * @return bool */ public function eventsAreCached() { return $this['files']->exists($this->getCachedEventsPath()); } /** * Get the path to the events cache file. * * @return string */ public function getCachedEventsPath() { return $this->normalizeCachePath('APP_EVENTS_CACHE', 'cache/events.php'); } /** * Normalize a relative or absolute path to a cache file. * * @param string $key * @param string $default * @return string */ protected function normalizeCachePath($key, $default) { if (is_null($env = Env::get($key))) { return $this->bootstrapPath($default); } return Str::startsWith($env, $this->absoluteCachePathPrefixes) ? $env : $this->basePath($env); } /** * Add new prefix to list of absolute path prefixes. * * @param string $prefix * @return $this */ public function addAbsoluteCachePathPrefix($prefix) { $this->absoluteCachePathPrefixes[] = $prefix; return $this; } /** * Determine if the application is currently down for maintenance. * * @return bool */ public function isDownForMaintenance() { return file_exists($this->storagePath().'/framework/down'); } /** * Throw an HttpException with the given data. * * @param int $code * @param string $message * @param array $headers * @return never * * @throws \Symfony\Component\HttpKernel\Exception\HttpException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function abort($code, $message = '', array $headers = []) { if ($code == 404) { throw new NotFoundHttpException($message); } throw new HttpException($code, $message, null, $headers); } /** * Register a terminating callback with the application. * * @param callable|string $callback * @return $this */ public function terminating($callback) { $this->terminatingCallbacks[] = $callback; return $this; } /** * Terminate the application. * * @return void */ public function terminate() { $index = 0; while ($index < count($this->terminatingCallbacks)) { $this->call($this->terminatingCallbacks[$index]); $index++; } } /** * Get the service providers that have been loaded. * * @return array */ public function getLoadedProviders() { return $this->loadedProviders; } /** * Determine if the given service provider is loaded. * * @param string $provider * @return bool */ public function providerIsLoaded(string $provider) { return isset($this->loadedProviders[$provider]); } /** * Get the application's deferred services. * * @return array */ public function getDeferredServices() { return $this->deferredServices; } /** * Set the application's deferred services. * * @param array $services * @return void */ public function setDeferredServices(array $services) { $this->deferredServices = $services; } /** * Add an array of services to the application's deferred services. * * @param array $services * @return void */ public function addDeferredServices(array $services) { $this->deferredServices = array_merge($this->deferredServices, $services); } /** * Determine if the given service is a deferred service. * * @param string $service * @return bool */ public function isDeferredService($service) { return isset($this->deferredServices[$service]); } /** * Configure the real-time facade namespace. * * @param string $namespace * @return void */ public function provideFacades($namespace) { AliasLoader::setFacadeNamespace($namespace); } /** * Get the current application locale. * * @return string */ public function getLocale() { return $this['config']->get('app.locale'); } /** * Get the current application locale. * * @return string */ public function currentLocale() { return $this->getLocale(); } /** * Get the current application fallback locale. * * @return string */ public function getFallbackLocale() { return $this['config']->get('app.fallback_locale'); } /** * Set the current application locale. * * @param string $locale * @return void */ public function setLocale($locale) { $this['config']->set('app.locale', $locale); $this['translator']->setLocale($locale); $this['events']->dispatch(new LocaleUpdated($locale)); } /** * Set the current application fallback locale. * * @param string $fallbackLocale * @return void */ public function setFallbackLocale($fallbackLocale) { $this['config']->set('app.fallback_locale', $fallbackLocale); $this['translator']->setFallback($fallbackLocale); } /** * Determine if the application locale is the given locale. * * @param string $locale * @return bool */ public function isLocale($locale) { return $this->getLocale() == $locale; } /** * Register the core class aliases in the container. * * @return void */ public function registerCoreContainerAliases() { foreach ([ 'app' => [self::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class], 'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class], 'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class], 'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class], 'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class], 'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class, \Psr\SimpleCache\CacheInterface::class], 'cache.psr6' => [\Symfony\Component\Cache\Adapter\Psr16Adapter::class, \Symfony\Component\Cache\Adapter\AdapterInterface::class, \Psr\Cache\CacheItemPoolInterface::class], 'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class], 'cookie' => [\Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class], 'db' => [\Illuminate\Database\DatabaseManager::class, \Illuminate\Database\ConnectionResolverInterface::class], 'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class], 'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\StringEncrypter::class], 'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class], 'files' => [\Illuminate\Filesystem\Filesystem::class], 'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class], 'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class], 'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class], 'hash' => [\Illuminate\Hashing\HashManager::class], 'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class], 'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class], 'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class], 'mail.manager' => [\Illuminate\Mail\MailManager::class, \Illuminate\Contracts\Mail\Factory::class], 'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class], 'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class], 'auth.password.broker' => [\Illuminate\Auth\Passwords\PasswordBroker::class, \Illuminate\Contracts\Auth\PasswordBroker::class], 'queue' => [\Illuminate\Queue\QueueManager::class, \Illuminate\Contracts\Queue\Factory::class, \Illuminate\Contracts\Queue\Monitor::class], 'queue.connection' => [\Illuminate\Contracts\Queue\Queue::class], 'queue.failer' => [\Illuminate\Queue\Failed\FailedJobProviderInterface::class], 'redirect' => [\Illuminate\Routing\Redirector::class], 'redis' => [\Illuminate\Redis\RedisManager::class, \Illuminate\Contracts\Redis\Factory::class], 'redis.connection' => [\Illuminate\Redis\Connections\Connection::class, \Illuminate\Contracts\Redis\Connection::class], 'request' => [\Illuminate\Http\Request::class, \Symfony\Component\HttpFoundation\Request::class], 'router' => [\Illuminate\Routing\Router::class, \Illuminate\Contracts\Routing\Registrar::class, \Illuminate\Contracts\Routing\BindingRegistrar::class], 'session' => [\Illuminate\Session\SessionManager::class], 'session.store' => [\Illuminate\Session\Store::class, \Illuminate\Contracts\Session\Session::class], 'url' => [\Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class], 'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class], 'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class], ] as $key => $aliases) { foreach ($aliases as $alias) { $this->alias($key, $alias); } } } /** * Flush the container of all bindings and resolved instances. * * @return void */ public function flush() { parent::flush(); $this->buildStack = []; $this->loadedProviders = []; $this->bootedCallbacks = []; $this->bootingCallbacks = []; $this->deferredServices = []; $this->reboundCallbacks = []; $this->serviceProviders = []; $this->resolvingCallbacks = []; $this->terminatingCallbacks = []; $this->beforeResolvingCallbacks = []; $this->afterResolvingCallbacks = []; $this->globalBeforeResolvingCallbacks = []; $this->globalResolvingCallbacks = []; $this->globalAfterResolvingCallbacks = []; } /** * Get the application namespace. * * @return string * * @throws \RuntimeException */ public function getNamespace() { if (! is_null($this->namespace)) { return $this->namespace; } $composer = json_decode(file_get_contents($this->basePath('composer.json')), true); foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) { foreach ((array) $path as $pathChoice) { if (realpath($this->path()) === realpath($this->basePath($pathChoice))) { return $this->namespace = $namespace; } } } throw new RuntimeException('Unable to detect application namespace.'); } }