PHP code example of blomstra / gdpr

1. Go to this page and download the library: Download blomstra/gdpr 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/ */

    

blomstra / gdpr example snippets


Flarum\Gdpr\Jobs\GdprJob::$onQueue = 'low';

return [
    ... your current extenders,
];



use Flarum\Gdpr\Extend\UserData;
use Flarum\Extend;

return [
    (new Extend\Conditional())
        ->whenExtensionEnabled('flarum-gdpr', fn () => [
            (new UserData())
                ->addType(Your\Own\DataType::class),

            ... other conditional extenders as 

use Flarum\Gdpr\Extend\UserData;
use Flarum\Extend;

return [
    (new Extend\Conditional())
        ->whenExtensionEnabled('flarum-gdpr', fn () => [
            (new UserData())
                ->removeType(Your\Own\DataType::class),

            ... other conditional extenders as 

use Flarum\Gdpr\Extend\UserData;

return [
    (new Extend\Conditional())
        ->whenExtensionEnabled('flarum-gdpr', fn () => [
            (new UserData())
                ->removeUserColumns(['column1', 'column2']),

            ... other conditional extenders as 

use Flarum\Gdpr\Data\Type;

class MyData extends Type
{
    public static function piiFields(): array
    {
        return ['custom_field', 'another_pii_field'];
    }

    // ... export(), anonymize(), delete() ...
}

use Flarum\Gdpr\Extend\UserData;

return [
    (new Extend\Conditional())
        ->whenExtensionEnabled('flarum-gdpr', fn () => [
            (new UserData())
                ->addPiiKeysForSerialization(['custom_field', 'another_pii_field']),
        ]),
];

use Flarum\Extension\ExtensionManager;
use Flarum\Gdpr\DataProcessor;

$extensions = resolve(ExtensionManager::class);

if ($extensions->isEnabled('flarum-gdpr')) {
    $piiKeys = resolve(DataProcessor::class)->getPiiKeysForSerialization();
} else {
    // Fallback covering common fields — used when flarum/gdpr is not installed.
    $piiKeys = ['email', 'username', 'ip_address', 'last_ip_address'];
}

// Recursively redact PII from your serialized payload before sending externally.
$anonymizedPayload = redactKeys($payload, $piiKeys);