PHP code example of heimrichhannot / contao-privacy-bundle

1. Go to this page and download the library: Download heimrichhannot/contao-privacy-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-bundle example snippets


// this represents your function for sending the opt in email
$success = $this->sendOptInEmail($firstname, $lastname, $email);

// only create a protocol entry if the email has indeed been sent
if ($success)
{
    System::getContainer()->get(\HeimrichHannot\PrivacyBundle\Manager\ProtocolManager::class)->addEntryFromModuleByConfig(
        // the id of the privacy protocol config
        1,
        // the data you want to add to the protocol entry to be created
        // CAUTION: Do NOT store personal data for which you don't have the user's permission!
        [
            'firstname' => $firstname,
            'lastname'  => $lastname,
            'email'     => $email
        ],
        // the contao module you're calling from
        $this,
        // optional: composer package name of the bundle your module lives in (version is retrieved automatically from composer.lock)
        'acme/contao-my-bundle'
    );
}