foowie / permission-checker
访问权限检查 & latte 模板宏
0.5.3
2023-08-03 17:19 UTC
Requires
- php: >=7.2
- latte/latte: ^2.10.8
- nette/nette: ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.9
- phpstan/phpstan-deprecation-rules: ^1.1.1
- phpstan/phpstan-nette: ^1.2.3
README
安装
在 config.neon 配置中包含扩展
extensions:
permission: Foowie\PermissionChecker\DI\PermissionExtension
并在您的基展示器中使用 PresenterPermissionTrait。
用法
您可以使用这些注解注解展示器类、动作、渲染方法和信号方法
@loggedIn - logged user is required
@loggedIn(false) - unlogged user is required
@role(superadmin, admin) - user must have role admin or superadmin
@resource(administration) - user must be assigned to administration resource
在模板文件中允许使用这些宏
{ifAllowed 'administration'}{/ifAllowed} - user must be assigned to administration resource
{ifAllowedLink ':Administration:Dashboard:'}{/ifAllowed} - user must be allowed to display that page
<a n:ifAllowedHref=':Administration:Dashboard:'></a> - user must be allowed to display that page, shorter alternative is "allowedHref"