Final Class Yiisoft\Html\Tag\Audio
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $attributes | array | Yiisoft\Html\Tag\Base\Tag |
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| after() | Yiisoft\Html\Tag\Base\Tag | |
| before() | Yiisoft\Html\Tag\Base\Tag | |
| generateContent() | Yiisoft\Html\Tag\Base\MediaTag | |
| getName() | Yiisoft\Html\Tag\Audio | |
| prepareAttributes() | Yiisoft\Html\Tag\Base\Tag | |
| prepend() | Yiisoft\Html\Tag\Base\NormalTag | |
| renderAttributes() | Render the current tag attributes. | Yiisoft\Html\Tag\Base\Tag |
| renderTag() | Yiisoft\Html\Tag\Base\NormalTag |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| CROSSORIGIN_ANONYMOUS | 'anonymous' | Yiisoft\Html\Tag\Base\MediaTag | |
| CROSSORIGIN_CREDENTIALS | 'use-credentials' | Yiisoft\Html\Tag\Base\MediaTag | |
| PRELOAD_AUTO | 'auto' | Yiisoft\Html\Tag\Base\MediaTag | |
| PRELOAD_METADATA | 'metadata' | Yiisoft\Html\Tag\Base\MediaTag | |
| PRELOAD_NONE | 'none' | Yiisoft\Html\Tag\Base\MediaTag |
Method Details
Defined in: Yiisoft\Html\Tag\Base\Tag::__toString()
| public string __toString ( ) |
final public function __toString(): string
{
return $this->render();
}
Defined in: Yiisoft\Html\Tag\Base\Tag::addAttributes()
Add a set of attributes to existing tag attributes.
Same named attributes are replaced.
| public Yiisoft\Html\Tag\Audio addAttributes ( array $attributes ) | ||
| $attributes | array |
Name-value set of attributes. |
final public function addAttributes(array $attributes): static
{
$new = clone $this;
$new->attributes = array_merge($new->attributes, $attributes);
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\Tag::addClass()
Add one or more CSS classes to the tag.
| public Yiisoft\Html\Tag\Audio addClass ( \BackedEnum|string|null $class ) | ||
| $class | \BackedEnum|string|null |
One or many CSS classes. |
final public function addClass(BackedEnum|string|null ...$class): static
{
$new = clone $this;
Html::addCssClass($new->attributes, $class);
return $new;
}
| public Yiisoft\Html\Tag\Audio addSource ( Yiisoft\Html\Tag\Source $source ) | ||
| $source | Yiisoft\Html\Tag\Source | |
public function addSource(Source $source): static
{
$new = clone $this;
$new->sources[] = $source;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\Tag::addStyle()
Add CSS styles to the tag.
See also Yiisoft\Html\Html::addCssStyle().
| public Yiisoft\Html\Tag\Audio addStyle ( string|string[] $style, boolean $overwrite = true ) | ||
| $style | string|string[] |
The new style string (e.g. |
| $overwrite | boolean |
Whether to overwrite existing CSS properties if the new style contain them too. |
final public function addStyle(array|string $style, bool $overwrite = true): static
{
$new = clone $this;
Html::addCssStyle($new->attributes, $style, $overwrite);
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::addTrack()
| public Yiisoft\Html\Tag\Audio addTrack ( Yiisoft\Html\Tag\Track $track ) | ||
| $track | Yiisoft\Html\Tag\Track | |
final public function addTrack(Track $track): static
{
$new = clone $this;
$new->tracks[] = $track;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\Tag::after()
| protected string after ( ) |
protected function after(): string
{
return '';
}
Defined in: Yiisoft\Html\Tag\Base\Tag::attribute()
Set attribute value.
| public Yiisoft\Html\Tag\Audio attribute ( string $name, mixed $value ) | ||
| $name | string |
Name of the attribute. |
| $value | mixed |
Value of the attribute. |
final public function attribute(string $name, mixed $value): static
{
$new = clone $this;
$new->attributes[$name] = $value;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\Tag::attributes()
Replace attributes with a new set.
| public Yiisoft\Html\Tag\Audio attributes ( array $attributes ) | ||
| $attributes | array |
Name-value set of attributes. |
final public function attributes(array $attributes): static
{
$new = clone $this;
$new->attributes = $attributes;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::autoplay()
| public Yiisoft\Html\Tag\Audio autoplay ( boolean $autoplay = true ) | ||
| $autoplay | boolean | |
final public function autoplay(bool $autoplay = true): static
{
return $this->attribute('autoplay', $autoplay);
}
Defined in: Yiisoft\Html\Tag\Base\Tag::before()
| protected string before ( ) |
protected function before(): string
{
return '';
}
Defined in: Yiisoft\Html\Tag\Base\Tag::class()
Replace current tag CSS classes with a new set of classes.
| public Yiisoft\Html\Tag\Audio class ( \BackedEnum|string|null $class ) | ||
| $class | \BackedEnum|string|null |
One or many CSS classes. |
final public function class(BackedEnum|string|null ...$class): static
{
$new = clone $this;
unset($new->attributes['class']);
Html::addCssClass($new->attributes, $class);
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\NormalTag::close()
| public string close ( ) | ||
| return | string |
Closing tag. |
|---|---|---|
final public function close(): string
{
return '</' . $this->getName() . '>';
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::controls()
| public Yiisoft\Html\Tag\Audio controls ( boolean $controls = true ) | ||
| $controls | boolean | |
final public function controls(bool $controls = true): static
{
return $this->attribute('controls', $controls);
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::crossOrigin()
| public Yiisoft\Html\Tag\Audio crossOrigin ( string|null $value ) | ||
| $value | string|null | |
final public function crossOrigin(?string $value): static
{
return $this->attribute('crossorigin', $value);
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::fallback()
Content for browser that doesn't support media tags.
| public Yiisoft\Html\Tag\Audio fallback ( string|\Stringable|null $fallback ) | ||
| $fallback | string|\Stringable|null | |
final public function fallback(string|Stringable|null $fallback): static
{
$new = clone $this;
$new->fallback = $fallback === null ? null : (string) $fallback;
return $new;
}
| protected string generateContent ( ) |
final protected function generateContent(): string
{
$items = $this->sources;
$hasDefaultTrack = false;
foreach ($this->tracks as $track) {
$isDefault = $track->isDefault();
if ($hasDefaultTrack && $isDefault) {
$items[] = $track->default(false);
} else {
$items[] = $track;
if (!$hasDefaultTrack) {
$hasDefaultTrack = $isDefault;
}
}
}
if ($this->fallback) {
$items[] = $this->fallback;
}
return $items ? "\n" . implode("\n", $items) . "\n" : '';
}
Defined in: Yiisoft\Html\Tag\Base\Tag::id()
Set tag ID.
| public Yiisoft\Html\Tag\Audio id ( string|null $id ) | ||
| $id | string|null |
Tag ID. |
final public function id(?string $id): static
{
$new = clone $this;
$new->attributes['id'] = $id;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::loop()
| public Yiisoft\Html\Tag\Audio loop ( boolean $loop = true ) | ||
| $loop | boolean | |
final public function loop(bool $loop = true): static
{
return $this->attribute('loop', $loop);
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::muted()
| public Yiisoft\Html\Tag\Audio muted ( boolean $muted = true ) | ||
| $muted | boolean | |
final public function muted(bool $muted = true): static
{
return $this->attribute('muted', $muted);
}
Defined in: Yiisoft\Html\Tag\Base\NormalTag::open()
| public string open ( ) | ||
| return | string |
Opening tag. |
|---|---|---|
final public function open(): string
{
return '<' . $this->getName() . $this->renderAttributes() . '>' . $this->prepend();
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::preload()
| public Yiisoft\Html\Tag\Audio preload ( string|null $preload ) | ||
| $preload | string|null | |
final public function preload(?string $preload): static
{
return $this->attribute('preload', $preload);
}
Defined in: Yiisoft\Html\Tag\Base\Tag::prepareAttributes()
| protected void prepareAttributes ( ) |
protected function prepareAttributes(): void {}
Defined in: Yiisoft\Html\Tag\Base\NormalTag::prepend()
| protected string prepend ( ) |
protected function prepend(): string
{
return '';
}
Defined in: Yiisoft\Html\Tag\Base\Tag::removeStyle()
Remove CSS styles from the tag.
See also Yiisoft\Html\Html::removeCssStyle().
| public Yiisoft\Html\Tag\Audio removeStyle ( string|string[] $properties ) | ||
| $properties | string|string[] |
The CSS properties to be removed. You may use a string if you are removing a single property. |
final public function removeStyle(string|array $properties): static
{
$new = clone $this;
Html::removeCssStyle($new->attributes, $properties);
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\Tag::render()
| public string render ( ) |
final public function render(): string
{
return $this->before() . $this->renderTag() . $this->after();
}
Defined in: Yiisoft\Html\Tag\Base\Tag::renderAttributes()
Render the current tag attributes.
See also Yiisoft\Html\Html::renderTagAttributes().
| protected string renderAttributes ( ) |
final protected function renderAttributes(): string
{
$this->prepareAttributes();
return Html::renderTagAttributes($this->attributes);
}
Defined in: Yiisoft\Html\Tag\Base\NormalTag::renderTag()
| protected string renderTag ( ) |
final protected function renderTag(): string
{
return $this->open() . $this->generateContent() . $this->close();
}
Defined in: Yiisoft\Html\Tag\Base\TagSourcesTrait::sources()
| public Yiisoft\Html\Tag\Audio sources ( Yiisoft\Html\Tag\Source $sources ) | ||
| $sources | Yiisoft\Html\Tag\Source | |
public function sources(Source ...$sources): static
{
$new = clone $this;
$new->sources = $sources;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::src()
| public Yiisoft\Html\Tag\Audio src ( string|null $src ) | ||
| $src | string|null | |
final public function src(?string $src): static
{
return $this->attribute('src', $src);
}
Defined in: Yiisoft\Html\Tag\Base\NormalTag::tag()
| public static Yiisoft\Html\Tag\Audio tag ( ) |
final public static function tag(): static
{
return new static();
}
Defined in: Yiisoft\Html\Tag\Base\MediaTag::tracks()
| public Yiisoft\Html\Tag\Audio tracks ( Yiisoft\Html\Tag\Track $tracks ) | ||
| $tracks | Yiisoft\Html\Tag\Track | |
final public function tracks(Track ...$tracks): static
{
$new = clone $this;
$new->tracks = $tracks;
return $new;
}
Defined in: Yiisoft\Html\Tag\Base\Tag::unionAttributes()
Union attributes with a new set.
| public Yiisoft\Html\Tag\Audio unionAttributes ( array $attributes ) | ||
| $attributes | array |
Name-value set of attributes. |
final public function unionAttributes(array $attributes): static
{
$new = clone $this;
$new->attributes += $attributes;
return $new;
}
Signup or Login in order to comment.