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
f46b51ea
Commit
f46b51ea
authored
Apr 07, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better executeRule implementation.
parent
a16c2eb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
Manager.php
framework/rbac/Manager.php
+12
-6
No files found.
framework/rbac/Manager.php
View file @
f46b51ea
...
...
@@ -9,6 +9,7 @@ namespace yii\rbac;
use
Yii
;
use
yii\base\Component
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidParamException
;
/**
...
...
@@ -145,16 +146,21 @@ abstract class Manager extends Component
* @param string $ruleName name of the rule to be executed.
* @param array $params parameters passed to [[Manager::checkAccess()]].
* @param mixed $data additional data associated with the authorization item or assignment.
* @return boolean whether the rule execution returns true.
*
If the rule is empty, it will still return tru
e.
* @return boolean whether the rule execution returns true.
If `$ruleName` is null, true will be returned.
*
@throws InvalidConfigException if `$ruleName` does not correspond to a valid rul
e.
*/
public
function
executeRule
(
$ruleName
,
$params
,
$data
)
{
$rule
=
$this
->
getRule
(
$ruleName
);
if
(
$rule
)
{
return
$rule
->
execute
(
$params
,
$data
);
if
(
$ruleName
!==
null
)
{
$rule
=
$this
->
getRule
(
$ruleName
);
if
(
$rule
instanceof
Rule
)
{
return
$rule
->
execute
(
$params
,
$data
);
}
else
{
throw
new
InvalidConfigException
(
"Rule not found:
$ruleName
"
);
}
}
else
{
return
true
;
}
return
true
;
}
/**
...
...
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