/** * Add cell by specifying column key and value * * @param string $columnKey * @param string|HtmlElement $value * @return HtmlElement * @throws Exception */ public function addCell($columnKey, $value = null) { if ($this->existsCell($columnKey)) { throw new Exception('cell "' . $columnKey . '" already exists.'); } $cell = new HtmlElement($this->_cellTagName); $cell->setIsReturnInner(false); $attrs = $this->_parentTable->getColumnAttributes($columnKey); if ($attrs) { $cell->setAttributes($attrs); } if ($value !== null) { $nodes = $value; if (!is_array($value)) { $nodes = array($value); } $cell->addNodes($nodes); } $this->_addCellElement($columnKey, $cell); return $cell; }