Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: Paweł
- * Date: 2015-10-10
- * Time: 13:34
- */
- namespace console\rbac;
- use yii\rbac\Rule;
- /**
- * Checks if authorID matches user passed via params
- */
- class AuthorRule extends Rule
- {
- public $name = 'isAuthor';
- /**
- * @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)
- {
- return isset($params['post']) ? $params['post']->id_user == $user : false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement