Repository navigation
Internals Redirect Redirect
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/redirect/Redirect.php · Snapshot 8411f4287706.
Redirect stores a target consumed by the web bootstrap. Breadcrumbs keeps the last rendered page in the PHP session.
use redirect\breadcrumbs\BreadCrumbs;class Redirect extends BreadCrumbsSource description (behavioral corrections are recorded in Known discrepancies):
The Redirect class extends the BreadCrumbs class and is responsible for managing redirection logic, including routing, custom redirects, and going back to the previous page.
Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| $routes | public array $routes = []; |
Used by setRoutes(), route(). |
| $redirectTo | public string $redirectTo; |
Used by route(), back(), redirect(), getRedirectTo(). |
| Method | Signature |
|---|---|
| __construct | public function __construct() |
| setRoutes | public function setRoutes(array $routes): void |
| route | public function route(string $name): self |
| back | public function back(): self |
| redirect | public function redirect(string $path): self |
| getRedirectTo | public function getRedirectTo(): string |
public function __construct()Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
public function __construct()
{
parent::__construct();
}public function setRoutes(array $routes): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$routes |
array $routes |
An associative array of routes. |
Sets the routes for the redirection logic.
This method assigns an array of routes to the $routes property.
Each route is a key-value pair where the key is the route name,
and the value is the corresponding URL.
@param array $routes An associative array of routes.
State writes: $this->routes.
Implementation, validation guards and interaction order
/**
* Sets the routes for the redirection logic.
*
* This method assigns an array of routes to the `$routes` property.
* Each route is a key-value pair where the key is the route name,
* and the value is the corresponding URL.
*
* @param array $routes An associative array of routes.
*/
public function setRoutes(array $routes): void
{
$this->routes = $routes;
}public function route(string $name): self| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$name |
string $name |
The name of the route. |
Sets the redirection URL based on a named route.
This method accepts a route name, retrieves the corresponding URL from the $routes array,
and assigns it to the $redirectTo property.
@param string $name The name of the route. @return self Returns the instance of the Redirect class to allow method chaining.
State writes: $this->redirectTo.
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
/**
* Sets the redirection URL based on a named route.
*
* This method accepts a route name, retrieves the corresponding URL from the `$routes` array,
* and assigns it to the `$redirectTo` property.
*
* @param string $name The name of the route.
* @return self Returns the instance of the Redirect class to allow method chaining.
*/
public function route(string $name): self
{
$this->redirectTo = $this->routes[$name];
return $this;
}public function back(): selfSets the redirection URL to the last visited page.
This method retrieves the last visited page URL (via the getLast() method inherited
from BreadCrumbs) and assigns it to the $redirectTo property.
@return self Returns the instance of the Redirect class to allow method chaining.
State writes: $this->redirectTo.
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
/**
* Sets the redirection URL to the last visited page.
*
* This method retrieves the last visited page URL (via the `getLast()` method inherited
* from BreadCrumbs) and assigns it to the `$redirectTo` property.
*
* @return self Returns the instance of the Redirect class to allow method chaining.
*/
public function back(): self
{
$this->redirectTo = $this->getLast();
return $this;
}public function redirect(string $path): self| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$path |
string $path |
The URL to which the user should be redirected. |
Manually sets the redirection URL to a specific path.
This method directly assigns a given path (or URL) to the $redirectTo property.
@param string $path The URL to which the user should be redirected. @return self Returns the instance of the Redirect class to allow method chaining.
State writes: $this->redirectTo.
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
/**
* Manually sets the redirection URL to a specific path.
*
* This method directly assigns a given path (or URL) to the `$redirectTo` property.
*
* @param string $path The URL to which the user should be redirected.
* @return self Returns the instance of the Redirect class to allow method chaining.
*/
public function redirect(string $path): self
{
$this->redirectTo = $path;
return $this;
}public function getRedirectTo(): stringRetrieves the current redirection URL.
This method returns the value of the $redirectTo property, which contains
the URL to which the user will be redirected.
@return string The URL to redirect to.
Return expressions (including local callbacks): $this->redirectTo.
Implementation, validation guards and interaction order
/**
* Retrieves the current redirection URL.
*
* This method returns the value of the `$redirectTo` property, which contains
* the URL to which the user will be redirected.
*
* @return string The URL to redirect to.
*/
public function getRedirectTo(): string
{
return $this->redirectTo;
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes