$role->
fromArray($params);
$this->modelManager->
persist($role);
$this->modelManager->
flush();
// Check if admin flag is set or unset
if ($params['admin'
] == true
) { Shopware()->
Db()->
query('
INSERT IGNORE INTO s_core_acl_roles (roleID,resourceID,privilegeID) VALUES (?,?,?)
',
[$role->
getId(), null, null
]);
} else { $query =
$this->
getUserRepository()->
getAdminRuleDeleteQuery($role->
getId());
$query->
execute();
} $this->
View()->
assign([ 'success' => true,
'data' =>
$this->modelManager->
toArray($role),
]);
} /**
* Get all roles available in database
* Strip roles that have parentID set - cause
* this roles are assigned to particular users
*
* Sample json return value
* <code>
* {"success":true,"data":[{"id":1,"parentId":null,"name":"Administrators","description":"Default group that gains access to all shop functions","source":"build-in","enabled":1,"admin":1},{"id":2,"parentId":null,"name":"Test-Group1A","description":"Group that has restricted access ","source":"test","enabled":0,"admin":0},{"id":3,"parentId":null,"name":"Test-Group2","description":"Group that has restricted access ","source":"test","enabled":0,"admin":0},{"id":4,"parentId":3,"name":"Test-Group3","description":"Group that has restricted access ","source":"test","enabled":1,"admin":0}],"total":4}
* </code>
*/