# Events

Leveraging the PSR-14 Event Dispatcher within the bundle provides you an opportunity to fine-tune the manifest creation process by hooking into events dispatched before and after the manifest compilation. Below, you'll find how you can listen to these events and implement custom logic accordingly.

Events are:

* `SpomkyLabs\PwaBundle\Event\PreManifestCompileEvent`
* `SpomkyLabs\PwaBundle\Event\PostManifestCompileEvent`

Here's a basic structure for listening to both events:

{% code title="src/EventListener\MyListener.php" lineNumbers="true" %}

```php
namespace App\EventListener;

use SpomkyLabs\PwaBundle\Event\PreManifestCompileEvent;
use SpomkyLabs\PwaBundle\Event\PostManifestCompileEvent;

use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(event: PreManifestCompileEvent ::class, method: 'preCompile')]
#[AsEventListener(event: PostManifestCompileEvent::class, method: 'postCompile')]
final readonly class MyListener
{
    public function preCompile(PreManifestCompileEvent $event): void
    {
        // ...
    }

    public function postCompile(PostManifestCompileEvent $event): void
    {
        // ...
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pwa.spomky-labs.com/1.3.x/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
