コード例 #1
0
ファイル: AbstractFilterType.php プロジェクト: ekyna/table
 /**
  * {@inheritdoc}
  */
 public function buildTableFilter(TableConfig $config, $name, array $options = [])
 {
     $resolver = new OptionsResolver();
     $this->configureOptions($resolver);
     $options['name'] = $name;
     $options['full_name'] = sprintf('%s_%s', $config->getName(), $name);
     $resolvedOptions = $resolver->resolve($options);
     $config->addFilter($resolvedOptions);
 }
コード例 #2
0
ファイル: Table.php プロジェクト: ekyna/table
 /**
  * Generates the cells.
  *
  * @param TableView $view
  */
 private function generateCells(TableView $view)
 {
     $sortDirs = [ColumnSort::ASC, ColumnSort::DESC];
     $columns = $this->config->getColumns();
     foreach ($columns as &$columnOptions) {
         $key = $columnOptions['full_name'] . '_sort';
         $sortDir = $this->requestHelper->getVar($key, ColumnSort::NONE);
         $columnOptions['sorted'] = in_array($sortDir, $sortDirs);
     }
     unset($columnOptions);
     $this->data->first();
     while ($this->data->current()) {
         $row = new Row($this->getCurrentRowData('id'));
         // TODO getCurrentRowKey() ?
         foreach ($columns as $columnOptions) {
             $cell = new Cell();
             $type = $this->factory->getColumnType($columnOptions['type']);
             $type->buildViewCell($cell, $this, $columnOptions);
             $row->cells[] = $cell;
         }
         $view->rows[] = $row;
         $this->data->next();
     }
 }