0 follower

Final Class Yiisoft\Html\Tag\Table

InheritanceYiisoft\Html\Tag\Table » Yiisoft\Html\Tag\Base\NormalTag » Yiisoft\Html\Tag\Base\Tag
ImplementsYiisoft\Html\NoEncodeStringableInterface

Protected Properties

Hide inherited properties

Property Type Description Defined By
$attributes array Yiisoft\Html\Tag\Base\Tag

Method Details

Hide inherited methods

__toString() public method
public string __toString ( )

                final public function __toString(): string
{
    return $this->render();
}

            
addAttributes() public method

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\Table 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;
}

            
addBody() public method

public self addBody ( Yiisoft\Html\Tag\Tbody $body )
$body Yiisoft\Html\Tag\Tbody

One or more body ({@see \Yiisoft\Html\Tag\Tbody}).

                public function addBody(Tbody ...$body): self
{
    $new = clone $this;
    $new->body = array_merge($new->body, $body);
    return $new;
}

            
addClass() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addClass()

Add one or more CSS classes to the tag.

public Yiisoft\Html\Tag\Table 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;
}

            
addColumnGroups() public method

public self addColumnGroups ( Yiisoft\Html\Tag\Colgroup $columnGroups )
$columnGroups Yiisoft\Html\Tag\Colgroup

One or more column groups ({@see \Yiisoft\Html\Tag\Colgroup}).

                public function addColumnGroups(Colgroup ...$columnGroups): self
{
    $new = clone $this;
    $new->columnGroups = array_merge($new->columnGroups, $columnGroups);
    return $new;
}

            
addColumns() public method

public self addColumns ( Yiisoft\Html\Tag\Col $columns )
$columns Yiisoft\Html\Tag\Col

One or more columns ({@see \Yiisoft\Html\Tag\Col}).

                public function addColumns(Col ...$columns): self
{
    $new = clone $this;
    $new->columns = array_merge($new->columns, $columns);
    return $new;
}

            
addRows() public method

public self addRows ( Yiisoft\Html\Tag\Tr $rows )
$rows Yiisoft\Html\Tag\Tr

One or more rows ({@see \Yiisoft\Html\Tag\Tr}).

                public function addRows(Tr ...$rows): self
{
    $new = clone $this;
    $new->rows = array_merge($new->rows, $rows);
    return $new;
}

            
addStyle() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addStyle()

Add CSS styles to the tag.

See also Yiisoft\Html\Html::addCssStyle().

public Yiisoft\Html\Tag\Table addStyle ( string|string[] $style, boolean $overwrite true )
$style string|string[]

The new style string (e.g. 'width: 100px; height: 200px') or array (e.g. ['width' => '100px', 'height' => '200px']).

$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;
}

            
after() protected method
protected string after ( )

                protected function after(): string
{
    return '';
}

            
attribute() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::attribute()

Set attribute value.

public Yiisoft\Html\Tag\Table 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;
}

            
attributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::attributes()

Replace attributes with a new set.

public Yiisoft\Html\Tag\Table 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;
}

            
before() protected method
protected string before ( )

                protected function before(): string
{
    return '';
}

            
body() public method

public self body ( Yiisoft\Html\Tag\Tbody $body )
$body Yiisoft\Html\Tag\Tbody

One or more body ({@see \Yiisoft\Html\Tag\Tbody}).

                public function body(Tbody ...$body): self
{
    $new = clone $this;
    $new->body = $body;
    return $new;
}

            
caption() public method

public self caption ( Yiisoft\Html\Tag\Caption|null $caption )
$caption Yiisoft\Html\Tag\Caption|null

                public function caption(?Caption $caption): self
{
    $new = clone $this;
    $new->caption = $caption;
    return $new;
}

            
captionString() public method

public self captionString ( string $content, boolean $encode true )
$content string
$encode boolean

                public function captionString(string $content, bool $encode = true): self
{
    $caption = Caption::tag()->content($content);
    if (!$encode) {
        $caption = $caption->encode(false);
    }
    return $this->caption($caption);
}

            
class() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::class()

Replace current tag CSS classes with a new set of classes.

public Yiisoft\Html\Tag\Table 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;
}

            
close() public method
public string close ( )
return string

Closing tag.

                final public function close(): string
{
    return '</' . $this->getName() . '>';
}

            
columnGroups() public method

public self columnGroups ( Yiisoft\Html\Tag\Colgroup $columnGroups )
$columnGroups Yiisoft\Html\Tag\Colgroup

One or more column groups ({@see \Yiisoft\Html\Tag\Colgroup}).

                public function columnGroups(Colgroup ...$columnGroups): self
{
    $new = clone $this;
    $new->columnGroups = $columnGroups;
    return $new;
}

            
columns() public method

public self columns ( Yiisoft\Html\Tag\Col $columns )
$columns Yiisoft\Html\Tag\Col

One or more columns ({@see \Yiisoft\Html\Tag\Col}).

                public function columns(Col ...$columns): self
{
    $new = clone $this;
    $new->columns = $columns;
    return $new;
}

            
footer() public method

public self footer ( Yiisoft\Html\Tag\Tfoot|null $footer )
$footer Yiisoft\Html\Tag\Tfoot|null

                public function footer(?Tfoot $footer): self
{
    $new = clone $this;
    $new->footer = $footer;
    return $new;
}

            
generateContent() protected method

protected string generateContent ( )

                protected function generateContent(): string
{
    $items = [];
    if ($this->caption !== null) {
        $items[] = $this->caption;
    }
    $items = array_merge(
        $items,
        $this->columnGroups,
        $this->columns,
    );
    if ($this->header !== null) {
        $items[] = $this->header;
    }
    $items = array_merge(
        $items,
        $this->body,
        $this->rows,
    );
    if ($this->footer !== null) {
        $items[] = $this->footer;
    }
    return $items
        ? "\n" . implode("\n", $items) . "\n"
        : '';
}

            
getName() protected method

protected string getName ( )

                protected function getName(): string
{
    return 'table';
}

            
header() public method

public self header ( Yiisoft\Html\Tag\Thead|null $header )
$header Yiisoft\Html\Tag\Thead|null

                public function header(?Thead $header): self
{
    $new = clone $this;
    $new->header = $header;
    return $new;
}

            
id() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::id()

Set tag ID.

public Yiisoft\Html\Tag\Table 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;
}

            
open() public method
public string open ( )
return string

Opening tag.

                final public function open(): string
{
    return '<' . $this->getName() . $this->renderAttributes() . '>' . $this->prepend();
}

            
prepareAttributes() protected method
protected void prepareAttributes ( )

                protected function prepareAttributes(): void {}

            
prepend() protected method
protected string prepend ( )

                protected function prepend(): string
{
    return '';
}

            
removeStyle() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::removeStyle()

Remove CSS styles from the tag.

See also Yiisoft\Html\Html::removeCssStyle().

public Yiisoft\Html\Tag\Table 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;
}

            
render() public method
public string render ( )

                final public function render(): string
{
    return $this->before() . $this->renderTag() . $this->after();
}

            
renderAttributes() protected method

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);
}

            
renderTag() protected method
protected string renderTag ( )

                final protected function renderTag(): string
{
    return $this->open() . $this->generateContent() . $this->close();
}

            
rows() public method

public self rows ( Yiisoft\Html\Tag\Tr $rows )
$rows Yiisoft\Html\Tag\Tr

One or more rows ({@see \Yiisoft\Html\Tag\Tr}).

                public function rows(Tr ...$rows): self
{
    $new = clone $this;
    $new->rows = $rows;
    return $new;
}

            
tag() public static method
public static Yiisoft\Html\Tag\Table tag ( )

                final public static function tag(): static
{
    return new static();
}

            
unionAttributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::unionAttributes()

Union attributes with a new set.

public Yiisoft\Html\Tag\Table 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;
}