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.4 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.4
      • 5.4
      • 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
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
      • Client
      • Cookie
      • Exception
      • Link
      • Middleware
      • RateLimit
      • Response
      • Session
      • TestSuite
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class Link

PSR-13 Link implementation.

Represents a hypermedia link as defined in RFC 5988 and RFC 8288.

Usage

$link = new Link('/api/users', 'self');
$link = $link->withRel('collection');
$link = $link->withAttribute('type', 'application/json');
Namespace: Cake\Http\Link

Method Summary

  • __construct() public

    Constructor.

  • getAttributes() public

    Returns a list of attributes that describe the target URI.

  • getHref() public

    Returns the target of the link.

  • getRels() public

    Returns the relationship type(s) of the link.

  • isTemplated() public

    Returns whether or not this is a templated link.

  • withAttribute() public

    Returns an instance with the specified attribute added.

  • withHref() public

    Returns an instance with the specified href.

  • withRel() public

    Returns an instance with the specified relationship included.

  • withoutAttribute() public

    Returns an instance with the specified attribute excluded.

  • withoutRel() public

    Returns an instance with the specified relationship excluded.

Method Detail

__construct() ¶ public

__construct(string $href = '', array<string>|string $rels = [], array<string, string|bool|int|float|array<string>> $attributes = [])

Constructor.

Parameters
string $href optional

The link URI.

array<string>|string $rels optional

The link relation(s).

array<string, string|bool|int|float|array<string>> $attributes optional

Additional attributes.

getAttributes() ¶ public

getAttributes(): array

Returns a list of attributes that describe the target URI.

Returns
array

getHref() ¶ public

getHref(): string

Returns the target of the link.

The target link must be one of:

  • An absolute URI, as defined by RFC 5988.
  • A relative URI, as defined by RFC 5988. The base of the relative link is assumed to be known based on context by the client.
  • A URI template as defined by RFC 6570.

If a URI template is returned, isTemplated() MUST return True.

Returns
string

getRels() ¶ public

getRels(): string[]

Returns the relationship type(s) of the link.

This method returns 0 or more relationship types for a link, expressed as an array of strings.

Returns
string[]

isTemplated() ¶ public

isTemplated(): bool

Returns whether or not this is a templated link.

Returns
bool

withAttribute() ¶ public

withAttribute(string $attribute, string|Stringable|int|float|bool|array $value): static

Returns an instance with the specified attribute added.

If the specified attribute is already present, it will be overwritten with the new value.

Parameters
string $attribute
string|Stringable|int|float|bool|array $value
Returns
static

withHref() ¶ public

withHref(string|Stringable $href): static

Returns an instance with the specified href.

Parameters
string|Stringable $href
Returns
static

withRel() ¶ public

withRel(string $rel): static

Returns an instance with the specified relationship included.

If the specified rel is already present, this method MUST return normally without errors, but without adding the rel a second time.

Parameters
string $rel
Returns
static

withoutAttribute() ¶ public

withoutAttribute(string $attribute): static

Returns an instance with the specified attribute excluded.

If the specified attribute is not present, this method MUST return normally without errors.

Parameters
string $attribute
Returns
static

withoutRel() ¶ public

withoutRel(string $rel): static

Returns an instance with the specified relationship excluded.

If the specified rel is already not present, this method MUST return normally without errors.

Parameters
string $rel
Returns
static
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