Skip to content

Commit

Permalink
Add integration for app validation from the hosting bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelbox committed Oct 25, 2024
1 parent 825d99f commit 3cf2472
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.15.0
======

* (feature) Add integration for app validation from the hosting bundle.


3.14.3
======

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": ">= 8.3",
"21torr/bundle-helpers": "^2.1.2",
"21torr/cli": "^1.0",
"21torr/hosting": "^2.1 || ^3.0 || ^4.0",
"21torr/hosting": "^3.2 || ^4.0",
"psr/log": "^3.0",
"sebastian/diff": "^4.0.4 || ^5.0",
"symfony/console": "^7.0",
Expand Down
42 changes: 42 additions & 0 deletions src/Hosting/ValidateStoryblokConfigListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php declare(strict_types=1);

namespace Torr\Storyblok\Hosting;

use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Torr\Hosting\Event\ValidateAppEvent;
use Torr\Storyblok\Api\ContentApi;
use Torr\Storyblok\Exception\Config\InvalidConfigException;

/**
* @final
*/
readonly class ValidateStoryblokConfigListener
{
/**
*
*/
public function __construct (
private ContentApi $contentApi,
) {}

/**
*
*/
#[AsEventListener]
public function onValidateApp (ValidateAppEvent $event) : void
{
$io = $event->io;
$io->write("• Checking Storyblok configuration ... ");

try
{
$this->contentApi->getSpaceInfo();
$io->writeln("<fg=green>valid</>");
}
catch (InvalidConfigException)
{
$io->writeln("<fg=red>invalid</>");
$event->markAppAsInvalid("Storyblok Config");
}
}
}

0 comments on commit 3cf2472

Please sign in to comment.