OOUI\Tag Class Reference
Inheritance diagram for OOUI\Tag:
[legend]
Collaboration diagram for OOUI\Tag:
[legend]

## Public Member Functions

| __construct ($tag= 'div')
| Create element. More...
| hasClass ($class)
| Check for CSS class. More...
| addClasses (array $classes)
| Add CSS classes. More...
| removeClasses (array $classes)
| Remove CSS classes. More...
| toggleClasses (array $classes, $toggle=null)
| Toggle CSS classes. More...
| getAttribute ($key)
| Get HTML attribute value. More...
| setAttributes (array $attributes)
| Add HTML attributes. More...
| setValue ($value)
| Set value of input element ('value' attribute for most, element content for textarea). More...
| removeAttributes (array $keys)
| Remove HTML attributes. More...
| appendContent ()
| Add content to the end. More...
| prependContent ()
| Add content to the beginning. More...
| clearContent ()
| Remove all content. More...
| getElementGroup ()
| Get group element is in. More...
| setElementGroup ($group)
| Set group element is in. More...
| setInfusable ($infusable)
| Enable widget for client-side infusion. More...
| isInfusable ()
| Get client-side infusability. More...
| ensureInfusableId ()
| Ensure that this given Tag is infusable and has a unique `id` attribute. More...
| toString ()
| Render element into HTML. More...
| __toString ()
| Magic method implementation. More...

## Protected Member Functions

| getGeneratedAttributes ()
| Return an augmented `attributes` array, including synthetic attributes which are created from other properties (like the `classes` array) but which shouldn't be retained in the user-visible `attributes`. More...

## Protected Attributes

string | $tag = ''
| Tag name for this instance. More...
array | $attributes = array()
| Attributes. More...
array | $classes = array()
| Classes. More...
array | $content = array()
| Content. More...
GroupElement null | $elementGroup = null
| Group. More...
boolean | $infusable = false
| Infusion support. More...

## Constructor & Destructor Documentation

OOUI\Tag::__construct | ( |  | $tag = `'div'` | ) |

Create element.

Parameters

  string | $tag | HTML tag name

## Member Function Documentation

OOUI\Tag::__toString | ( |  | ) |

Magic method implementation.

PHP doesn't allow __toString to throw exceptions and will trigger a fatal error if it does. This is a wrapper around the real toString() to convert them to errors instead.

Returns
  string

OOUI\Tag::addClasses | ( | array | $classes | ) |

Add CSS classes.

Parameters

  array | $classes | List of classes to add

Returns
  $this

OOUI\Tag::appendContent | ( |  | ) |

Add content to the end.

Accepts variadic arguments (the $content argument can be repeated any number of times).

Parameters

  string | Tag | HtmlSnippet | $content | Content to append. Strings will be HTML-escaped for output, use a HtmlSnippet instance to prevent that.

Returns
  $this

OOUI\Tag::clearContent | ( |  | ) |

Remove all content.

Returns
  $this

OOUI\Tag::ensureInfusableId | ( |  | ) |

Ensure that this given Tag is infusable and has a unique `id` attribute.

Returns
  $this

OOUI\Tag::getAttribute | ( |  | $key | ) |

Get HTML attribute value.

Parameters

  string | $key | HTML attribute name

Returns
  string|null

OOUI\Tag::getElementGroup | ( |  | ) |

Get group element is in.

Returns
  GroupElement|null Group element, null if none

OOUI\Tag::getGeneratedAttributes | ( |  | ) |

protected

Return an augmented `attributes` array, including synthetic attributes which are created from other properties (like the `classes` array) but which shouldn't be retained in the user-visible `attributes`.

Returns
  array An attributes array.

OOUI\Tag::hasClass | ( |  | $class | ) |

Check for CSS class.

Parameters

  string | $name | CSS class name

Returns
  boolean

OOUI\Tag::isInfusable | ( |  | ) |

Get client-side infusability.

Returns
  boolean If this tag/element/widget can be referenced client-side.

OOUI\Tag::prependContent | ( |  | ) |

Add content to the beginning.

Accepts variadic arguments (the $content argument can be repeated any number of times).

Parameters

  string | Tag | HtmlSnippet | $content | Content to prepend. Strings will be HTML-escaped for output, use a HtmlSnippet instance to prevent that.

Returns
  $this

OOUI\Tag::removeAttributes | ( | array | $keys | ) |

Remove HTML attributes.

Parameters

  array | $keys | List of attribute keys to remove

Returns
  $this

OOUI\Tag::removeClasses | ( | array | $classes | ) |

Remove CSS classes.

Parameters

  array | $classes | List of classes to remove

Returns
  $this

OOUI\Tag::setAttributes | ( | array | $attributes | ) |

Add HTML attributes.

Parameters

  array | $attributes | List of attribute key/value pairs to add

Returns
  $this

OOUI\Tag::setElementGroup | ( |  | $group | ) |

Set group element is in.

Parameters

  GroupElement | null | $group | Group element, null if none

Returns
  $this

OOUI\Tag::setInfusable | ( |  | $infusable | ) |

Enable widget for client-side infusion.

Parameters

  boolean | $infusable | True to allow tag/element/widget to be referenced client-side.

Returns
  $this

OOUI\Tag::setValue | ( |  | $value | ) |

Set value of input element ('value' attribute for most, element content for textarea).

Parameters

  string | $value | Value to set

Returns
  $this

OOUI\Tag::toggleClasses | ( | array | $classes,
|  |  | $toggle = `null`
| ) |  |

Toggle CSS classes.

Parameters

  array | $classes | List of classes to add
  boolean | $toggle | Add classes

Returns
  $this

OOUI\Tag::toString | ( |  | ) |

Render element into HTML.

Returns
  string HTML serialization

Exceptions

  Exception |

## Member Data Documentation

array OOUI\Tag::$attributes = array()

protected

Attributes.

HTML attributes

array OOUI\Tag::$classes = array()

protected

Classes.

CSS classes

array OOUI\Tag::$content = array()

protected

Content.

Content text and elements

GroupElement null OOUI\Tag::$elementGroup = null

protected

Group.

Group element is in

boolean OOUI\Tag::$infusable = false

protected

Infusion support.

Whether to serialize tag/element/widget state for client-side use.

string OOUI\Tag::$tag = ''

protected

Tag name for this instance.

HTML tag name

The documentation for this class was generated from the following file:

- php/Tag.php