Skip to content

Commit

Permalink
Merge pull request #716 from plfort/mass-action-id-session
Browse files Browse the repository at this point in the history
Add MassActionColumn::ID in keys to be removed from session in getFilters
  • Loading branch information
Petit Yoann committed May 16, 2015
2 parents 312cdf9 + d084a5e commit e961c19
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Grid/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Grid
* @var string
*/
protected $defaultTweak;

/**
* Filters in session
* @var array
Expand Down Expand Up @@ -2008,7 +2008,7 @@ public function getRawData($columnNames = null, $namedIndexes = true)

return $result;
}

/**
* Returns an array of the active filters of the grid stored in session
*
Expand All @@ -2020,11 +2020,11 @@ public function getFilters()
if ($this->hash === null) {
throw new \Exception('getFilters method is only available in the manipulate callback function or after the call of the method isRedirected of the grid.');
}

if ($this->sessionFilters === null) {
$this->sessionFilters = array();
$session = $this->sessionData;

$requestQueries = array(
self::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED,
self::REQUEST_QUERY_MASS_ACTION,
Expand All @@ -2033,32 +2033,33 @@ public function getFilters()
self::REQUEST_QUERY_LIMIT,
self::REQUEST_QUERY_ORDER,
self::REQUEST_QUERY_TEMPLATE,
self::REQUEST_QUERY_RESET
self::REQUEST_QUERY_RESET,
MassActionColumn::ID,
);

foreach ($requestQueries as $request_query) {
unset($session[$request_query]);
}

foreach ($session as $columnId => $sessionFilter) {
if (isset($sessionFilter['operator'])) {
$operator = $sessionFilter['operator'];
unset($sessionFilter['operator']);
} else {
$operator = $this->getColumn($columnId)->getDefaultOperator();
}

if (! isset($sessionFilter['to'])) {
$sessionFilter = $sessionFilter['from'];
}

$this->sessionFilters[$columnId] = new Filter($operator, $sessionFilter);
}
}

return $this->sessionFilters;
}

/**
* Returns the filter of a column stored in session
*
Expand All @@ -2072,12 +2073,12 @@ public function getFilter($columnId)
if ($this->hash === null) {
throw new \Exception('getFilters method is only available in the manipulate callback function or after the call of the method isRedirected of the grid.');
}

$sessionFilters = $this->getFilters();

return isset($sessionFilters[$columnId]) ? $sessionFilters[$columnId] : null;
}

/**
* A filter of the column is stored in session ?
*
Expand All @@ -2091,7 +2092,7 @@ public function hasFilter($columnId)
if ($this->hash === null) {
throw new \Exception('hasFilters method is only available in the manipulate callback function or after the call of the method isRedirected of the grid.');
}

return getFilter($columnId) !== null;
}
}

0 comments on commit e961c19

Please sign in to comment.