| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace FL\Assistant\Data\Transformers; |
| 5 |
|
| 6 |
use FL\Assistant\Data\Repository\LabelsRepository; |
| 7 |
|
| 8 |
class LabelsTransformer { |
| 9 |
|
| 10 |
protected $labels; |
| 11 |
|
| 12 |
public function __construct( LabelsRepository $labels ) { |
| 13 |
$this->labels = $labels; |
| 14 |
} |
| 15 |
|
| 16 |
public function __invoke( \WP_Term $term ) { |
| 17 |
return [ |
| 18 |
'id' => $term->term_id, |
| 19 |
'label' => $term->name, |
| 20 |
'slug' => $term->slug, |
| 21 |
'color' => get_term_meta( $term->term_id, $this->labels::FL_ASST_NOTATION_COLOR, true ), |
| 22 |
]; |
| 23 |
} |
| 24 |
} |
| 25 |
|