|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +declare(strict_types=1); |
| 8 | + |
7 | 9 | namespace Magento\User\Model\ResourceModel;
|
8 | 10 |
|
9 | 11 | use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
|
@@ -208,28 +210,27 @@ protected function _createUserRole($parentId, ModelUser $user)
|
208 | 210 | if ($parentId > 0) {
|
209 | 211 | /** @var \Magento\Authorization\Model\Role $parentRole */
|
210 | 212 | $parentRole = $this->_roleFactory->create()->load($parentId);
|
| 213 | + if ($parentRole->getId()) { |
| 214 | + $data = new \Magento\Framework\DataObject( |
| 215 | + [ |
| 216 | + 'parent_id' => $parentRole->getId(), |
| 217 | + 'tree_level' => $parentRole->getTreeLevel() + 1, |
| 218 | + 'sort_order' => 0, |
| 219 | + 'role_type' => RoleUser::ROLE_TYPE, |
| 220 | + 'user_id' => $user->getId(), |
| 221 | + 'user_type' => UserContextInterface::USER_TYPE_ADMIN, |
| 222 | + 'role_name' => $user->getFirstName(), |
| 223 | + ] |
| 224 | + ); |
| 225 | + |
| 226 | + $insertData = $this->_prepareDataForTable($data, $this->getTable('authorization_role')); |
| 227 | + $this->getConnection()->insert($this->getTable('authorization_role'), $insertData); |
| 228 | + $this->aclDataCache->clean(); |
| 229 | + } |
211 | 230 | } else {
|
212 | 231 | $role = new \Magento\Framework\DataObject();
|
213 | 232 | $role->setTreeLevel(0);
|
214 | 233 | }
|
215 |
| - |
216 |
| - if ($parentRole->getId()) { |
217 |
| - $data = new \Magento\Framework\DataObject( |
218 |
| - [ |
219 |
| - 'parent_id' => $parentRole->getId(), |
220 |
| - 'tree_level' => $parentRole->getTreeLevel() + 1, |
221 |
| - 'sort_order' => 0, |
222 |
| - 'role_type' => RoleUser::ROLE_TYPE, |
223 |
| - 'user_id' => $user->getId(), |
224 |
| - 'user_type' => UserContextInterface::USER_TYPE_ADMIN, |
225 |
| - 'role_name' => $user->getFirstName(), |
226 |
| - ] |
227 |
| - ); |
228 |
| - |
229 |
| - $insertData = $this->_prepareDataForTable($data, $this->getTable('authorization_role')); |
230 |
| - $this->getConnection()->insert($this->getTable('authorization_role'), $insertData); |
231 |
| - $this->aclDataCache->clean(); |
232 |
| - } |
233 | 234 | }
|
234 | 235 |
|
235 | 236 | /**
|
|
0 commit comments