1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model;
/**
* Admin Role Model
*
* @api
* @method int getParentId()
* @method \Magento\Authorization\Model\Role setParentId(int $value)
* @method int getTreeLevel()
* @method \Magento\Authorization\Model\Role setTreeLevel(int $value)
* @method int getSortOrder()
* @method \Magento\Authorization\Model\Role setSortOrder(int $value)
* @method string getRoleType()
* @method \Magento\Authorization\Model\Role setRoleType(string $value)
* @method int getUserId()
* @method \Magento\Authorization\Model\Role setUserId(int $value)
* @method string getUserType()
* @method \Magento\Authorization\Model\Role setUserType(string $value)
* @method string getRoleName()
* @method \Magento\Authorization\Model\Role setRoleName(string $value)
* @api
* @since 100.0.2
*/
class Role extends \Magento\Framework\Model\AbstractModel
{
/**
* @var string
*/
protected $_eventPrefix = 'authorization_roles';
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Authorization\Model\ResourceModel\Role $resource
* @param \Magento\Authorization\Model\ResourceModel\Role\Collection $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Authorization\Model\ResourceModel\Role $resource,
\Magento\Authorization\Model\ResourceModel\Role\Collection $resourceCollection,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
/**
* {@inheritdoc}
*/
public function __sleep()
{
$properties = parent::__sleep();
return array_diff($properties, ['_resource', '_resourceCollection']);
}
/**
* {@inheritdoc}
*/
public function __wakeup()
{
parent::__wakeup();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->_resource = $objectManager->get(\Magento\Authorization\Model\ResourceModel\Role::class);
$this->_resourceCollection = $objectManager->get(
\Magento\Authorization\Model\ResourceModel\Role\Collection::class
);
}
/**
* Class constructor
*
* @return void
*/
protected function _construct()
{
$this->_init(\Magento\Authorization\Model\ResourceModel\Role::class);
}
/**
* Update object into database
*
* @return $this
*/
public function update()
{
$this->getResource()->update($this);
return $this;
}
/**
* Return users for role
*
* @return array
*/
public function getRoleUsers()
{
return $this->getResource()->getRoleUsers($this);
}
}