/**
  * Contains common output behavior here based on columns definitions.
  *
  * @param $row
  * @param AbstractTable $table
  *
  * @return mixed
  */
 public function formatRow($row, AbstractTable $table)
 {
     $cols = $table->getColumns();
     $newRow = [];
     foreach ($cols as $colIdentifier => $column) {
         $rawValue = array_key_exists($colIdentifier, $row) ? $row[$colIdentifier] : "";
         if ($column->getOptions()['auto_escape']) {
             $value = htmlentities($rawValue, ENT_COMPAT | ENT_HTML401, 'UTF-8');
         } else {
             $value = $rawValue;
         }
         $colVal = $column->formatCell($value, $row);
         //Column definition
         $newRow[$colIdentifier] = $colVal;
     }
     return $newRow;
 }
 public static function fromHttpRequest(Request $request, AbstractTable $table)
 {
     $table->getFilterForm()->handleRequest($request);
     $numericOrder = $request->get('order', []);
     $colnameOrder = [];
     //Limit: support single column ordering
     if (!empty($numericOrder[0]) && !empty($numericOrder[0]['column'])) {
         $colIndex = 0;
         $sortColIndex = $numericOrder[0]['column'];
         foreach ($table->getColumns() as $colid => $column) {
             if ($sortColIndex == $colIndex) {
                 $colnameOrder[$colid] = $numericOrder[0]['dir'];
             }
             $colIndex++;
         }
     }
     return new static($request->get('start', 0), $request->get('length', 10), $request->get('search', []), $table->getFilterForm(), $request->get('columns', []), $colnameOrder);
 }
 public function render(AbstractTable $table)
 {
     $viewVars = $table->buildView();
     $jsonVars = [];
     $jsonVars['recordsTotal'] = $viewVars['unfilteredRowsCount'];
     if ($viewVars['filteredRowsCount'] !== false) {
         $jsonVars['recordsFiltered'] = $viewVars['filteredRowsCount'];
     } else {
         $jsonVars['recordsFiltered'] = $viewVars['unfilteredRowsCount'];
     }
     $jsonVars['data'] = array_map(function ($item) {
         $t = [];
         foreach ($item as $k => $v) {
             $t[] = $v;
         }
         return $t;
     }, $viewVars['data']);
     return json_encode($jsonVars);
 }
 public function render(AbstractTable $table)
 {
     $template = $this->twig->loadTemplate($table->getOptions()['template']);
     return $template->render($table->buildView());
 }