public function __construct(Form $form, $request) { $this->form = $form; $this->request = $request; $this->entity = $this->form->getEntity(); $this->primaryKey = $this->form->getPrimaryKey(); $this->filter['columns'] = $this->form->getListArrayColumns(); switch ($this->request['METHOD']) { case 'POST': $this->filter['columnsSelected'] = $this->request['filter']['columnsSelected']; $this->filter['valuesSelected'] = $this->request['filter']['valuesSelected']; $this->filter['flags'] = isset($this->request['filter']['flags']) ? $this->request['filter']['flags'] : ''; break; case 'GET': $this->filter['columnsSelected'] = array(); $this->filter['valuesSelected'] = array(); $this->filter['flags'] = array(); break; } // El criterio de ordenacion concreto seleccionado en el request // Si no se ha seleccionado ninguno (cuando se entra al controlador por el método listAction con GET) // se pone el primer criterio de ordenación indicado en el config.yml. Y si tampoco hubiera nada // se pone la primaryKey. $this->filter['orderBy'] = $this->request['filter']['orderBy']; if ($this->filter['orderBy'] == '') { $criteriosOrden = $this->form->getListOrderBy(); if (is_array($criteriosOrden) and count($criteriosOrden) > 0) { $this->filter['orderBy'] = $criteriosOrden[0]['criteria']; } else { $this->filter['orderBy'] = $form->getPrimaryKey() . " ASC"; } } // Criterios de ordenacion definidos en config.yml de cada modulo $this->filter['columnsOrder'] = $this->form->getListOrderBy(); // Número de página a mostrar $this->filter['page'] = $this->request['filter']['page']; if ($this->filter['page'] <= 0) { $this->filter['page'] = 1; } // Número de resgistros por página a mostrar $this->filter['recordsPerPage'] = $this->request['filter']['recordsPerPage']; if ($this->filter['recordsPerPage'] <= 0) { $this->filter['recordsPerPage'] = $this->form->getListRecordsPerPage(); } // Filtros adicionales $this->filter['aditional'] = $this->form->getFilters(); foreach ($this->filter['aditional'] as $key => $value) { if ($value['entity'] != '' and $value['type'] == 'select') { $claseConId = explode(',', $value['entity']); if (class_exists($claseConId[0])) { $objeto = new $claseConId[0](isset($claseConId[1]) ? $claseConId[1] : ""); } $this->filter['aditional'][$key]['values'] = $objeto->{$value['method']}($value['params']); //$this->filter['aditional'][$key]['values'][] = array('Id' => '', 'Value' => '** Todo **'); } } // Los títulos de las columnas a mostrar en el listado $this->titles = $this->form->getListTitleColumns(); }