documentation/Transformers/transformer-structure.md
2023-11-22 21:58:33 +01:00

38 lines
1.1 KiB
Markdown

# Transformer Structure
To create a custom ActivityPub Transformer start by creating a class that extends the `\Activitypub\Transformer\Base` class and fill in all the required methods.
Each transformer needs to have a few basic settings — a unique name that will identify the transformer, a label that will be used as the title when being displayed in the settings section, and a list of supported post types that the transformer can use as an input.
## Transformer Class
First, we need to create a class that extends the `\Activitypub\Transformer\Base` class:
```php
class Activitypub_Test_Transformer extends \Activitypub\Transformer\Base {
}
```
## Transformer Methods
A simple transformer skeleton class will look as follows:
```php
class Activitypub_Test_Transformer extends \Activitypub\Transformer\Base {
public function get_name() {}
public function get_label() {}
public function get_object_type() {}
public function supported_post_types() {}
public function to_object() {}
// TODO
}
```
The `\Activitypub\Transformer\Base` class has many more methods, but the vast majority of your needs are covered by the methods mentioned above.
// TODO