setono/consent-bundle

A Symfony bundle that integrates the consent contracts

Maintainers

πŸ‘ loevgaard

Package info

github.com/Setono/ConsentBundle

Type:symfony-bundle

pkg:composer/setono/consent-bundle

Statistics

Installs: 62 767

Dependents: 4

Suggesters: 0

Stars: 3

Open Issues: 0

v1.2.0 2025-01-13 14:18 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT fec8280a1c36e9f266e0a195eae720a0ff8581ac

  • Joachim LΓΈvgaard <joachim.woop@loevgaard.dk>

This package is auto-updated.

Last update: 2026-06-13 18:02:22 UTC


README

πŸ‘ Latest Version
πŸ‘ Software License
πŸ‘ Build Status
πŸ‘ Code Coverage
πŸ‘ Mutation testing

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

Consents

The default configuration has all (default) consents (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:
 consents:
 marketing: true
 preferences: true
 statistics: true
 random_consent: true # you can easily add your own consents

The above configuration will effectively change the default consent to true for all permissions.

Consent checker

If you want to use a different consent checker, you can easily do so by implementing the ConsentCheckerInterface and setting your own service id as the consent checker:

# config/packages/setono_consent.yaml
setono_consent:
 consent_checker: <your service id>

Usage

The bundle provides a StaticConsentChecker that uses the above consents array as an input. You can then autowire the ConsentCheckerInterface and check for a granted consent:

<?php
use Setono\Consent\Consents;
use Setono\Consent\ConsentCheckerInterface;

final class YourMarketingTrackingService
{
 private ConsentCheckerInterface $consentChecker;
 
 public function __construct(ConsentCheckerInterface $consentChecker) {
 $this->consentChecker = $consentChecker;
 }
 
 public function track(): void
 {
 if(!$this->consentChecker->isGranted(Consents::CONSENT_MARKETING)) {
 return;
 }
 
 // do your marketing tracking
 }
}