setono / consent-contracts
与同意相关的通用抽象
v1.0.0
2023-02-21 07:18 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.18
- setono/code-quality-pack: ^2.4
README
这个库作为处理库或应用程序中与同意相关实现的构建块。
安装
composer require setono/consent-contracts
用法
<?php use Setono\Consent\Consents; use Setono\Consent\ConsentCheckerInterface; final class YourService { private ConsentCheckerInterface $consentChecker; public function __construct(ConsentCheckerInterface $consentChecker) { $this->consentChecker = $consentChecker; } public function __invoke() { if ($this->consentChecker->isGranted(Consents::CONSENT_MARKETING)) { // marketing consent is granted, and you can set your marketing related cookie ;) } } }
默认同意检查器
此库还提供了两种 ConsentCheckerInterface
的实现,即 DenyAllConsentChecker
和 GrantAllConsentChecker
。如果您未实现同意管理系统,可以使用这两个来提供默认同意。