From 86c3d0a0b1815ec4cf1c94b5bae896cdd4abb1a3 Mon Sep 17 00:00:00 2001 From: Jeremy Tubbs Date: Sun, 18 Nov 2018 10:38:56 -0500 Subject: [PATCH] update config loading --- composer.json | 2 +- config/iiif.php | 2 +- src/ImageFactory.php | 15 ++++++++------- src/ImageIIIF.php | 12 ++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 899ead1..ad498ca 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.1", - "hassankhan/config": "^1.0", + "hassankhan/config": "^2.0", "intervention/image": "^2.4" }, "require-dev": { diff --git a/config/iiif.php b/config/iiif.php index a3f7522..be539df 100644 --- a/config/iiif.php +++ b/config/iiif.php @@ -4,7 +4,7 @@ 'driver' => 'gd', //imagick - 'base_url' => 'http://packages.test', + 'base_url' => 'http://iiif.test', 'prefix' => 'iiif', diff --git a/src/ImageFactory.php b/src/ImageFactory.php index 3d49165..1663fb5 100644 --- a/src/ImageFactory.php +++ b/src/ImageFactory.php @@ -3,6 +3,7 @@ namespace Conlect\ImageIIIF; use Noodlehaus\Config; +use Noodlehaus\Parser\Json; use Intervention\Image\ImageManager; class ImageFactory @@ -14,19 +15,20 @@ class ImageFactory */ protected $driver = 'gd'; + protected $config; - public function __invoke(array $config = null) - { + public function __invoke(array $config = null) + { if (is_null($config)) { - $config = new Config(__DIR__ . '/../config'); + $config = new Config(__DIR__ . '/../config'); } else { - $config = new Config($config); + $config = new Config(json_encode($config), new Json, true); } $manager = $this->getImageManager($config['driver']); return new ImageIIIF($manager, $config); - } + } /** @@ -34,7 +36,7 @@ public function __invoke(array $config = null) * @return ImageManager */ public function getImageManager($driver = null) - { + { if (is_null($driver)) { $driver = $this->driver; } @@ -45,5 +47,4 @@ public function getImageManager($driver = null) ] ); } - } diff --git a/src/ImageIIIF.php b/src/ImageIIIF.php index 543b608..b00f3c0 100755 --- a/src/ImageIIIF.php +++ b/src/ImageIIIF.php @@ -20,7 +20,7 @@ public function __construct(ImageManager $manager, Config $config = null) } public function load($file) - { + { $this->image = $this->manager->make($file); return $this; @@ -55,20 +55,20 @@ public function info($identifier) { return [ '@context' => 'http://iiif.io/api/image/2/context.json', - '@id' => $this->config->get('base_url') . '/' . $this->config->get('prefix') . '/' . $identifier, + '@id' => $this->config['base_url'] . '/' . $this->config['prefix'] . '/' . $identifier, 'protocol' => 'http://iiif.io/api/image', 'height' => $this->image->height(), 'width' => $this->image->width(), 'profile' => [ 'http://iiif.io/api/image/2/level2.json', [ - 'supports' => config('iiif.supports'), - 'qualities' => config('iiif.qualities'), - 'formats' => config('iiif.formats') + 'supports' => $this->config['supports'], + 'qualities' => $this->config['qualities'], + 'formats' => $this->config['formats'] ] ], 'tiles'=> [ [ - 'width' => $this->config->get('tile_width'), + 'width' => $this->config['tile_width'], 'scaleFactors' => $this->getScaleFactors(), ] ],