Esempio n. 1
0
 public function testMapRows()
 {
     $column = new Column();
     $column->setProperty('name');
     $column->setCellType(new TextCell());
     $column->setLabel('User name');
     $columnCollection = new ArrayCollection();
     $columnCollection->add($column);
     $user = new User();
     $user->setId(1);
     $user->setName('some random name');
     $user->setEmail('*****@*****.**');
     $rowCollection = new ArrayCollection();
     $rowCollection->add($user);
     $mapper = new DatagridMapper();
     $actual = $mapper->mapRows($rowCollection, $columnCollection);
     $cell = new Cell();
     $cell->setProperty('name');
     $cell->setValue('some random name');
     $cell->setExportValue('some random name');
     $cell->setType('text');
     $cell->setView('text');
     $cell->setAttributes([]);
     $row = new Row();
     $row->setId(1);
     $row->setName(1);
     $row->setObject($user);
     $row->addCell($cell);
     $expected = new ArrayCollection();
     $expected->add($row);
     $this->assertEquals($actual, $expected);
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function build()
 {
     $columns = $this->getColumns();
     $columns = $this->mapper->mapColumns($columns);
     $this->datagrid->setColumns($columns);
     $rows = $this->getRows();
     $rows = $this->mapper->mapRows($rows, $columns);
     $this->datagrid->setRows($rows);
     $this->handleViewForm();
     $views = $this->getViewRepository()->findByEntity(get_class($this->datagrid->getSource()));
     $this->datagrid->setViews($views);
     return $this->datagrid;
 }