Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.0.4 - WIP
- Adding `hasTags()`, `tagListAsString()`, `tagListAsArray()` methods for stories

## 1.0.3 - 2025-09-29
- Adding new parameter for duplicating space (for adding the space in the organization)
- Adding `update()` method for Space endpoint
Expand Down
22 changes: 22 additions & 0 deletions src/Data/StoryBaseData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,26 @@ public function hasWorkflowStage(): bool
$workflowStageId = $this->getInt('stage.workflow_stage_id', 0);
return $workflowStageId > 0;
}

public function hasTags(): bool
{
$tags = $this->getArray('tag_list', []);
return $tags !== [];
}

public function tagListAsString(): string
{
$tags = $this->getArray('tag_list', []);
return implode(", ", $tags);
}

/**
* Returns the list of tags as array.
*
* @return array<mixed>
*/
public function tagListAsArray(): array
{
return $this->getArray('tag_list', []);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/Data/one-story.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"full_slug": "posts/my-third-post",
"sort_by_date": null,
"position": 0,
"tag_list": [],
"tag_list": ["tag1","tag2"],
"is_startpage": false,
"parent_id": 440448337,
"meta_data": null,
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/StoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
->toBe("My third post")
->and($storyblokData->name())->toBe("My third post")
->and($storyblokData->createdAt())->toBe("2024-02-08")
->and($storyblokData->tagListAsArray())->toBe(["tag1", "tag2"])
->and($storyblokData->tagListAsString())->toBe("tag1, tag2")
->and($storyblokResponse->getResponseStatusCode())->toBe(200);

expect(function () use ($storyApi): void {
Expand Down