ExternalLinktype extends AbstractLinktype

This class provides external links checking !!! There are some known issues with external link checking: - "false positives": Link targets considered broken which are not broken - no rate limiting when checking links on external sites (e.g. crawl delay) - no caching of results (except for a runtime cache during link checking which will be invalid on next run) see "Known Problems" in the linkvalidator documentation

Attributes
#[Autoconfigure]
$public: true

Table of Contents

Constants

ERROR_TYPE_GENERIC_EXCEPTION  = 'exception'
ERROR_TYPE_HTTP_STATUS_CODE  = 'httpStatusCode'
ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO  = 'libcurlErrno'
ERROR_TYPE_UNKNOWN  = 'unknown'

Properties

$errorParams  : array<string|int, mixed>
Contains parameters needed for the rendering of the error message
$headers  : array<string|int, mixed>
List of HTTP request headers to use for checking a URL
$identifier  : string
$method  : string
Preferred method of fetching (HEAD | GET).
$range  : string
For GET method, set number of bytes returned.
$requestFactory  : RequestFactory
$timeout  : int
Total timeout of the request in seconds. Using 0 (which is usually the default) may cause the request to take indefinitely, which means the scheduler task never ends.
$urlErrorParams  : array<string|int, mixed>
Cached list of all error parameters of the URLs, which were already checked for the current processing
$urlReports  : array<string|int, mixed>
Cached list of the URLs, which were already checked for the current processing

Methods

__construct()  : mixed
checkLink()  : bool
Checks a given URL for validity
fetchType()  : string
Get the external type from the softRefParserObj result
getBrokenUrl()  : string
Construct a valid Url for browser output
getErrorMessage()  : string
Generate the localized error message from the error params saved from the parsing
getErrorParams()  : array<string|int, mixed>
Get the value of the private property errorParams
getIdentifier()  : string
Returns the unique identifier of the linktype
getReadableName()  : string
Get localized label for this linktype to be displayed in Backend user interface.
setAdditionalConfig()  : void
Function to override config of Linktype. Should be used only if necessary. Add additional configuration to TSconfig.
getLanguageService()  : LanguageService
preprocessUrl()  : string
Convert domain to punycode to handle domains with non-ASCII characters
requestUrl()  : bool
Check URL using the specified request methods
setErrorParams()  : mixed
Set the value of the protected property errorParams

Constants

ERROR_TYPE_GENERIC_EXCEPTION

protected mixed ERROR_TYPE_GENERIC_EXCEPTION = 'exception'

ERROR_TYPE_HTTP_STATUS_CODE

protected mixed ERROR_TYPE_HTTP_STATUS_CODE = 'httpStatusCode'

ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO

protected mixed ERROR_TYPE_LOWLEVEL_LIBCURL_ERRNO = 'libcurlErrno'

ERROR_TYPE_UNKNOWN

protected mixed ERROR_TYPE_UNKNOWN = 'unknown'

Properties

$errorParams

Contains parameters needed for the rendering of the error message

protected array<string|int, mixed> $errorParams = []

$headers

List of HTTP request headers to use for checking a URL

protected array<string|int, mixed> $headers = ['User-Agent' => 'TYPO3 linkvalidator', 'Accept' => '*/*', 'Accept-Language' => '*', 'Accept-Encoding' => '*']

$identifier

protected string $identifier = 'external'

$method

Preferred method of fetching (HEAD | GET).

protected string $method = 'HEAD'

If HEAD is used, we fallback to GET

$range

For GET method, set number of bytes returned.

protected string $range = '0-4048'

This limits the payload, but may fail for some sites.

$timeout

Total timeout of the request in seconds. Using 0 (which is usually the default) may cause the request to take indefinitely, which means the scheduler task never ends.

protected int $timeout = 0

$urlErrorParams

Cached list of all error parameters of the URLs, which were already checked for the current processing

protected array<string|int, mixed> $urlErrorParams = []

$urlReports

Cached list of the URLs, which were already checked for the current processing

protected array<string|int, mixed> $urlReports = []

Methods

Checks a given URL for validity

public checkLink(string $origUrl, array<string|int, mixed> $softRefEntry, LinkAnalyzer $reference) : bool
Parameters
$origUrl : string

The URL to check

$softRefEntry : array<string|int, mixed>

The soft reference entry which builds the context of that URL

$reference : LinkAnalyzer

Parent instance

Tags
throws
InvalidArgumentException
Return values
bool

TRUE on success or FALSE on error

fetchType()

Get the external type from the softRefParserObj result

public fetchType(array<string|int, mixed> $value, string $type, string $key) : string
Parameters
$value : array<string|int, mixed>

Reference properties

$type : string

Current type

$key : string

Validator hook name

Return values
string

Fetched type

getBrokenUrl()

Construct a valid Url for browser output

public getBrokenUrl(array<string|int, mixed> $row) : string
Parameters
$row : array<string|int, mixed>

Broken link record

Return values
string

Parsed broken url

getErrorMessage()

Generate the localized error message from the error params saved from the parsing

public getErrorMessage(array<string|int, mixed> $errorParams) : string
Parameters
$errorParams : array<string|int, mixed>

All parameters needed for the rendering of the error message

Return values
string

Validation error message

getErrorParams()

Get the value of the private property errorParams

public getErrorParams() : array<string|int, mixed>
Return values
array<string|int, mixed>

All parameters needed for the rendering of the error message

getIdentifier()

Returns the unique identifier of the linktype

public getIdentifier() : string
Return values
string

getReadableName()

Get localized label for this linktype to be displayed in Backend user interface.

public getReadableName() : string

Custom Linktypes should override this and provide language labels for their type.

Return values
string

setAdditionalConfig()

Function to override config of Linktype. Should be used only if necessary. Add additional configuration to TSconfig.

public setAdditionalConfig(array<string|int, mixed> $config) : void
Parameters
$config : array<string|int, mixed>

preprocessUrl()

Convert domain to punycode to handle domains with non-ASCII characters

protected preprocessUrl(string $url) : string
Parameters
$url : string
Return values
string

requestUrl()

Check URL using the specified request methods

protected requestUrl(string $url, string $method, array<string|int, mixed> $options) : bool
Parameters
$url : string
$method : string
$options : array<string|int, mixed>
Return values
bool

setErrorParams()

Set the value of the protected property errorParams

protected setErrorParams(array<string|int, mixed> $value) : mixed
Parameters
$value : array<string|int, mixed>

All parameters needed for the rendering of the error message


        
On this page

Search results