FEATURE: move user roles into separate enumeration.

This commit moves list of user roles into separate class (with own namespace), so we can access this data anywhere from application.
This commit is contained in:
Michal Kváček
2016-01-24 20:43:41 +01:00
parent 7a08a11497
commit 8fcc5d041c
3 changed files with 48 additions and 8 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Enumerations;
use App\Models\User;
class UserRoles
{
/**
* Getter for roles
*
* This method returns only list of roles as inserted into database
*
* @return array
*/
public static function getSimple()
{
return array_values(self::getWithTranslations());
}
/**
* Getter for roles with translations
*
* This method returns all user roles as keys. Values are strings used for translations.
*
* @return array
*/
public static function getWithTranslations()
{
return [
User::ROLE_ADMIN => 'admin/userManagement.role_' . User::ROLE_ADMIN,
User::ROLE_EDITOR => 'admin/userManagement.role_' . User::ROLE_EDITOR,
User::ROLE_VISITOR => 'admin/userManagement.role_' . User::ROLE_VISITOR
];
}
}