| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Web\Widget; |
| 4 |
|
| 5 |
use ipl\Html\BaseHtmlElement; |
| 6 |
|
| 7 |
/** |
| 8 |
* Table row item |
| 9 |
* |
| 10 |
* It is rarely necessary to extend this class. Instead, you should create a new layout class that extends |
| 11 |
* {@see ItemLayout} and pass it to the {@see ItemTable} instance. |
| 12 |
* |
| 13 |
* @template Item |
| 14 |
*/ |
| 15 |
class ItemTableRow extends BaseHtmlElement |
| 16 |
{ |
| 17 |
/** @var Item The associated list item */ |
| 18 |
protected $item; |
| 19 |
|
| 20 |
/** @var ItemList<Item> The list where the item is part of */ |
| 21 |
protected $list; |
| 22 |
|
| 23 |
protected $tag = 'li'; |
| 24 |
|
| 25 |
protected $defaultAttributes = ['class' => 'table-row']; |
| 26 |
|
| 27 |
/** |
| 28 |
* Create a new table row item |
| 29 |
* |
| 30 |
* @param Item $item |
| 31 |
* @param ItemTable $table |
| 32 |
*/ |
| 33 |
public function __construct($item, ItemTable $table) |
| 34 |
{ |
| 35 |
$this->item = $item; |
| 36 |
$this->list = $table; |
| 37 |
} |
| 38 |
|
| 39 |
protected function assemble() |
| 40 |
{ |
| 41 |
$layout = $this->list->getItemLayout($this->item); |
| 42 |
|
| 43 |
$this->addAttributes($layout->getAttributes()); |
| 44 |
$this->addHtml($layout); |
| 45 |
} |
| 46 |
} |