Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
f1aeac5d
Commit
f1aeac5d
authored
Aug 18, 2014
by
restyler
Committed by
Qiang Xue
Aug 18, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addFlash method was implemented
parent
3d2cac53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
Session.php
framework/web/Session.php
+23
-1
No files found.
framework/web/Session.php
View file @
f1aeac5d
...
...
@@ -717,13 +717,35 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
{
$counters
=
$this
->
get
(
$this
->
flashParam
,
[]);
$counters
[
$key
]
=
$removeAfterAccess
?
-
1
:
0
;
$_SESSION
[
$key
]
=
$value
;
$_SESSION
[
$this
->
flashParam
]
=
$counters
;
}
/**
* Appends new flash message to the specified key.
* @param string $key the key identifying the flash message.
* @param mixed $value flash message
* @param boolean $removeAfterAccess whether the flash message should be automatically removed only if
* it is accessed. If false, the flash message will be automatically removed after the next request,
* regardless if it is accessed or not. If true (default value), the flash message will remain until after
* it is accessed.
* @throws InvalidParamException if exising session variable is not array.
* @see getFlash()
* @see removeFlash()
*/
public
function
addFlash
(
$key
,
$value
=
true
,
$removeAfterAccess
=
true
)
{
$counters
=
$this
->
get
(
$this
->
flashParam
,
[]);
$counters
[
$key
]
=
$removeAfterAccess
?
-
1
:
0
;
if
(
!
empty
(
$_SESSION
[
$key
]))
{
// If it's not an array, convert it to array
if
(
!
is_array
(
$_SESSION
[
$key
]))
{
$_SESSION
[
$key
]
=
[
$_SESSION
[
$key
]];
}
$_SESSION
[
$key
][]
=
$value
;
}
else
{
$_SESSION
[
$key
]
=
[
$value
];
}
$_SESSION
[
$this
->
flashParam
]
=
$counters
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment