/** * Takes an array of Role. * Parse each key of the $perms array * and add the entry 'role' where it is needed. * It's used when a workspace is imported * * @param array $baseRoles * @param array $perms * * @return array */ public function addRolesToPermsArray(array $baseRoles, array $perms) { $initializedArray = array(); foreach ($perms as $roleBaseName => $data) { foreach ($baseRoles as $baseRole) { if ($this->roleManager->getRoleBaseName($baseRole->getName()) === $roleBaseName) { $data['role'] = $baseRole; $initializedArray[$roleBaseName] = $data; } } } return $initializedArray; }