src/Viserio/Component/Session/Provider/SessionServiceProvider.php
public static function extendEventManager(
        ContainerInterface $container,
        ?EventManagerContract $eventManager = null
    ): ?EventManagerContract {
        if ($eventManager !== null) {
            $eventManager->attach(TerminableContract::TERMINATE, static function (EventContract $event): void {
                /** @var StoreContract $driver */
                $driver = $event->getTarget()->getContainer()->get(SessionManager::class)->getDriver();

                if (! $driver->getHandler() instanceof CookieSessionHandler) {
                    $driver->save();
                }
            });
        }

        return $eventManager;
    }
public static function extendEventManager(
        ContainerInterface $container,
        ?EventManagerContract $eventManager = null
    ): ?EventManagerContract {
        if ($eventManager !== null) {
            $eventManager->attach(TerminableContract::TERMINATE, static function (EventContract $event): void {
                /** @var StoreContract $driver */
                $driver = $event->getTarget()->getContainer()->get(SessionManager::class)->getDriver();

                if (! $driver->getHandler() instanceof CookieSessionHandler) {
                    $driver->save();
                }
            });
        }

        return $eventManager;
    }
Extend viserio events with data collector.

@param \Psr\Container\ContainerInterface                    $container
@param null|\Viserio\Component\Contract\Events\EventManager $eventManager

@return null|\Viserio\Component\Contract\Events\EventManager