CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.3 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.3
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
      • Exception
      • Middleware
      • Route
    • TestSuite
    • Utility
    • Validation
    • View

Trait RedirectTrait

Trait to implement redirect route functionality.

Redirect route will perform an immediate redirect. Redirect routes are useful when you want to have Routing layer redirects occur in your application, for when URLs move.

Redirection is signaled by an exception that halts route matching and defines the redirect URL and status code.

Namespace: Cake\Routing\Route

Property Summary

  • $redirect public
    array

    The location to redirect to.

Method Summary

  • __construct() public

    Constructor

  • match() public

    There is no reverse routing redirection routes.

  • parse() public

    Parses a string URL into an array. Parsed URLs will result in an automatic redirection.

  • setStatus() public

    Sets the HTTP status

Method Detail

__construct() ¶ public

__construct(string $template, array $defaults = [], array<string, mixed> $options = [])

Constructor

Parameters
string $template

Template string with parameter placeholders

array $defaults optional

Defaults for the route. Either a redirect=>value array or a CakePHP array URL.

array<string, mixed> $options optional

Array of additional options for the Route

match() ¶ public

match(array $url, array $context = []): string|null

There is no reverse routing redirection routes.

Parameters
array $url

Array of parameters to convert to a string.

array $context optional

Array of request context parameters.

Returns
string|null

Always null, string return result unused.

parse() ¶ public

parse(string $url, string $method = ''): array|null

Parses a string URL into an array. Parsed URLs will result in an automatic redirection.

Parameters
string $url

The URL to parse.

string $method optional

The HTTP method being used.

Returns
array|null

Null on failure. An exception is raised on a successful match. Array return type is unused.

Throws
Cake\Http\Exception\RedirectException
An exception is raised on successful match. This is used to halt route matching and signal to the middleware that a redirect should happen.

setStatus() ¶ public

setStatus(int $status): $this

Sets the HTTP status

Parameters
int $status

The status code for this route

Returns
$this

Property Detail

$redirect ¶ public

The location to redirect to.

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs