setono / sylius-consent-management-plugin
Consent management plugin for Sylius
Package info
github.com/Setono/SyliusConsentManagementPlugin
Type:sylius-plugin
pkg:composer/setono/sylius-consent-management-plugin
Fund package maintenance!
Requires
- php: >=8.1
- ext-json: *
- dbrekelmans/bdi: ^1.4
- doctrine/collections: ^1.6
- doctrine/orm: ^2.15
- doctrine/persistence: ^3.0
- fakerphp/faker: ^1.9
- knplabs/knp-menu: ^3.1
- league/uri: ^6.8
- league/uri-components: ^2.4
- league/uri-interfaces: ^2.3
- php-webdriver/webdriver: ^1.15
- psr/event-dispatcher: ^1.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- setono/bot-detection-bundle: ^1.13
- setono/client: ^1.1
- setono/client-bundle: ^1.1
- setono/composite-compiler-pass: ^1.2
- setono/consent-bundle: ^1.2
- setono/consent-contracts: ^1.1
- setono/doctrine-orm-trait: ^1.1
- setono/sylius-static-contexts-bundle: ^1.0
- stof/doctrine-extensions-bundle: ^1.6
- sylius/channel: ^1.0
- sylius/channel-bundle: ^1.0
- sylius/core: ^1.0
- sylius/core-bundle: ^1.0
- sylius/grid-bundle: ^1.0
- sylius/locale: ^1.0
- sylius/locale-bundle: ^1.0
- sylius/mailer-bundle: ^1.0 || ^2.0
- sylius/resource-bundle: ^1.11
- sylius/ui-bundle: ^1.0
- symfony/browser-kit: ^6.4 || ^7.0
- symfony/config: ^6.4 || ^7.0
- symfony/console: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/doctrine-bridge: ^6.4 || ^7.0
- symfony/event-dispatcher: ^6.4 || ^7.0
- symfony/form: ^6.4 || ^7.0
- symfony/http-foundation: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/options-resolver: ^6.4 || ^7.0
- symfony/panther: ^2.2
- symfony/process: ^6.4 || ^7.0
- symfony/routing: ^6.4 || ^7.0
- symfony/security-bundle: ^6.4 || ^7.0
- symfony/security-http: ^6.4 || ^7.0
- symfony/service-contracts: ^2.5 || ^3.5
- symfony/string: ^6.4 || ^7.0
- symfony/translation-contracts: ^1.1 || ^2.4 || ^3.3
- symfony/workflow: ^6.4 || ^7.0
- twig/twig: ^2.12 || ^3.0
- webmozart/assert: ^1.11
Requires (Dev)
- api-platform/core: ^2.7
- babdev/pagerfanta-bundle: ^3.8
- behat/behat: ^3.14
- doctrine/doctrine-bundle: ^2.7
- jms/serializer-bundle: ^4.2
- lexik/jwt-authentication-bundle: ^2.17
- php-http/message-factory: ^1.1
- psalm/plugin-symfony: ^5.2
- setono/sylius-plugin-pack: ^1.12
- symfony/debug-bundle: ^6.4 || ^7.0
- symfony/dotenv: ^6.4 || ^7.0
- symfony/intl: ^6.4 || ^7.0
- symfony/property-info: ^6.4 || ^7.0
- symfony/serializer: ^6.4 || ^7.0
- symfony/web-profiler-bundle: ^6.4 || ^7.0
- symfony/webpack-encore-bundle: ^1.17
- weirdan/doctrine-psalm-plugin: ^2.9
- willdurand/negotiation: ^3.1
README
This plugin will create a consent dialog that every user will see. The user is given the option to accept all 'services' or necessary services.
Installation
composer require setono/sylius-consent-management-plugin
Register bundle
Add the bundle to bundles.php if not done automatically. Be sure to add this line before Sylius\Bundle\GridBundle\SyliusGridBundle::class
Setono\SyliusConsentManagementPlugin\SetonoSyliusConsentManagementPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
Install assets
php bin/console assets:install
Add migration
php bin/console doctrine:migration:diff php bin/console doctrine:migration:migrate
Import the routes
Create the file config/routes/setono_sylius_consent_management.yaml and add the following:
# config/routes/setono_sylius_consent_management.yaml setono_sylius_consent_management: resource: "@SetonoSyliusConsentManagementPlugin/Resources/config/routes.yaml"
If your store doesn't use locales, there's also a route file for that:
# config/routes/setono_sylius_consent_management.yaml setono_sylius_consent_management: resource: "@SetonoSyliusConsentManagementPlugin/Resources/config/routes_no_locale.yaml"
Update the layout
For everything to work there are two Twig functions you need to call: sscm_resources() and sscm_widget().
The sscm_resources() should be called in your <head> section while the sscm_widget() should be called just before
the </body>.
The sscm_resources() function will output the JS and CSS needed to render the widget. It will only output what's
necessary, so you don't have to worry about bloating your page with unused JS or CSS.
The sscm_widget() will output the actual HTML needed to render the widget. It's also true for this function that it
will only render what's necessary, so in this case if the user has already seen the widget, it will output an empty string.