Esempio n. 1
0
        $size = (int) $size;
        if ($size >= 16 && $size <= 1000) {
            $url = $context->assets->getUrl('assets/logo' . ($size < 60 ? '-small' : '') . '.png', ['width' => $size, 'height' => $size]);
            $path = str_replace($app->request->base, '', $url);
            $response = new App\Response\FileReader($app->assets->getFilename($path));
            $response->setContentType('image/png');
            $response->setMaxAge(86400);
            return $response;
        }
    }
    return new App\Response\NotFound();
});
// Route for the image used by the social networks
$app->routes->add('/assets/socialimage', function () use($context) {
    $response = new App\Response\FileReader($context->dir . 'assets/social-image.png');
    $response->setContentType('image/png');
    $response->setMaxAge(86400);
    return $response;
});
// Update the response
$app->hooks->add('responseCreated', function ($response) use($app, $context) {
    $addTemplate = false;
    if ($response instanceof App\Response\NotFound) {
        $response->setContentType('text/html');
        $response->content = $app->components->process('<component src="file:' . $context->dir . 'components/systempage.php" text="Page not found" />');
        $addTemplate = true;
    } elseif ($response instanceof App\Response\TemporaryUnavailable) {
        $response->setContentType('text/html');
        $response->content = $app->components->process('<component src="file:' . $context->dir . 'components/systempage.php" text="Temporary unavailable. Try again in few moments." />');
        $addTemplate = true;
    }