Example #1
0
 /**
  * Setup before fetching elements
  * Override if predefined keys must be changed
  *
  * @param array $data Data from request (GET, POST, session ...)
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 public function populate($data)
 {
     if (!empty($data['page'])) {
         $this->pagination->setPageNum($data['page']);
     }
     if (!empty($data['perPage'])) {
         $this->pagination->setPerPage($data['perPage']);
     }
     if (!empty($data['filterOption']) && !empty($data['filterValue'])) {
         $option = $this->getOption($data['filterOption']);
         $option->setFilter($data['filterValue']);
     }
     if (!empty($data['sorterOption']) && !empty($data['sorterDir'])) {
         $option = $this->getOption($data['sorterOption']);
         $option->setDir($data['sorterDir']);
     }
     return $this;
 }