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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
8a436c4a
Commit
8a436c4a
authored
Nov 20, 2013
by
Kartik Visweswaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup.
Removed redundant declarations and checks in the code.
parent
c5506285
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
23 deletions
+4
-23
Alert.php
apps/advanced/frontend/widgets/Alert.php
+4
-23
No files found.
apps/advanced/frontend/widgets/Alert.php
View file @
8a436c4a
...
@@ -7,10 +7,6 @@
...
@@ -7,10 +7,6 @@
namespace
frontend\widgets
;
namespace
frontend\widgets
;
use
yii\helpers\Html
;
use
yii\bootstrap\Widget
;
use
yii\bootstrap\Alert
as
BsAlert
;
/**
/**
* Alert widget renders a message from session flash. All flash messages are displayed
* Alert widget renders a message from session flash. All flash messages are displayed
* in the sequence they were assigned using setFlash. You can set message as following:
* in the sequence they were assigned using setFlash. You can set message as following:
...
@@ -22,7 +18,7 @@ use yii\bootstrap\Alert as BsAlert;
...
@@ -22,7 +18,7 @@ use yii\bootstrap\Alert as BsAlert;
* @author Alexander Makarov <sam@rmcerative.ru>
* @author Alexander Makarov <sam@rmcerative.ru>
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @author Kartik Visweswaran <kartikv2@gmail.com>
*/
*/
class
Alert
extends
Widget
class
Alert
extends
\yii\bootstrap\
Widget
{
{
/**
/**
* @var array the allowed bootstrap alert types.
* @var array the allowed bootstrap alert types.
...
@@ -34,38 +30,23 @@ class Alert extends Widget
...
@@ -34,38 +30,23 @@ class Alert extends Widget
*/
*/
public
$closeButton
=
[];
public
$closeButton
=
[];
private
$_doNotRender
=
true
;
public
function
init
()
public
function
init
()
{
{
$this
->
_doNotRender
=
true
;
$session
=
\Yii
::
$app
->
getSession
();
$session
=
\Yii
::
$app
->
getSession
();
$flashes
=
$session
->
getAllFlashes
();
$appendCss
=
isset
(
$this
->
options
[
'class'
])
?
$this
->
options
[
'class'
]
:
''
;
$baseCssClass
=
isset
(
$this
->
options
[
'class'
])
?
$this
->
options
[
'class'
]
:
''
;
foreach
(
$flashes
as
$type
=>
$message
)
{
foreach
(
$flashes
as
$type
=>
$message
)
{
if
(
in_array
(
$type
,
$this
->
allowedTypes
))
{
if
(
in_array
(
$type
,
$this
->
allowedTypes
))
{
$this
->
options
[
'class'
]
=
((
$type
===
'error'
)
?
"alert-danger"
:
"alert-
{
$type
}
"
)
.
' '
.
$baseCssCla
ss
;
$this
->
options
[
'class'
]
=
((
$type
===
'error'
)
?
'alert-danger'
:
'alert-'
.
$type
)
.
' '
.
$appendC
ss
;
echo
Bs
Alert
::
widget
([
echo
\yii\bootstrap\
Alert
::
widget
([
'body'
=>
$message
,
'body'
=>
$message
,
'closeButton'
=>
$this
->
closeButton
,
'closeButton'
=>
$this
->
closeButton
,
'options'
=>
$this
->
options
'options'
=>
$this
->
options
]);
]);
Html
::
removeCssClass
(
$this
->
options
,
$class
);
$session
->
removeFlash
(
$type
);
$session
->
removeFlash
(
$type
);
$this
->
_doNotRender
=
false
;
$this
->
_doNotRender
=
false
;
}
}
}
}
if
(
!
$this
->
_doNotRender
)
{
parent
::
init
();
parent
::
init
();
}
}
}
public
function
run
()
{
if
(
!
$this
->
_doNotRender
)
{
parent
::
run
();
}
}
}
}
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