Example #1
0
 /**
  * @test
  */
 public function getByArray()
 {
     $cell = new Tx_PtExtlist_Domain_Model_List_Cell();
     $cell->setValue('testValue');
     $cell->setRowIndex(1);
     $cell->setColumnIndex(2);
     $cell->addSpecialValue('key1', 'value1');
     $cell->setCSSClass('testCssClass');
     $this->assertEquals($this->testDataArray, $cell->getAsArray());
 }
Example #2
0
 /**
  * Renders the cell content.
  *
  * @param \Tx_PtExtlist_Domain_Configuration_ColumnConfigInterface $columnConfig
  * @param Tx_PtExtlist_Domain_Model_List_Row $data The table data.
  * @param integer $columnIndex Current column index.
  * @param integer $rowIndex Current row index.
  *
  * @internal param string $columnIdentifier The columnIdentifier.
  * @return Tx_Pt_extlist_Domain_Model_List_Cell
  */
 public function renderCell(Tx_PtExtlist_Domain_Configuration_ColumnConfigInterface $columnConfig, Tx_PtExtlist_Domain_Model_List_Row $data, $columnIndex, $rowIndex)
 {
     // Load all available fields
     $fieldSet = $this->createFieldSet($data, $columnConfig);
     $caching = $columnConfig->getCacheRendering() || $this->configurationBuilder->buildListConfiguration()->getCacheRendering();
     // TODO: Include the objectMapper here ...
     // if($columnConfig->getObjectMapperConfig() instanceof Tx_PtExtlist_Domain_Configuration_Columns_ObjectMapper_ObjectMapperConfig) {}
     if ($columnConfig->getRawFields()) {
         $content = $fieldSet;
     } else {
         $content = Tx_PtExtlist_Utility_RenderValue::renderByConfigObject($fieldSet, $columnConfig, $caching);
     }
     // Create new cell
     $cell = new Tx_PtExtlist_Domain_Model_List_Cell($content);
     $cell->setRowIndex($rowIndex);
     $cell->setColumnIndex($columnIndex);
     // render cell css class
     if ($columnConfig->getCellCSSClass()) {
         $cell->setCSSClass($this->renderCellCSSClass($fieldSet, $columnConfig));
     }
     return $cell;
 }
Example #3
0
 /**
  * Set Cell Data by array
  * Reuse the existing cell objects or create new.
  *
  * @param $rowArray
  */
 public function setByArray($rowArray)
 {
     $this->specialValues = isset($rowArray['specialValues']) ? $rowArray['specialValues'] : null;
     $newItemsArray = array();
     foreach ($rowArray['columns'] as $columnIdentifier => $cellData) {
         if (count($this->itemsArr)) {
             $cell = array_pop($this->itemsArr);
             /**  @var $cell Tx_PtExtlist_Domain_Model_List_Cell */
             $cell->setByArray($cellData);
         } else {
             $cell = new Tx_PtExtlist_Domain_Model_List_Cell();
             $cell->setByArray($cellData);
         }
         $newItemsArray[$columnIdentifier] = $cell;
     }
     unset($this->itemsArr);
     $this->itemsArr = $newItemsArray;
 }
Example #4
0
 /**
  * @param array $rowData
  * @return Tx_PtExtlist_Domain_Model_List_Row
  */
 protected function createRowFromTestData(array $rowData)
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->setSpecialValues($rowData['specialValues']);
     foreach ($rowData['columns'] as $key => $testCell) {
         $cell = new Tx_PtExtlist_Domain_Model_List_Cell($testCell['value']);
         $cell->setCSSClass($testCell['cssClass']);
         $cell->setColumnIndex($testCell['columnIndex']);
         $cell->setRowIndex($testCell['rowIndex']);
         $cell->addSpecialValue('key1', $testCell['specialValues']['key1']);
         $row->addCell($cell, $key);
     }
     return $row;
 }