Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
update transformer to make it compatible with a newer fractal version (
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed May 29, 2024
2 parents a6d8786 + b29ebde commit 5f9d381
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"source": "https://github.com/cebe/yii2-openapi"
},
"require": {
"php": ">=7.2.0",
"php": "^7.4 || ^8.0",
"cebe/php-openapi": "^1.5.0",
"yiisoft/yii2": "~2.0.48",
"yiisoft/yii2-gii": "~2.0.0 | ~2.1.0 | ~2.2.0| ~2.3.0",
Expand Down
8 changes: 4 additions & 4 deletions src/generator/default/transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
class <?=$transformer->name?> extends TransformerAbstract
{
<?php if (!empty($transformer->availableRelations)):?>
protected $availableIncludes = ['<?=implode("', '", $transformer->availableRelations)?>'];
protected array $availableIncludes = ['<?=implode("', '", $transformer->availableRelations)?>'];
<?php else:?>
protected $availableIncludes = [];
protected array $availableIncludes = [];
<?php endif;?>
<?php if (!empty($transformer->defaultRelations)):?>
protected $defaultIncludes = ['<?=implode("', '", $transformer->defaultRelations)?>'];
protected array $defaultIncludes = ['<?=implode("', '", $transformer->defaultRelations)?>'];
<?php else:?>
protected $defaultIncludes = [];
protected array $defaultIncludes = [];
<?php endif;?>

public function transform(<?=$transformer->dbModel->getClassName()?> $model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

class CategoryTransformer extends TransformerAbstract
{
protected $availableIncludes = ['posts'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['posts'];
protected array $defaultIncludes = [];

public function transform(Category $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class CommentTransformer extends TransformerAbstract
{
protected $availableIncludes = ['post', 'user'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['post', 'user'];
protected array $defaultIncludes = [];

public function transform(Comment $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class PostTagTransformer extends TransformerAbstract
{
protected $availableIncludes = ['post', 'tag'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['post', 'tag'];
protected array $defaultIncludes = [];

public function transform(PostTag $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class PostTransformer extends TransformerAbstract
{
protected $availableIncludes = ['category', 'author', 'comments', 'postTags'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['category', 'author', 'comments', 'postTags'];
protected array $defaultIncludes = [];

public function transform(Post $model)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/blog_jsonapi/transformers/base/TagTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

class TagTransformer extends TransformerAbstract
{
protected $availableIncludes = ['postTags'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['postTags'];
protected array $defaultIncludes = [];

public function transform(Tag $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class UserTransformer extends TransformerAbstract
{
protected $availableIncludes = [];
protected $defaultIncludes = [];
protected array $availableIncludes = [];
protected array $defaultIncludes = [];

public function transform(User $model)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/many2many/transformers/PhotoTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PhotoTransformer extends TransformerAbstract
{
protected $availableIncludes = ['postsAttaches', 'postsGallery', 'photosPosts', 'targets', 'articles', 'posts'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['postsAttaches', 'postsGallery', 'photosPosts', 'targets', 'articles', 'posts'];
protected array $defaultIncludes = [];

public function transform(Photo $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class Photos2PostsTransformer extends TransformerAbstract
{
protected $availableIncludes = ['photo', 'post'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['photo', 'post'];
protected array $defaultIncludes = [];

public function transform(Photos2Posts $model)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/many2many/transformers/PostTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PostTransformer extends TransformerAbstract
{
protected $availableIncludes = ['postsAttaches', 'postsGallery', 'postsPhotos', 'tags', 'attaches', 'images', 'photos'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['postsAttaches', 'postsGallery', 'postsPhotos', 'tags', 'attaches', 'images', 'photos'];
protected array $defaultIncludes = [];

public function transform(Post $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PostsAttachesTransformer extends TransformerAbstract
{
protected $availableIncludes = ['attach', 'target'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['attach', 'target'];
protected array $defaultIncludes = [];

public function transform(PostsAttaches $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PostsGalleryTransformer extends TransformerAbstract
{
protected $availableIncludes = ['image', 'article'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['image', 'article'];
protected array $defaultIncludes = [];

public function transform(PostsGallery $model)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/many2many/transformers/TagTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class TagTransformer extends TransformerAbstract
{
protected $availableIncludes = ['posts'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['posts'];
protected array $defaultIncludes = [];

public function transform(Tag $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class DoctorTransformer extends TransformerAbstract
{
protected $availableIncludes = [];
protected $defaultIncludes = [];
protected array $availableIncludes = [];
protected array $defaultIncludes = [];

public function transform(Doctor $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PetStatisticTransformer extends TransformerAbstract
{
protected $availableIncludes = ['parentPet', 'favoritePets', 'topDoctors'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['parentPet', 'favoritePets', 'topDoctors'];
protected array $defaultIncludes = [];

public function transform(PetStatistic $model)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/petstore_jsonapi/transformers/PetTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PetTransformer extends TransformerAbstract
{
protected $availableIncludes = ['duplicates', 'doctor'];
protected $defaultIncludes = [];
protected array $availableIncludes = ['duplicates', 'doctor'];
protected array $defaultIncludes = [];

public function transform(Pet $model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PersonWatchTransformer extends TransformerAbstract
{
protected $availableIncludes = [];
protected $defaultIncludes = [];
protected array $availableIncludes = [];
protected array $defaultIncludes = [];

public function transform(PersonWatch $model)
{
Expand Down

0 comments on commit 5f9d381

Please sign in to comment.