drago-ex/authorization

简单的动态访问控制列表管理。

v1.0.28 2024-01-12 07:20 UTC

README

简单的动态访问控制列表管理。

License: MIT PHP version Tests Coding Style CodeFactor Coverage Status

技术

  • PHP 8.1或更高版本
  • Bootstrap
  • composer

安装

composer require drago-ex/authorization

扩展注册

extensions:
	- Drago\Authorization\DI\AuthorizationExtension

在基展示器中使用特性实现访问控制

use Drago\Authorization\Authorization

// Add redirect to sign in presenter or module
private string $loginLink = ':Module:Presenter:';

在展示器中使用特性实现设置访问控制

use Drago\Authorization\Control\AuthorizationControl

组件创建和配置

// Minimum configuration.
protected function createComponentPermissionsControl(): PermissionsControl
{
	return $this->permissionsControl;
}

protected function createComponentRolesControl(): RolesControl
{
	return $this->rolesControl;
}

protected function createComponentResourcesControl(): ResourcesControl
{
	return $this->resourcesControl;
}

protected function createComponentPrivilegesControl(): PrivilegesControl
{
	return $this->privilegesControl;
}

protected function createComponentAccessControl(): AccessControl
{
	return $this->accessControl;
}

// Configure a custom template.
$control->templateControl = __DIR__ . '/path/to/file.latte';
$control->templateGrid = __DIR__ . '/path/to/file.latte';


// Inserting a translator.
$control->translator = $this->getTranslator();

在latte中使用组件

{control permissionsControl}
{control rolesControl}
{control resourcesControl}
{control privilegesControl}
{control accessControl}