-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration for app validation from the hosting bundle
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
====== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |