foowie/permission-checker

访问权限检查 & latte 模板宏

0.5.3 2023-08-03 17:19 UTC

This package is auto-updated.

Last update: 2024-09-03 19:30:31 UTC


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"