✅
PWA Bundle
1.2.x
1.2.x
  • PHPWA Bundle
  • How To Create A PWA?
  • How To Install/Remove A PWA?
  • Bundle Installation
  • Development
  • Events
  • Deployment
  • Debugging
  • The Manifest
    • Application Information
      • Scope
      • ID
      • Direction and Language
      • Orientation
      • Description
      • IARC Rating ID
      • Categories
    • Icons
    • Screenshots
    • Shortcuts
    • Protocol Handlers
    • File Handlers
    • Share Target
    • Complete Example
  • The Service Worker
    • Configuration
    • Content Security Policy
    • Custom Service Worker Rule
    • Custom Cache Strategies
    • Workbox
      • Site Manifest Cache
      • Asset Caching
      • Resource Caching
      • Image Caching
      • Font Caching
      • Offline Fallbacks
      • BackgoundSync
      • CDN and Versions
      • Cache Cleaning
      • Custom Cache Strategy
    • Push Notifications
    • Complete Example
  • Favicons
    • Create Favicons
  • Symfony UX
    • Connection Status
    • Prefetch on demand
    • Sync Broadcast
    • BackgroundSync Form
  • Image Management
    • Icons
    • Screenshots
  • Experimental Features
    • Non-Standard Parameters
      • Launch Handler
      • Display Override
      • Related Applications
      • EDGE Side Panel
    • Translations
    • Widgets (Win10+)
Powered by GitBook
On this page

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:

src/EventListener\MyListener.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
    {
        // ...
    }
}
PreviousDevelopmentNextDeployment

Last updated 1 year ago