-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was previously found in the User plugin and is a black box; nearly impossible to find from the `Redirect` facade, the `october\rain` library should provide an interface to change the key name, that is, if Laravel doesn't add this common feature in a later version
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php namespace October\Rain\Router; | ||
|
||
use App; | ||
use Illuminate\Routing\Redirector as RedirectorBase; | ||
|
||
/** | ||
* CoreRedirector adds extra events to the base redirector and ensures the "intended" | ||
* session is different for the frontend and backend contexts. | ||
* | ||
* @package october\router | ||
* @author Alexey Bobkov, Samuel Georges | ||
*/ | ||
class CoreRedirector extends RedirectorBase | ||
{ | ||
/** | ||
* intended creates a new redirect response to the previously intended location. | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function intended($default = '/', $status = 302, $headers = [], $secure = null) | ||
{ | ||
if (!App::runningInFrontend()) { | ||
return parent::intended($default, $status, $headers, $secure); | ||
} | ||
|
||
$path = $this->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters