From 18193b0bc4c3c368a982f1b7033cd36c9a09e644 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 24 Aug 2022 16:35:43 -0500 Subject: [PATCH 1/2] Add support for curl options and fail curl on error in the TileLayer construct and getTile function. --- src/TileLayer.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/TileLayer.php b/src/TileLayer.php index 160ae37..df4a455 100644 --- a/src/TileLayer.php +++ b/src/TileLayer.php @@ -44,17 +44,31 @@ public static function defaultTileLayer(): TileLayer */ protected $opacity = 1; + /** + * @array $curlOptions Array of curl options + */ + protected $curlOptions = []; + + /** + * @bool $failCurlOnError If true, curl will throw an exception on error. + */ + protected $failCurlOnError = false; + /** * TileLayer constructor * @param string $url tile server url with placeholders (`x`, `y`, `z`, `r`, `s`) * @param string $attributionText tile server attribution text * @param string $subdomains tile server subdomains + * @param array $curlOptions Array of curl options + * @param bool $failCurlOnError If true, curl will throw an exception on error. */ - public function __construct(string $url, string $attributionText, string $subdomains = 'abc') + public function __construct(string $url, string $attributionText, string $subdomains = 'abc', array $curlOptions = [], bool $failCurlOnError = false) { $this->url = $url; $this->attributionText = $attributionText; $this->subdomains = \str_split($subdomains); + $this->curlOptions = $curlOptions; + $this->failCurlOnError = $failCurlOnError; } /** @@ -115,7 +129,7 @@ public function getTile(float $x, float $y, int $z): Image return Image::newCanvas(256, 256); } - $tile = Image::fromCurl($this->getTileUrl($x, $y, $z)); + $tile = Image::fromCurl($this->getTileUrl($x, $y, $z),$this->curlOptions, $this->failCurlOnError); if($this->opacity > 0 && $this->opacity < 1) { $tile->setOpacity($this->opacity); From e037af651233bc18997a782817e0c1bf4e2d51da Mon Sep 17 00:00:00 2001 From: Franck Alary Date: Wed, 9 Nov 2022 11:21:16 +0100 Subject: [PATCH 2/2] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ac9cf92..4e471a5 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ ], "require": { "php": ">=7.0", - "dantsu/php-image-editor": "^1.2" + "dantsu/php-image-editor": "^1.3" }, "autoload": { "psr-4": {