public function run(ApplicationInterface $app) { $response = $app->getResponse(); if (!$response) { throw new Exception(sprintf('Cannot filter response ContentType against "%s" because no response has been set', $this->getFilter()->join(', '))); } $contentTypes = $response->getHeader('Content-Type'); $result = false; $this->getFilter()->each(function ($filter) use($contentTypes, &$result) { foreach ($contentTypes as $contentType) { if (strpos($contentType, $filter) === 0) { $result = true; break; } } }); return $result; }
/** * @param ApplicationInterface $app */ public function __invoke(ApplicationInterface $app) { $response = $app->getResponse(); $emitter = new SapiEmitter(); $emitter->emit($response); }