-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
Expected Behavior
When supplying the field "by_slugs" to a Stories Request, the parameter doesn't exist, but does exist on the Storyblok documentation.
Current Behavior
Currently, the Stories Request does not expose any way of querying a collection of stories by slugs only.
Steps to Reproduce
- The below code example will retrieve all stories with a full_slug starting with 'StoryFolderName'
use Storyblok\Api\StoriesApi;
use Storyblok\Api\StoryblokClient;
use Storyblok\Api\Domain\Value\Dto\Pagination;
use Storyblok\Api\Request\StoriesRequest;
$client = new StoryblokClient(/* ... */);
$storiesApi = new StoriesApi($client);
$response = $storiesApi->all(new StoriesRequest(
language: 'de',
pagination: new Pagination(page: 1, perPage: 30)
startsWith => new Slug('StoryFolderName/'),
));
- The below code, does not retrieve any stories by the slugs supplied
use Storyblok\Api\StoriesApi;
use Storyblok\Api\StoryblokClient;
use Storyblok\Api\Domain\Value\Dto\Pagination;
use Storyblok\Api\Domain\Value\Slug\SlugCollection;
use Storyblok\Api\Request\StoriesRequest;
$client = new StoryblokClient(/* ... */);
$storiesApi = new StoriesApi($client);
$response = $storiesApi->all(new StoriesRequest(
language: 'de',
pagination: new Pagination(page: 1, perPage: 30)
bySlugs => new SlugCollection(['StoryFolderName/*', 'StoryFolderName2/*']),
));
Proposed Fix
Add in the following code to StoriesRequest class construct:
public ?SlugCollection $bySlugs = new SlugCollection(),
The SlugCollection is used on the exclude_slugs parameter, which in essence, is the exact opposite of the by_slugs functionality.
And add in the follow code to the toArray method:
if ($this->bySlugs->count() > 0) {
$array['by_slugs'] = $this->bySlugs->toString();
}
Metadata
Metadata
Assignees
Labels
No labels