Provides an annotation for anonymizing objects based on specific anonymization types. Specific anonymization types can be created and registered with the compiler pass.
- fixed
- dateTime
- ip
- object
- collection
- null
You can create your own anonymizers and register them in the compiler pass by tagging the service:
your_bundle_name.your_anonymizer:
class: Your\Class\To\Your\Anonymizer
tags:
- { name: superbrave_gdpr.anonymizer, type: your_type }You can anonymize objects by using the anonymizer service:
<?php
$this->get('superbrave_gdpr.anonymizer')->anonymize($object);Anonymizes the property with a fixed value.
Setting a fixed value for the property.
<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @GDPR\Anonymize(type="fixed", value="anonymized")
*/
protected $value;Brackets can be used here to concat the fixed value with the value of a property on the object.
The value between the quotes has to be a property.
First a check is performed to determine if the property is public, if so that is used.
The second check is to determine whether or not the property has a getter, if so that is used.
If the checks above both failed it resorts back to a ReflectionProperty
<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @GDPR\Anonymize(type="fixed", value="firstName-{id}")
*/
protected $firstName;Anonymizes the date time field by setting the month and day to 01 and hours, minutes and seconds to 00.
<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @GDPR\Anonymize(type="dateTime")
*/
protected $createdAt;Anonymizes the ip address by zeroing the last bytes of an ipv4 or ipv6 address.
<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @GDPR\Anonymize(type="ip")
*/
protected $ipAddress;Anonymizes the property by setting it to null.
<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @GDPR\Anonymize(type="null")
*/
protected $city;The object type anonymizer is to indicate that the property is an actual object which itself can have annotations.
<?php
use SuperBrave\GdprBundle\Annotation AS GDPR;
class Order
{
/**
* @var string;
*
* @GDPR\Anonymize(type="ip")
*/
protected $ipAddress;
}<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @var Order
*
* @GDPR\Anonymize(type="object")
*/
protected $order;The collection type anonymizer is to indicate that the property is an collection of objects which itself can be anonymized.
<?php
use SuperBrave\GdprBundle\Annotation AS GDPR;
class Order
{
/**
* @var string;
*
* @GDPR\Anonymize(type="ip")
*/
protected $ipAddress;
}<?php
use SuperBrave\GdprBundle\Annotation as GDPR;
/**
* @var Order[]
*
* @GDPR\Anonymize(type="collection")
*/
protected $orders;