* @package tao */ abstract class tao_helpers_grid_Cell_SubgridAdapter extends tao_helpers_grid_Cell_Adapter { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- /** * Short description of attribute subgridClass * * @access public * @var string */ public $subgridClass = ''; /** * Instance of gridContainer used to format the cell content. * This instance is a prototype and will be cloned for each cells. * * @access public * @var GridContainer */ public $subGridContainer = null; // --- OPERATIONS --- /** * Short description of method __construct * * @access public * @author Cédric Alfonsi, * @param array options * @param string subgridClass * @return mixed */ public function __construct($options = [], $subgridClass = '') { parent::__construct($options); $this->initSubgridClass($subgridClass); //the class exists if (!class_exists($this->subgridClass)) { throw new Exception('the subgrid class does not exist : ' . $this->subgridClass); } $this->subGridContainer = new $this->subgridClass([]); //the instance is an instance of the good class if (is_a($this->subGridContainer, $this->subgridClass) && is_a($this->subGridContainer, 'tao_helpers_grid_GridContainer')) { $returnValue = $this->subGridContainer->getGrid()->getColumnsModel(); } else { throw new common_Exception('invalid subgrid class : ' . $this->subgridClass); } } /** * Short description of method getValue * * @access public * @author Cédric Alfonsi, * @param string rowId * @param string columnId * @param string data * @return mixed */ public function getValue($rowId, $columnId, $data = null) { $returnValue = null; if (isset($this->data[$rowId]) && is_a($this->data[$rowId], 'wfEngine_helpers_Monitoring_ActivityMonitoringGrid')) { $returnValue = $this->data[$rowId]; } else { $subgridData = $this->getSubgridRows($rowId); $cloneSubGridCtn = clone $this->subGridContainer; $cloneSubGridCtn->getGrid()->setData($subgridData); $returnValue = $cloneSubGridCtn; $this->data[$rowId] = $cloneSubGridCtn; } return $returnValue; } /** * Short description of method getSubgridRows * * @abstract * @access protected * @author Cédric Alfonsi, * @param string rowId * @return array */ abstract protected function getSubgridRows($rowId); /** * Short description of method initSubgridClass * * @abstract * @access protected * @author Cédric Alfonsi, * @param subgridClass * @return mixed */ abstract protected function initSubgridClass($subgridClass = ''); /** * Short description of method getGridContainer * * @access public * @author Cédric Alfonsi, * @return tao_helpers_grid_GridContainer */ public function getGridContainer() { $returnValue = null; $returnValue = $this->subGridContainer; return $returnValue; } } /* end of abstract class tao_helpers_grid_Cell_SubgridAdapter */