Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
php: ['8.1', '8.2']
php: ['8.2']

steps:
- name: Checkout Code
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
3.6.0
=====

* (improvement) Bump dependencies.
* (feature) Add `ComponentAssetsHelper` to easily generate component preview screenshot URLs.


3.5.1
=====

Expand Down
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
}
],
"require": {
"php": ">= 8.1",
"php": ">= 8.2",
"21torr/bundle-helpers": "^2.1.2",
"21torr/cli": "^1.0",
"psr/log": "^3.0",
"symfony/console": "^6.1",
"symfony/http-client": "^6.1",
"symfony/lock": "^6.2",
"symfony/rate-limiter": "^6.2",
"symfony/string": "^6.2",
"symfony/validator": "^6.1"
"symfony/asset": "^6.3",
"symfony/console": "^6.3",
"symfony/http-client": "^6.3",
"symfony/http-foundation": "^6.3",
"symfony/lock": "^6.3",
"symfony/rate-limiter": "^6.3",
"symfony/string": "^6.3",
"symfony/validator": "^6.3"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^10.4",
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^6.1.6"
"symfony/phpunit-bridge": "^6.3"
},
"autoload": {
"psr-4": {
Expand Down
22 changes: 22 additions & 0 deletions src/Assets/ComponentAssetsHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);

namespace Torr\Storyblok\Assets;

use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
use Symfony\Component\HttpFoundation\UrlHelper;

final readonly class ComponentAssetsHelper
{
public function __construct (
private UrlHelper $urlHelper,
) {}

public function generatePreviewScreenshotUrl (string $subPath) : string
{
$cacheDate = new \DateTimeImmutable();
$package = new Package(new StaticVersionStrategy($cacheDate->format("U"), "%s?version=%s"));

return $this->urlHelper->getAbsoluteUrl($package->getUrl($subPath));
}
}