addAttributes() public méthode

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
Résultat string
 /**
  * @param string $html
  * @param array $attributes
  * @param string $fallbackTagName
  * @param string $expectedResult
  * @param array $exclusiveAttributes
  * @test
  * @dataProvider addAttributesDataProvider
  */
 public function addAttributesTests($html, array $attributes, $fallbackTagName, $exclusiveAttributes, $expectedResult)
 {
     if ($fallbackTagName === null) {
         $fallbackTagName = 'div';
     }
     $actualResult = $this->htmlAugmenter->addAttributes($html, $attributes, $fallbackTagName, $exclusiveAttributes);
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * Wrap the $content identified by $node with the needed markup for the backend.
  *
  * @param NodeInterface $node
  * @param string $property
  * @param string $content
  * @return string
  */
 public function wrapContentProperty(NodeInterface $node, $property, $content)
 {
     /** @var $contentContext ContentContext */
     $contentContext = $node->getContext();
     if ($contentContext->getWorkspaceName() === 'live' || !$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
         return $content;
     }
     if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) {
         return $content;
     }
     $attributes = array();
     $attributes['class'] = 'neos-inline-editable';
     $attributes['property'] = 'typo3:' . $property;
     $attributes['data-neos-node-type'] = $node->getNodeType()->getName();
     return $this->htmlAugmenter->addAttributes($content, $attributes, 'span');
 }
 /**
  * @param NodeInterface $node
  * @param string $content
  * @param string $typoScriptPath
  * @return string
  */
 public function wrapCurrentDocumentMetadata(NodeInterface $node, $content, $typoScriptPath)
 {
     if ($this->needsMetadata($node, true) === false) {
         return $content;
     }
     $attributes = [];
     $attributes['data-node-__typoscript-path'] = $typoScriptPath;
     $attributes = $this->addGenericEditingMetadata($attributes, $node);
     $attributes = $this->addNodePropertyAttributes($attributes, $node);
     $attributes = $this->addDocumentMetadata($attributes, $node);
     $attributes = $this->addCssClasses($attributes, $node, []);
     return $this->htmlAugmenter->addAttributes($content, $attributes, 'div', ['typeof']);
 }