PHP code example of heimrichhannot / contao-privacy-protocol-bundle

1. Go to this page and download the library: Download heimrichhannot/contao-privacy-protocol-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

heimrichhannot / contao-privacy-protocol-bundle example snippets


use HeimrichHannot\PrivacyProtocolBundle\Protocol\PrivacyProtocolLogger;
use HeimrichHannot\PrivacyProtocolBundle\Protocol\ProtocolEntry;
use HeimrichHannot\PrivacyProtocolBundle\Protocol\ProtocolType;

class ExampleController
{
    public function __construct(
        private readonly PrivacyProtocolLogger $logger,
    ) {}
    
    public function __invoke()
    {
        // create a new protocol entry
        $entry = new ProtocolEntry(
            person: ['email' => '[email protected]',],
            target: ['dataContainer' => 'tl_mailing_list', 'id' => 43,],
            type: ProtocolType::FIRST_OPT_IN,
            archiveId: 2,
            packageName: 'vendor/example-bundle',
        );
        
        // add an optional description
        $entry->description = '[email protected] has subscribed to the mailing list with ID 43.';
        
        $this->logger->log($entry);
        
    }
}