-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from superbrave/exporter-doc
Fixed the exporter documentation
- Loading branch information
Showing
5 changed files
with
118 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
``` |