Skip to content

Commit 08e0eed

Browse files
committed
Tweak
1 parent 75c09a3 commit 08e0eed

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

session.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,16 @@ controllers if you type-hint an argument with
149149

150150
public function someMethod()
151151
{
152+
$session = $this->requestStack->getSession();
153+
152154
// stores an attribute in the session for later reuse
153-
$this->requestStack->getSession()->set('attribute-name', 'attribute-value');
155+
$session->set('attribute-name', 'attribute-value');
154156

155157
// gets an attribute by name
156-
$foo = $this->requestStack->getSession()->get('foo');
158+
$foo = $session->get('foo');
157159

158160
// the second argument is the value returned when the attribute doesn't exist
159-
$filters = $this->requestStack->getSession()->get('filters', []);
161+
$filters = $session->get('filters', []);
160162

161163
// ...
162164
}

0 commit comments

Comments
 (0)