Created
November 1, 2016 10:06
-
-
Save onmotion/795387d075a0c9057f42d7a1a86be4f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function behaviors() | |
{ | |
return [ | |
'access' => [ | |
'class' => AccessControl::className(), | |
'rules' => [ | |
[ | |
'actions' => ['update'], | |
'allow' => true, | |
'matchCallback' => function ($rule, $action) { | |
$model = $this->findModel(Yii::$app->getRequest()->get('id')); | |
return Yii::$app->getUser()->can('updateOwnPost', ['model' => $model]); | |
} | |
], | |
] | |
] | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment