/** * Add extra columns * * @return Bvb_Grid */ public function addExtraColumns($columns = array()) { static $order = 10; if (is_array($columns)) { $extraColumns = $columns; } else { $extraColumns = func_get_args(); } if (count($extraColumns) == 0) { throw new Bvb_Grid_Exception('No Columns To Add'); } $this->emitEvent('grid.add_extra_columns', array('columns' => $extraColumns)); foreach ($extraColumns as $value) { if (!$value instanceof Bvb_Grid_Extra_Column) { $value = new Bvb_Grid_Extra_Column($value['name'], $value); #throw new Bvb_Grid_Exception($value . ' must be a instance of Bvb_Grid_Extra_Column'); } if (!$value->getOption('name') || !is_string($value->getOption('name'))) { throw new Bvb_Grid_Exception('You need to define the column name'); } if ($value->getOption('title') && !is_string($value->getOption('title'))) { throw new Bvb_Grid_Exception('title option must be a string'); } if (!$value->getOption('position') || !in_array($value->getOption('position'), array('left', 'right'))) { throw new Bvb_Grid_Exception('Please define column position (left|right)'); } if (!$value->getOption('order')) { $order++; $value->setOption('order', $order); } $this->_extraColumns[$value->getOption('name')] = $value->getColumn(); } return $this; }