[Bridge] [Twig] AppVariable: get and flush only flash sessions you need in getFlashes method
This commit is contained in:
parent
bc93526731
commit
ff82cb29bb
@ -174,6 +174,13 @@ class AppVariable
|
||||
return $session->getFlashBag()->get($types);
|
||||
}
|
||||
|
||||
return array_intersect_key($session->getFlashBag()->all(), array_flip($types));
|
||||
$result = array();
|
||||
foreach ($types as $type) {
|
||||
if ($value = $session->getFlashBag()->get($type)) {
|
||||
$result[$type] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -212,6 +212,11 @@ class AppVariableTest extends TestCase
|
||||
array('notice' => $flashMessages['notice'], 'error' => $flashMessages['error']),
|
||||
$this->appVariable->getFlashes(array('notice', 'error'))
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array('warning' => $flashMessages['warning']),
|
||||
$this->appVariable->getFlashes(array('warning'))
|
||||
);
|
||||
}
|
||||
|
||||
protected function setRequestStack($request)
|
||||
|
Reference in New Issue
Block a user