| 1 | <?php |
||
| 21 | trait byLevel |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Authorization levels. |
||
| 25 | * Level names should not contain only digits. |
||
| 26 | * |
||
| 27 | * <code> |
||
| 28 | * protected static $levels = [ |
||
| 29 | * 'user' => 1, |
||
| 30 | * 'moderator' => 100, |
||
| 31 | * 'admin' => 1000 |
||
| 32 | * ]; |
||
| 33 | * </code> |
||
| 34 | * |
||
| 35 | * @var array |
||
| 36 | */ |
||
| 37 | protected static $levels; |
||
| 38 | |||
| 39 | |||
| 40 | /** |
||
| 41 | * Get all access levels. |
||
| 42 | * |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public static function getLevels() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Get access level |
||
| 57 | * |
||
| 58 | * @param string $name Level name |
||
| 59 | * @return int |
||
| 60 | */ |
||
| 61 | public static function getLevel($name) |
||
| 68 | } |
||
| 69 |