PHP 클래스 Neos\Neos\Service\HtmlAugmenter

This is used in order to add meta data arguments to content elements in the Backend. Usage: $html = '
Some HTML code
'; $result = (new HtmlAugmenter())->addAttributes($html, array('foo' => 'bar', 'bar' => 'baz')); will return '
Some HTML code
파일 보기 프로젝트 열기: neos/neos-development-collection 1 사용 예제들

공개 메소드들

메소드 설명
addAttributes ( string $html, array $attributes, string $fallbackTagName = 'div', array $exclusiveAttributes = null ) : string Adds the given $attributes to the $html by augmenting the root element.

보호된 메소드들

메소드 설명
elementHasAttributes ( DOMNode $element, array $attributes = null ) : boolean Checks whether the given $element contains at least one of the specified $attributes (case insensitive)
getHtmlRootElement ( string $html ) : DOMNode Detects a unique root tag in the given $html string and returns its DOMNode representation - or NULL if no unique root element could be found
mergeAttributes ( DOMNode $element, array &$newAttributes ) : void Merges the attributes of $element with the given $newAttributes If an attribute exists in both collections, it is merged to " " (if both values differ)
renderAttributes ( array $attributes ) : string Renders the given key/value pair to a valid attribute string in the format ="" ="".

메소드 상세

addAttributes() 공개 메소드

Attributes are merged with the existing root element's attributes. If no unique root node can be determined, a wrapping tag is added with all the given attributes. The name of this tag can be specified with $fallbackTagName.
public addAttributes ( string $html, array $attributes, string $fallbackTagName = 'div', array $exclusiveAttributes = null ) : string
$html string The HTML code to augment
$attributes array Attributes to be added to the root element in the format array('' => '', ...)
$fallbackTagName string The root element tag name if one needs to be added
$exclusiveAttributes array A list of lowercase(!) attribute names that should be exclusive to the root element. If the existing root element contains one of these a new root element is wrapped
리턴 string

elementHasAttributes() 보호된 메소드

Checks whether the given $element contains at least one of the specified $attributes (case insensitive)
protected elementHasAttributes ( DOMNode $element, array $attributes = null ) : boolean
$element DOMNode
$attributes array array of attribute names to check (lowercase)
리턴 boolean TRUE if at least one of the $attributes is contained in the given $element, otherwise FALSE

getHtmlRootElement() 보호된 메소드

Detects a unique root tag in the given $html string and returns its DOMNode representation - or NULL if no unique root element could be found
protected getHtmlRootElement ( string $html ) : DOMNode
$html string
리턴 DOMNode

mergeAttributes() 보호된 메소드

Merges the attributes of $element with the given $newAttributes If an attribute exists in both collections, it is merged to " " (if both values differ)
protected mergeAttributes ( DOMNode $element, array &$newAttributes ) : void
$element DOMNode
$newAttributes array
리턴 void

renderAttributes() 보호된 메소드

..
protected renderAttributes ( array $attributes ) : string
$attributes array The attributes to render in the format array('' => '', ...)
리턴 string