Yii2 RBAC auth_rule example

I am looking for a clear-cut example of Yii2 auth_rule scenario where an author can only update, delete his own posts.

I see a lot of role/assignment example but non on the auth_rule.

The guide in Yii2 website shows the concept but not how to exactly go about.

Thnx

example by memory:




public function execute($user, $item, $params) {

   $myARModel = $params[...];

  return $user == $mARModel->owner_id;

}






if (Yii::app->user->can(<MY_RBAC_ITEM>, array('myARModel' => $myARModel))) {

 ...

}



Thnx Sergey for the quick reply.

So the function text will reside in the data column and the MY_RBAC_ITEM will be the value of name column in the auth_rule table ?

Thnx again.