Assignment.php 1.51 KB
Newer Older
1 2 3 4 5 6 7
<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

8
namespace yii\rbac;
9 10 11 12 13

use Yii;
use yii\base\Object;

/**
14 15 16
 * Assignment represents an assignment of a role to a user.
 * It includes additional assignment information such as [[bizRule]] and [[data]].
 * Do not create a Assignment instance using the 'new' operator.
17
 * Instead, call [[Manager::assign()]].
18
 *
19 20 21 22
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @author Alexander Kochetov <creocoder@gmail.com>
 * @since 2.0
 */
23
class Assignment extends Object
24
{
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    /**
     * @var Manager the auth manager of this item
     */
    public $manager;
    /**
     * @var string the business rule associated with this assignment
     */
    public $bizRule;
    /**
     * @var mixed additional data for this assignment
     */
    public $data;
    /**
     * @var mixed user ID (see [[\yii\web\User::id]]). Do not modify this property after it is populated.
     * To modify the user ID of an assignment, you must remove the assignment and create a new one.
     */
    public $userId;
    /**
     * @return string the authorization item name. Do not modify this property after it is populated.
     *                To modify the item name of an assignment, you must remove the assignment and create a new one.
     */
    public $itemName;
47

48 49 50 51 52 53 54
    /**
     * Saves the changes to an authorization assignment.
     */
    public function save()
    {
        $this->manager->saveAssignment($this);
    }
55
}