Skip to content

Instantly share code, notes, and snippets.

@onmotion
Created November 1, 2016 10:06
Show Gist options
  • Save onmotion/795387d075a0c9057f42d7a1a86be4f2 to your computer and use it in GitHub Desktop.
Save onmotion/795387d075a0c9057f42d7a1a86be4f2 to your computer and use it in GitHub Desktop.
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