TYPO3  7.6
Public Member Functions | Protected Attributes | List of all members
TagBuilder Class Reference

Public Member Functions

 __construct ($tagName= '', $tagContent= '')
 
 setTagName ($tagName)
 
 getTagName ()
 
 setContent ($tagContent)
 
 getContent ()
 
 hasContent ()
 
 forceClosingTag ($forceClosingTag)
 
 hasAttribute ($attributeName)
 
 getAttribute ($attributeName)
 
 getAttributes ()
 
 addAttribute ($attributeName, $attributeValue, $escapeSpecialCharacters=true)
 
 addAttributes (array $attributes, $escapeSpecialCharacters=true)
 
 removeAttribute ($attributeName)
 
 reset ()
 
 render ()
 

Protected Attributes

 $tagName = ''
 
 $content = ''
 
 $attributes = array()
 
 $forceClosingTag = false
 

Detailed Description

Tag builder. Can be easily accessed in AbstractTagBasedViewHelper

Definition at line 19 of file TagBuilder.php.

Constructor & Destructor Documentation

__construct (   $tagName = '',
  $tagContent = '' 
)

Constructor

Parameters
string$tagNamename of the tag to be rendered
string$tagContentcontent of the tag to be rendered

Definition at line 57 of file TagBuilder.php.

References TagBuilder\$tagName, TagBuilder\setContent(), and TagBuilder\setTagName().

Member Function Documentation

addAttribute (   $attributeName,
  $attributeValue,
  $escapeSpecialCharacters = true 
)

Adds an attribute to the $attributes-collection

Parameters
string$attributeNamename of the attribute to be added to the tag
string$attributeValueattribute value
bool$escapeSpecialCharactersapply htmlspecialchars to attribute value
Returns
void

Definition at line 182 of file TagBuilder.php.

Referenced by TagBuilder\addAttributes().

addAttributes ( array  $attributes,
  $escapeSpecialCharacters = true 
)

Adds attributes to the $attributes-collection

Parameters
array$attributescollection of attributes to add. key = attribute name, value = attribute value
bool$escapeSpecialCharactersapply htmlspecialchars to attribute values#
Returns
void

Definition at line 198 of file TagBuilder.php.

References TagBuilder\addAttribute().

forceClosingTag (   $forceClosingTag)

Set this to TRUE to force a closing tag E.g. <textarea> cant be self-closing even if its empty

Parameters
bool$forceClosingTag

Definition at line 130 of file TagBuilder.php.

References TagBuilder\$forceClosingTag.

Referenced by TagBuilder\render(), and TagBuilder\reset().

getAttribute (   $attributeName)

Get an attribute from the $attributes-collection

Parameters
string$attributeNamename of the attribute
Returns
string The attribute value or NULL if the attribute is not registered

Definition at line 154 of file TagBuilder.php.

References TagBuilder\hasAttribute().

getAttributes ( )

Get all attribute from the $attributes-collection

Returns
array Attributes indexed by attribute name

Definition at line 168 of file TagBuilder.php.

References TagBuilder\$attributes.

getContent ( )

Gets the content of the tag

Returns
string content of the tag to be rendered

Definition at line 104 of file TagBuilder.php.

References TagBuilder\$content.

getTagName ( )

Gets the tag name

Returns
string tag name of the tag to be rendered

Definition at line 81 of file TagBuilder.php.

References TagBuilder\$tagName.

hasAttribute (   $attributeName)

Returns TRUE if the tag has an attribute with the given name

Parameters
string$attributeNamename of the attribute
Returns
bool TRUE if the tag has an attribute with the given name, otherwise FALSE

Definition at line 142 of file TagBuilder.php.

Referenced by TagBuilder\getAttribute().

hasContent ( )

Returns TRUE if tag contains content, otherwise FALSE

Returns
bool TRUE if tag contains text, otherwise FALSE

Definition at line 115 of file TagBuilder.php.

Referenced by TagBuilder\render().

removeAttribute (   $attributeName)

Removes an attribute from the $attributes-collection

Parameters
string$attributeNamename of the attribute to be removed from the tag
Returns
void

Definition at line 212 of file TagBuilder.php.

render ( )

Renders and returns the tag

Returns
string

Definition at line 237 of file TagBuilder.php.

References TagBuilder\$tagName, TagBuilder\forceClosingTag(), and TagBuilder\hasContent().

reset ( )

Resets the TagBuilder by setting all members to their default value

Returns
void

Definition at line 223 of file TagBuilder.php.

References TagBuilder\forceClosingTag().

setContent (   $tagContent)

Sets the content of the tag

Parameters
string$tagContentcontent of the tag to be rendered
Returns
void

Definition at line 93 of file TagBuilder.php.

Referenced by TagBuilder\__construct().

setTagName (   $tagName)

Sets the tag name

Parameters
string$tagNamename of the tag to be rendered
Returns
void

Definition at line 70 of file TagBuilder.php.

References TagBuilder\$tagName.

Referenced by TagBuilder\__construct().

Member Data Documentation

$attributes = array()
protected

Definition at line 40 of file TagBuilder.php.

Referenced by TagBuilder\getAttributes().

$content = ''
protected

Definition at line 33 of file TagBuilder.php.

Referenced by TagBuilder\getContent().

$forceClosingTag = false
protected

Definition at line 48 of file TagBuilder.php.

Referenced by TagBuilder\forceClosingTag().

$tagName = ''
protected