Documentation

LinkRenderer
in package

Renders an HTML anchor pointing to the location of the provided element.

Table of Contents

PRESENTATION_CLASS_SHORT  = 'class:short'
PRESENTATION_FILE_SHORT  = 'file:short'
PRESENTATION_NORMAL  = 'normal'
PRESENTATION_URL  = 'url'
$convertToRootPath  : bool
$destination  : string
$project  : ProjectDescriptor|null
$router  : Router
__construct()  : mixed
convertToRootPath()  : string|null
Converts the given path to be relative to the root of the documentation target directory.
doNotConvertUrlsToRootPath()  : self
getDestination()  : string
Returns the target directory relative to the Project's Root.
link()  : string
render()  : array<string|int, string>|string
setDestination()  : void
withDestination()  : self
Sets the destination directory relative to the Project's Root.
withProject()  : self
createFqsenFromReference()  : Fqsen
getPathPrefixBasedOnDepth()  : string
Calculates how deep the given destination is and returns a prefix.
isReferenceToFqsen()  : bool
renderAbstractListLinks()  : string
renderASeriesOfLinks()  : array<int, string>
Returns a series of anchors and strings for the given collection of routable items.
renderLink()  : string
renderType()  : array<int, string>
withoutLeadingSlash()  : string

Constants

PRESENTATION_CLASS_SHORT

public mixed PRESENTATION_CLASS_SHORT = 'class:short'

PRESENTATION_FILE_SHORT

public mixed PRESENTATION_FILE_SHORT = 'file:short'

PRESENTATION_NORMAL

public mixed PRESENTATION_NORMAL = 'normal'

Properties

$convertToRootPath

private bool $convertToRootPath = true

Methods

convertToRootPath()

Converts the given path to be relative to the root of the documentation target directory.

public convertToRootPath(string $pathOrReference[, bool $force = false ]) : string|null

It is not possible to use absolute paths in documentation templates since they may be used locally, or in a subfolder. As such we need to calculate the number of levels to go up from the current document's directory and then append the given path.

For example:

Suppose you are in <root>/classes/my/class.html and you want open
<root>/my/index.html then you provide 'my/index.html' to this method
and it will convert it into ../../my/index.html (<root>/classes/my is
two nesting levels until the root).

This method does not try to normalize or optimize the paths in order to save on development time and performance, and because it adds no real value.

In addition, when a path starts with an @-sign, it is interpreted as a reference to a structural element and we use the router to try and find a path to which this refers.

Parameters
$pathOrReference : string
$force : bool = false
Tags
todo

References can only point to an element that is a class, interface, trait, method, property or class constant at this moment. This is because an FQSEN does not contain the necessary data to distinguish whether the FQCN is actually a class or a namespace reference. As such we assume a class as that is the most common occurrence.

Return values
string|null

doNotConvertUrlsToRootPath()

public doNotConvertUrlsToRootPath() : self
Return values
self

getDestination()

Returns the target directory relative to the Project's Root.

public getDestination() : string
Return values
string

setDestination()

public setDestination(string $destination) : void
Parameters
$destination : string
Tags
deprecated

in favour of withDestination()

Return values
void

withDestination()

Sets the destination directory relative to the Project's Root.

public withDestination(string $destination) : self

The destination is the target directory containing the resulting file. This destination is relative to the Project's root and can be used for the calculation of nesting depths, etc.

For this specific extension the destination is provided in the Twig writer itself.

Parameters
$destination : string
Return values
self

createFqsenFromReference()

private createFqsenFromReference(string $path) : Fqsen
Parameters
$path : string
Return values
Fqsen

getPathPrefixBasedOnDepth()

Calculates how deep the given destination is and returns a prefix.

private getPathPrefixBasedOnDepth() : string

The calculated prefix is used to get back to the root (i.e. three levels deep means ../../..) or an empty string is returned when you are already at the same level as the root.

This prefix will include a trailing forward slash (/) when it actually needs to direct the caller to go elsewhere.

Return values
string

isReferenceToFqsen()

private isReferenceToFqsen(string $path) : bool
Parameters
$path : string
Return values
bool
private renderAbstractListLinks(AbstractList $node, string $presentation) : string
Parameters
$node : AbstractList
$presentation : string
Return values
string

Returns a series of anchors and strings for the given collection of routable items.

private renderASeriesOfLinks(iteratable<string|int, mixed> $value, string $presentation) : array<int, string>
Parameters
$value : iteratable<string|int, mixed>
$presentation : string
Return values
array<int, string>

renderType()

private renderType(iteratable<string|int, Type$value) : array<int, string>
Parameters
$value : iteratable<string|int, Type>
Return values
array<int, string>

withoutLeadingSlash()

private withoutLeadingSlash(string $path) : string
Parameters
$path : string
Return values
string

Search results