Assignment.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\rbac;
  8. use Yii;
  9. use yii\base\Object;
  10. /**
  11. * Assignment represents an assignment of a role to a user.
  12. * It includes additional assignment information such as [[bizRule]] and [[data]].
  13. * Do not create a Assignment instance using the 'new' operator.
  14. * Instead, call [[Manager::assign()]].
  15. *
  16. * @author Qiang Xue <[email protected]>
  17. * @author Alexander Kochetov <[email protected]>
  18. * @since 2.0
  19. */
  20. class Assignment extends Object
  21. {
  22. /**
  23. * @var Manager the auth manager of this item
  24. */
  25. public $manager;
  26. /**
  27. * @var string the business rule associated with this assignment
  28. */
  29. public $bizRule;
  30. /**
  31. * @var mixed additional data for this assignment
  32. */
  33. public $data;
  34. /**
  35. * @var mixed user ID (see [[User::id]]). Do not modify this property after it is populated.
  36. * To modify the user ID of an assignment, you must remove the assignment and create a new one.
  37. */
  38. public $userId;
  39. /**
  40. * @return string the authorization item name. Do not modify this property after it is populated.
  41. * To modify the item name of an assignment, you must remove the assignment and create a new one.
  42. */
  43. public $itemName;
  44. /**
  45. * Saves the changes to an authorization assignment.
  46. */
  47. public function save()
  48. {
  49. $this->manager->saveAssignment($this);
  50. }
  51. }