LinkResult

class \TYPO3\CMS\Frontend\Typolink\LinkResult

Implements
LinkResultInterface, LinkResultStateInterface, Stringable, JsonSerializable

This class represents a created link to a resource (page, email etc.), coming from LinkService.

After it was executed by the LinkBuilders (mostly in Frontend) after it is called from Typolink.

Table of Contents

Interfaces

LinkResultInterface
Interface representing a created link to any type (page, file etc).
LinkResultStateInterface
Interface for managing the state of a link result object.
Stringable
JsonSerializable

Constants

STRING_CAST_HTML  : mixed = 1
STRING_CAST_JSON  : mixed = 2

Properties

$additionalAttributes  : array
$flags  : int
$linkConfiguration  : array
$linkText  : string|null
$target  : string
$type  : string
$url  : string

Methods

__construct()  : mixed
__toString()  : string
adapt()  : self
Use this method to create a new LinkResult for a specific output format (HTML or JSON)
fromState()  : self
Create a LinkResult instance from a state array.
getAttribute()  : string|null
getAttributes()  : array
getHtml()  : string
getJson()  : string
getLinkConfiguration()  : array<string, string>
getLinkText()  : string|null
getState()  : array
Export all properties as a scalar state array for serialization.
getTarget()  : string
getType()  : string
getUrl()  : string
hasAttribute()  : bool
jsonSerialize()  : array
toArray()  : array{href: ?string, target: ?string, class: ?string, title: ?string, linkText: ?string, additionalAttributes: array}
withAttribute()  : self
withAttributes()  : self
withFlags()  : self
withLinkConfiguration()  : self
withLinkText()  : self
withTarget()  : self
filterAdditionalAttributes()  : array

Constants

STRING_CAST_HTML

public mixed STRING_CAST_HTML = 1

STRING_CAST_JSON

public mixed STRING_CAST_JSON = 2

Properties

$additionalAttributes

protected array $additionalAttributes = []

$flags

protected int $flags = self::STRING_CAST_HTML

$linkConfiguration

protected array $linkConfiguration = []

$linkText

protected string|null $linkText = null

$type

protected string $type = \TYPO3\CMS\Core\LinkHandling\LinkService::TYPE_UNKNOWN

Methods

__construct()

public __construct(string $type, string $url) : mixed

Parameters

$type : string
$url : string

__toString()

public __toString() : string

Return values

string

adapt()

Use this method to create a new LinkResult for a specific output format (HTML or JSON)

public static adapt(LinkResultInterface $other[, int $flags = self::STRING_CAST_HTML ]) : self

Parameters

$other : LinkResultInterface
$flags : int = self::STRING_CAST_HTML

Return values

self

fromState()

Create a LinkResult instance from a state array.

public static fromState(array $state) : self

Parameters

$state : array

Return values

self

getAttribute()

public getAttribute(string $attributeName) : string|null

Parameters

$attributeName : string

Return values

string|null

getAttributes()

public getAttributes() : array

Return values

array

getHtml()

public getHtml() : string

Return values

string

getJson()

public getJson() : string

Return values

string

getLinkConfiguration()

public getLinkConfiguration() : array<string, string>

Return values

array<string, string>

getLinkText()

public getLinkText() : string|null

Return values

string|null

getState()

Export all properties as a scalar state array for serialization.

public getState() : array

Return values

array

getTarget()

public getTarget() : string

Return values

string

getType()

public getType() : string

Return values

string

getUrl()

public getUrl() : string

Return values

string

hasAttribute()

public hasAttribute(string $attributeName) : bool

Parameters

$attributeName : string

Return values

bool

jsonSerialize()

public jsonSerialize() : array

Return values

array

toArray()

public toArray() : array{href: ?string, target: ?string, class: ?string, title: ?string, linkText: ?string, additionalAttributes: array}

Return values

array{href: ?string, target: ?string, class: ?string, title: ?string, linkText: ?string, additionalAttributes: array}

withAttribute()

public withAttribute(string $attributeName, string|null $attributeValue) : self

Parameters

$attributeName : string
$attributeValue : string|null

Return values

self

withAttributes()

public withAttributes(array $additionalAttributes[, bool $resetExistingAttributes = false ]) : self

Parameters

$additionalAttributes : array
$resetExistingAttributes : bool = false

Return values

self

withFlags()

public withFlags(int $flags) : self

Parameters

$flags : int

Return values

self

withLinkConfiguration()

public withLinkConfiguration(array $configuration) : self

Parameters

$configuration : array

Return values

self

withLinkText()

public withLinkText(string $linkText) : self

Parameters

$linkText : string

Return values

self

withTarget()

public withTarget(string $target) : self

Parameters

$target : string

Return values

self

filterAdditionalAttributes()

protected filterAdditionalAttributes(array $attributes) : array

Parameters

$attributes : array

Return values

array
On this page