diff --git a/src/Event/PostManifestBuildEvent.php b/src/Event/PostManifestBuildEvent.php new file mode 100644 index 0000000..e96dd56 --- /dev/null +++ b/src/Event/PostManifestBuildEvent.php @@ -0,0 +1,28 @@ +manifest = $manifest; + } + + public function getManifest(): Manifest + { + return $this->manifest; + } +} + diff --git a/src/Event/PreManifestBuildEvent.php b/src/Event/PreManifestBuildEvent.php new file mode 100644 index 0000000..abdedb0 --- /dev/null +++ b/src/Event/PreManifestBuildEvent.php @@ -0,0 +1,26 @@ +config = $config; + } + + public function getConfig(): array + { + return $this->config; + } +} diff --git a/src/Service/ManifestBuilder.php b/src/Service/ManifestBuilder.php index f478471..aa86fa6 100644 --- a/src/Service/ManifestBuilder.php +++ b/src/Service/ManifestBuilder.php @@ -5,6 +5,9 @@ namespace SpomkyLabs\PwaBundle\Service; use SpomkyLabs\PwaBundle\Dto\Manifest; +use SpomkyLabs\PwaBundle\Event\PostManifestBuildEvent; +use SpomkyLabs\PwaBundle\Event\PreManifestBuildEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use function assert; @@ -17,6 +20,7 @@ final class ManifestBuilder */ public function __construct( private readonly DenormalizerInterface $denormalizer, + private readonly null|EventDispatcherInterface $dispatcher, private readonly array $config, ) { } @@ -24,8 +28,10 @@ public function __construct( public function create(): Manifest { if ($this->manifest === null) { + $this->dispatcher->dispatch(new PreManifestBuildEvent($this->config)); $result = $this->denormalizer->denormalize($this->config, Manifest::class); assert($result instanceof Manifest); + $this->dispatcher->dispatch(new PostManifestBuildEvent($this->manifest)); $this->manifest = $result; }