Пример #1
0
 protected function buildTableBody(TableBuilderInterface $builder, $options)
 {
     if ($options['use_tbody']) {
         $container = $builder->create('tbody', 'body', array());
         $builder->add($container);
     } else {
         $container = $builder;
     }
     $count = (string) is_array($options['data']) ? count($options['data']) : $options['data']->count();
     $padCount = strlen($count);
     $i = 1;
     foreach ($options['data'] as $item) {
         $rowNumber = str_pad($i++, $padCount, '0', STR_PAD_LEFT);
         $row = $builder->create('row' . $rowNumber, 'row', array());
         foreach ($this->columns as $name => $info) {
             if (isset($info['options']['data_transformer']) && $info['options']['data_transformer'] instanceof DataTransformerInterface) {
                 $transformer = $info['options']['data_transformer'];
                 $value = $transformer->transform($item);
             } else {
                 $value = $this->getValue($item, $name);
             }
             $type = $info['type'];
             $cell = $builder->create($name, $type, array('data' => $value));
             $row->add($cell);
         }
         $cell = $builder->create('actions', 'crud_cell', array());
         $row->add($cell);
         $this->buildRowActions($builder, $cell, $item, $options);
         $container->add($row);
     }
 }
Пример #2
0
 public function buildTable(TableBuilderInterface $builder, array $options)
 {
     $isDataOptionSet = array_key_exists('data', $options);
     $builder->setData($isDataOptionSet ? $options['data'] : null);
 }
Пример #3
0
 public function buildTable(TableBuilderInterface $builder, array $options)
 {
     $builder->addViewTransformer(new DateTimeTransformer());
     parent::buildTable($builder, $options);
 }