Skip to content

Commit

Permalink
Merge pull request #28 from superbrave/exporter-doc
Browse files Browse the repository at this point in the history
Fixed the exporter documentation
  • Loading branch information
Jelle van Oosterbosch authored Sep 19, 2018
2 parents d208554 + 21ad6fb commit 73fc513
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 30 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/SuperbraveGdprExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('services.exporter.types.yml');
$loader->load('services.anonymizer.types.yml');
}
}
22 changes: 22 additions & 0 deletions Resources/config/services.exporter.types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
_defaults:
public: false

superbrave_gdpr.exporter.serializer.normalizer.export_annotation:
class: Superbrave\GdprBundle\Serializer\Normalizer\AnnotationNormalizer
arguments:
- "@superbrave_gdpr.annotation.reader"
- "Superbrave\\GdprBundle\\Annotation\\Export"
- "@superbrave_gdpr.property_manipulator"
tags:
- { name: "superbrave_gdpr.serializer.normalizer" }

superbrave_gdpr.exporter.serializer.encoder.xml:
class: Symfony\Component\Serializer\Encoder\XmlEncoder
tags:
- { name: "superbrave_gdpr.serializer.encoder" }

superbrave_gdpr.exporter.serializer.encoder.json:
class: Symfony\Component\Serializer\Encoder\JsonEncoder
tags:
- { name: "superbrave_gdpr.serializer.encoder" }
19 changes: 0 additions & 19 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@ services:
- !tagged "superbrave_gdpr.serializer.normalizer"
- !tagged "superbrave_gdpr.serializer.encoder"

superbrave_gdpr.exporter.serializer.normalizer.export_annotation:
class: Superbrave\GdprBundle\Serializer\Normalizer\AnnotationNormalizer
arguments:
- "@superbrave_gdpr.annotation.reader"
- "Superbrave\\GdprBundle\\Annotation\\Export"
- "@superbrave_gdpr.property_manipulator"
tags:
- { name: "superbrave_gdpr.serializer.normalizer" }

superbrave_gdpr.exporter.serializer.encoder.xml:
class: Symfony\Component\Serializer\Encoder\XmlEncoder
tags:
- { name: "superbrave_gdpr.serializer.encoder" }

superbrave_gdpr.exporter.serializer.encoder.json:
class: Symfony\Component\Serializer\Encoder\JsonEncoder
tags:
- { name: "superbrave_gdpr.serializer.encoder" }

superbrave_gdpr.property_accessor:
class: Symfony\Component\PropertyAccess\PropertyAccessor

Expand Down
22 changes: 11 additions & 11 deletions Resources/doc/anonymizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Provides an annotation for anonymizing objects based on specific anonymization t

## Registering new anonymizers

You can create your own anonymizers and register them in the compiler pass by tagging the service.
You can create your own anonymizers and add them to the compiler pass by tagging the service.
The `type` parameter specifies the name to be used in the `type` parameter of the annotation.

```yml
Expand All @@ -23,7 +23,7 @@ your_bundle_name.your_anonymizer:
- { name: superbrave_gdpr.anonymizer, type: your_type }
```
The example above will register an anonymizer with the name `your_type`. You can then use it as followed:
The example above will add an anonymizer with the name `your_type`. You can then use it as followed:
```@GDPR\Anonymize(type="your_type")```

## Usage
Expand Down Expand Up @@ -56,7 +56,7 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="fixed", value="anonymized")
*/
protected $value;
private $value;
```

##### Advanced fixed value
Expand All @@ -78,7 +78,7 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="fixed", value="firstName-{id}")
*/
protected $firstName;
private $firstName;
```

#### Type: dateTime
Expand All @@ -95,7 +95,7 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="dateTime")
*/
protected $createdAt;
private $createdAt;
```

#### Type: ip
Expand All @@ -112,7 +112,7 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="ip")
*/
protected $ipAddress;
private $ipAddress;
```

#### Type: null
Expand All @@ -129,7 +129,7 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="null")
*/
protected $city;
private $city;
```

#### Type: object
Expand All @@ -148,7 +148,7 @@ class Order
*
* @GDPR\Anonymize(type="ip")
*/
protected $ipAddress;
private $ipAddress;
}
```

Expand All @@ -162,7 +162,7 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="object")
*/
protected $order;
private $order;
```

#### Type: collection
Expand All @@ -181,7 +181,7 @@ class Order
*
* @GDPR\Anonymize(type="ip")
*/
protected $ipAddress;
private $ipAddress;
}
```

Expand All @@ -195,5 +195,5 @@ use Superbrave\GdprBundle\Annotation as GDPR;
*
* @GDPR\Anonymize(type="collection")
*/
protected $orders;
private $orders;
```
84 changes: 84 additions & 0 deletions Resources/doc/exporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Exporter

Provides an annotation for exporting object data to a specific format

## Exporter encoder types

- xml
- json

## Register new normalizers

You can create your own normalizers and add them to the compiler pass by tagging the service.

```yml
your_bundle_name.your_normalizer:
class: Your\Class\To\Your\Normalizer
tags:
- { name: superbrave_gdpr.serializer.normalizer }
```
## Register new encoders
You can create your own encoders and register them to the compiler pass by tagging the service.
```yml
your_bundle_name.your_encoder:
class: Your\Class\To\Your\Encoder
tags:
- { name: superbrave_gdpr.serializer.encoder }
```
## Usage
You can export objects by using the exporter service:
```php
<?php

$this->get('superbrave_gdpr.exporter')->exportObject($object, $objectName, $format);
```

## Examples

#### Annotations

Setting annotations on the object. Only the marked properties are being exported. If you mark an object, you also need to put annotations on properties of the object.

```php
<?php

use Superbrave\GdprBundle\Annotation as GDPR;

class Order
{
/**
* @var int
*
* @GDPR\Export()
*/
private $id;

/**
* @var Product
*
* @GDPR\Export()
*/
private $product;
}

class Product
{
/**
* @var int
*/
private $id;

/**
* @var int
*
* @GDPR\Export()
*/
private $name;
}
```

0 comments on commit 73fc513

Please sign in to comment.