Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 9 |
| ParticipantUserRule | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 9 |
| execute | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 9 |
|||
| <?php | |
| namespace common\rbac; | |
| use common\models\Participant; | |
| use yii\rbac\Rule; | |
| /** | |
| * Checks if user have a supervisor entry | |
| */ | |
| class ParticipantUserRule extends Rule | |
| { | |
| public $name = 'isMyParticipant'; | |
| /** | |
| * @param string|integer $user the user ID. | |
| * @param Item $item the role or permission that this rule is associated with | |
| * @param array $params parameters passed to ManagerInterface::checkAccess(). | |
| * @return boolean a value indicating whether the rule permits the role or permission it is associated with. | |
| */ | |
| public function execute($user, $item, $params) | |
| { | |
| if(isset($params['participant']) && $params['participant'] instanceof Participant){ | |
| $participant = Participant::findOne(['user_id' => $user]); | |
| if($participant !== null){ | |
| return $params['participant']->id === $participant->id; | |
| } | |
| } | |
| return false; | |
| } | |
| } |