diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index b7c8fafa7..073262b3e 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -327,7 +327,7 @@ public function registerCoreContainerAliases() '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' => [\October\Rain\Database\DatabaseManager::class], + 'db' => [\Illuminate\Database\DatabaseManager::class], 'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class], 'db.schema' => [\Illuminate\Database\Schema\Builder::class], 'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class], @@ -347,7 +347,7 @@ public function registerCoreContainerAliases() '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], + 'redirect' => [\October\Rain\Router\CoreRedirector::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], diff --git a/src/Router/CoreRedirector.php b/src/Router/CoreRedirector.php new file mode 100644 index 000000000..d43a43324 --- /dev/null +++ b/src/Router/CoreRedirector.php @@ -0,0 +1,54 @@ +session->pull('url.cms.intended', $default); + + return $this->to($path, $status, $headers, $secure); + } + + /** + * getIntendedUrl from the session. + */ + public function getIntendedUrl() + { + if (!App::runningInFrontend()) { + return parent::getIntendedUrl(); + } + + return $this->session->get('url.cms.intended'); + } + + /** + * setIntendedUrl in the session. + */ + public function setIntendedUrl($url) + { + if (!App::runningInFrontend()) { + return parent::setIntendedUrl($url); + } + + $this->session->put('url.cms.intended', $url); + return $this; + } +} diff --git a/src/Router/RoutingServiceProvider.php b/src/Router/RoutingServiceProvider.php index 80a5630b8..bb60049ad 100644 --- a/src/Router/RoutingServiceProvider.php +++ b/src/Router/RoutingServiceProvider.php @@ -45,4 +45,23 @@ protected function registerRouter() return new CoreRouter($app['events'], $app); }); } + + /** + * registerRedirector + */ + protected function registerRedirector() + { + $this->app->singleton('redirect', function ($app) { + $redirector = new CoreRedirector($app['url']); + + // If the session is set on the application instance, we'll inject it into + // the redirector instance. This allows the redirect responses to allow + // for the quite convenient "with" methods that flash to the session. + if (isset($app['session.store'])) { + $redirector->setSession($app['session.store']); + } + + return $redirector; + }); + } }