| Code Coverage | ||||||||||
| Classes and Traits | Functions and Methods | Lines | ||||||||
| Total |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 3 | CRAP |  | 0.00% | 0 / 7 | 
| RequestCloseSubscriber |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 3 | 12 |  | 0.00% | 0 / 7 | 
| __construct |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 2 | |||
| onTerminate |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 2 | |||
| getSubscribedEvents |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 3 | |||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\Core\EventSubscriber\RequestCloseSubscriber. | |
| */ | |
| namespace Drupal\Core\EventSubscriber; | |
| use Drupal\Core\Extension\ModuleHandlerInterface; | |
| use Symfony\Component\HttpKernel\KernelEvents; | |
| use Symfony\Component\HttpKernel\Event\PostResponseEvent; | |
| use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
| /** | |
| * Subscriber for all responses. | |
| */ | |
| class RequestCloseSubscriber implements EventSubscriberInterface { | |
| /** | |
| * @var \Drupal\Core\Extension\ModuleHandlerInterface | |
| */ | |
| protected $moduleHandler; | |
| /** | |
| * Constructs a new RequestCloseSubscriber instance. | |
| * | |
| * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler | |
| * The module handler. | |
| */ | |
| function __construct(ModuleHandlerInterface $module_handler) { | |
| $this->moduleHandler = $module_handler; | |
| } | |
| /** | |
| * Performs end of request tasks. | |
| * | |
| * @todo The body of this function has just been copied almost verbatim from | |
| * drupal_page_footer(). There's probably a lot in here that needs to get | |
| * removed/changed. Also, if possible, do more light-weight shutdowns on | |
| * AJAX requests. | |
| * | |
| * @param Symfony\Component\HttpKernel\Event\PostResponseEvent $event | |
| * The Event to process. | |
| */ | |
| public function onTerminate(PostResponseEvent $event) { | |
| $this->moduleHandler->writeCache(); | |
| } | |
| /** | |
| * Registers the methods in this class that should be listeners. | |
| * | |
| * @return array | |
| * An array of event listener definitions. | |
| */ | |
| static function getSubscribedEvents() { | |
| $events[KernelEvents::TERMINATE][] = array('onTerminate', 100); | |
| return $events; | |
| } | |
| } |