From 0e8b79247819f12ce80f384bdb3571d7d60603aa Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 26 Feb 2019 02:46:30 +0300 Subject: [PATCH] Flextype Slim Integration - bootstrap - updates --- composer.json | 3 ++- flextype/bootstrap.php | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index bbaf345a..2dd63495 100755 --- a/composer.json +++ b/composer.json @@ -41,7 +41,8 @@ "flextype-components/text" : "1.1.2", "league/glide": "^1.4", "slim/slim": "^3.0", - "slim/twig-view": "^2.4" + "slim/twig-view": "^2.4", + "league/glide-slim": "^1.0" }, "autoload": { "classmap": [ diff --git a/flextype/bootstrap.php b/flextype/bootstrap.php index 94e6affd..963bc421 100755 --- a/flextype/bootstrap.php +++ b/flextype/bootstrap.php @@ -20,6 +20,8 @@ use Flextype\Component\Filesystem\Filesystem; use Thunder\Shortcode\ShortcodeFacade; use Slim\Http\Request; use Slim\Http\Response; +use League\Glide\ServerFactory; +use League\Glide\Responses\SlimResponseFactory; /** * The version of Flextype @@ -171,17 +173,14 @@ $flextype['images'] = function($container) { $api = new \League\Glide\Api\Api($imageManager, $manipulators); // Setup Glide server - $server = new \League\Glide\Server( - $source, - $cache, - $api - ); + $server = \League\Glide\ServerFactory::create([ + 'source' => $source, + 'cache' => $cache, + 'api' => $api, + 'response' => new SlimResponseFactory(), + ]); - return new \League\Glide\Server( - $source, - $cache, - $api - ); + return $server; }; /** @@ -232,12 +231,19 @@ $flextype['view'] = function ($container) { return $view; }; +/** + * Generates and returns the image reponse + */ +$app->get('/image/{path:.+}', function (Request $request, Response $response, array $args) use ($flextype) { + return $flextype['images']->getImageResponse($args['path'], $_GET); +}); /** * Init plugins */ $plugins = new Plugins($flextype, $app); + /** * Run application */