# assistant/0.3.1/backend/src/Data/Transformers/NotationsTransformer.php

Assistant – Every Day Productivity Apps, version 0.3.1. 44 lines.

- Page: https://pluginprobe.com/plugins/assistant/0.3.1/code/backend/src/Data/Transformers/NotationsTransformer.php
- Raw: https://pluginprobe.com/plugins/assistant/0.3.1/raw/backend/src/Data/Transformers/NotationsTransformer.php
- Modified: 2020-03-25T19:33:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/assistant/0.3.1/code/backend/src/Data/Transformers/NotationsTransformer.php#L10-L20`.

```php
<?php

namespace FL\Assistant\Data\Transformers;

use FL\Assistant\System\Contracts\TransformerAbstract;

class NotationsTransformer extends TransformerAbstract {

	public function __invoke( \WP_Post $post ) {
		$meta = get_post_custom( $post->ID );
		$type = $meta['fl_asst_notation_type'][0];
		$notation = [
			'id'          => $post->ID,
			'type'        => $type,
			'object_type' => $meta['fl_asst_notation_object_type'][0],
			'object_id'   => $meta['fl_asst_notation_object_id'][0],
		];

		if ( 'favorite' === $type ) {
			return $this->transform_favorite( $post, $notation );
		} elseif ( 'label' === $type ) {
			return $this->transform_label( $post, $notation );
		}

		return $notation;
	}

	public function transform_favorite( \WP_Post $post, $notation ) {
		return array_merge(
			$notation, [
				'user_id' => $post->post_author,
			]
		);
	}

	public function transform_label( \WP_Post $post, $notation ) {
		return array_merge(
			$notation, [
				'label_id' => (int) get_post_meta( $post->ID, 'fl_asst_notation_label_id', true ),
			]
		);
	}
}

```
