setono / consent-bundle
A Symfony bundle that integrates the consent contracts
Installs: 9 431
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=7.4
- setono/client-id-bundle: ^0.2
- setono/consent-contracts: ^0.1.2
- symfony/config: ^4.4 || ^5.0
- symfony/console: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/http-foundation: ^4.4 || ^5.0.7
- symfony/http-kernel: ^4.4 || ^5.1.5
Requires (Dev)
- infection/infection: ^0.25.0
- matthiasnoback/symfony-config-test: ^4.3
- matthiasnoback/symfony-dependency-injection-test: ^4.3
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- psalm/plugin-symfony: ^3.0
- roave/security-advisories: dev-latest
- setono/code-quality-pack: ^2.1.3
This package is auto-updated.
Last update: 2022-04-24 14:47:23 UTC
README
This bundle integrates the consent contracts into Symfony.
Installation
composer require setono/consent-bundle
This installs and enables the plugin automatically if you're using Symfony Flex. If not, add the bundle manually
to bundles.php
.
Configuration
The default configuration has all permissions (marketing, preferences, and statistics) set to false
. If you want to
change these defaults, you can easily do so:
# config/packages/setono_consent.yaml setono_consent: marketing_granted: true preferences_granted: true statistics_granted: true
The above configuration will effectively changes the default consent to true
for all permissions.
Usage
The bundle provides a default consent context that you can easily inject and use inside your application:
<?php use Setono\Consent\Context\ConsentContextInterface; final class YourMarketingTrackingService { private ConsentContextInterface $consentContext; public function __construct(ConsentContextInterface $consentContext) { $this->consentContext = $consentContext; } public function track(): void { if(!$this->consentContext->getConsent()->isMarketingConsentGranted()) { return; } // do your marketing tracking } }