class NodeLabelToken implements ProtectedContextAwareInterface (View source)

Provides a chainable interface to build a label for a nodetype with a fallback mechanism.

Properties

protected TranslationHelper $translationHelper
protected StringHelper $stringHelper
protected string $label
protected int $length
protected string $suffix
protected string $prefix
protected string $postfix
protected NodeInterface $node

Methods

__construct(NodeInterface $node)

No description

override(string $override = null)

No description

crop(int $length, string $suffix = '...')

No description

prefix(string $prefix)

Add a text before the main label

postfix(string $postfix)

Add a text after the main label (can will be cropped)

properties(string ...$propertyNames)

No description

string
__toString()

Runs evaluate to avoid the need of calling evaluate as a finishing method

string
evaluate()

Crops, removes special chars & tags and trim the label.

void
resolveLabelFromNodeType()

Sets the label and postfix based on the nodetype

string
sanitiseLabel(string $label)

No description

bool
allowsCallOfMethod(string $methodName)

All methods are considered safe

Details

__construct(NodeInterface $node)

No description

Parameters

NodeInterface $node

NodeLabelToken override(string $override = null)

No description

Parameters

string $override

Return Value

NodeLabelToken

NodeLabelToken crop(int $length, string $suffix = '...')

No description

Parameters

int $length
string $suffix

Return Value

NodeLabelToken

NodeLabelToken prefix(string $prefix)

Add a text before the main label

Parameters

string $prefix

Return Value

NodeLabelToken

NodeLabelToken postfix(string $postfix)

Add a text after the main label (can will be cropped)

Parameters

string $postfix

Return Value

NodeLabelToken

NodeLabelToken properties(string ...$propertyNames)

No description

Parameters

string ...$propertyNames

Return Value

NodeLabelToken

string __toString()

Runs evaluate to avoid the need of calling evaluate as a finishing method

Return Value

string

string evaluate()

Crops, removes special chars & tags and trim the label.

If the label is empty a fallback based on the nodetype is provided.

Return Value

string

protected void resolveLabelFromNodeType()

Sets the label and postfix based on the nodetype

Return Value

void

protected string sanitiseLabel(string $label)

No description

Parameters

string $label

Return Value

string

bool allowsCallOfMethod(string $methodName)

All methods are considered safe

Parameters

string $methodName

Return Value

bool