Assignment.php 1.4 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
{
	/**
Qiang Xue committed
26
	 * @var Manager the auth manager of this item
27
	 */
Qiang Xue committed
28
	public $manager;
29
	/**
Qiang Xue committed
30
	 * @var string the business rule associated with this assignment
31
	 */
Qiang Xue committed
32
	public $bizRule;
33
	/**
Qiang Xue committed
34
	 * @var mixed additional data for this assignment
35
	 */
Qiang Xue committed
36
	public $data;
37
	/**
Qiang Xue committed
38 39
	 * @var mixed user ID (see [[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.
40
	 */
Qiang Xue committed
41
	public $userId;
42
	/**
Qiang Xue committed
43 44
	 * @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.
45
	 */
Qiang Xue committed
46
	public $itemName;
47 48 49 50 51 52

	/**
	 * Saves the changes to an authorization assignment.
	 */
	public function save()
	{
Qiang Xue committed
53
		$this->manager->saveAssignment($this);
54
	}
55
}