Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Role.php
Go to the documentation of this file.
1 <?php
7 
30 {
34  protected $_eventPrefix = 'authorization_roles';
35 
43  public function __construct(
44  \Magento\Framework\Model\Context $context,
45  \Magento\Framework\Registry $registry,
46  \Magento\Authorization\Model\ResourceModel\Role $resource,
47  \Magento\Authorization\Model\ResourceModel\Role\Collection $resourceCollection,
48  array $data = []
49  ) {
50  parent::__construct($context, $registry, $resource, $resourceCollection, $data);
51  }
52 
56  public function __sleep()
57  {
59  return array_diff($properties, ['_resource', '_resourceCollection']);
60  }
61 
65  public function __wakeup()
66  {
69  $this->_resource = $objectManager->get(\Magento\Authorization\Model\ResourceModel\Role::class);
70  $this->_resourceCollection = $objectManager->get(
71  \Magento\Authorization\Model\ResourceModel\Role\Collection::class
72  );
73  }
74 
80  protected function _construct()
81  {
82  $this->_init(\Magento\Authorization\Model\ResourceModel\Role::class);
83  }
84 
90  public function update()
91  {
92  $this->getResource()->update($this);
93  return $this;
94  }
95 
101  public function getRoleUsers()
102  {
103  return $this->getResource()->getRoleUsers($this);
104  }
105 }
$objectManager
Definition: bootstrap.php:17
$resource
Definition: bulk.php:12
__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=[])
Definition: Role.php:43
$properties
Definition: categories.php:26