Chris@0: services[] = $id; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Invoked by the terminate kernel event. Chris@0: * Chris@0: * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event Chris@0: * The event object. Chris@0: */ Chris@0: public function onKernelTerminate(PostResponseEvent $event) { Chris@0: foreach ($this->services as $id) { Chris@0: // Check if the service was initialized during this request, destruction Chris@0: // is not necessary if the service was not used. Chris@0: if ($this->container->initialized($id)) { Chris@0: $service = $this->container->get($id); Chris@0: $service->destruct(); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Registers the methods in this class that should be listeners. Chris@0: * Chris@0: * @return array Chris@0: * An array of event listener definitions. Chris@0: */ Chris@0: public static function getSubscribedEvents() { Chris@17: $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 100]; Chris@0: return $events; Chris@0: } Chris@0: Chris@0: }