Loading src/LeafletService.php +60 −34 Original line number Diff line number Diff line Loading @@ -62,6 +62,13 @@ class LeafletService { */ protected $requestStack; /** * Static cache for icon sizes. * * @var array */ protected $iconSizes = []; /** * Creates an absolute web-accessible URL string. * Loading Loading @@ -438,11 +445,17 @@ class LeafletService { * The feature. */ public function setFeatureIconSizesIfEmptyOrInvalid(array &$feature) { $icon_url = !empty($feature["icon"]["iconUrl"]) ? $this->generateAbsoluteString((string) $feature["icon"]["iconUrl"]) : NULL; $icon_url = $feature["icon"]["iconUrl"] ?? NULL; if (isset($icon_url) && isset($feature["icon"]["iconSize"]) && (empty(intval($feature["icon"]["iconSize"]["x"])) && empty(intval($feature["icon"]["iconSize"]["y"]))) && (!empty($feature["icon"]["iconUrl"]) && $this->fileExists($icon_url))) { && (!empty($feature["icon"]["iconUrl"]))) { // Use the cached IconSize is present for this Icon Url. if (isset($this->iconSizes[$feature["icon"]["iconUrl"]])) { $feature["icon"]["iconSize"]["x"] = $this->iconSizes[$feature["icon"]["iconUrl"]]["x"]; $feature["icon"]["iconSize"]["y"] = $this->iconSizes[$feature["icon"]["iconUrl"]]["y"]; } elseif ($this->fileExists($feature["icon"]["iconUrl"])) { $file_parts = pathinfo($icon_url); switch ($file_parts['extension']) { case "svg": Loading @@ -459,13 +472,22 @@ class LeafletService { $feature["icon"]["iconSize"]["y"] = $iconSize[1]; } } // Cache the IconSize, so we don't fetch the same icon multiple times. $this->iconSizes[$feature["icon"]["iconUrl"]] = $feature["icon"]["iconSize"]; } } $shadow_url = !empty($feature["icon"]["shadowUrl"]) ? $this->generateAbsoluteString($feature["icon"]["shadowUrl"]) : NULL; $shadow_url = $feature["icon"]["shadowUrl"] ?? NULL; if (isset($shadow_url) && isset($feature["icon"]["shadowSize"]) && (empty(intval($feature["icon"]["shadowSize"]["x"])) && empty(intval($feature["icon"]["shadowSize"]["y"]))) && (!empty($feature["icon"]["shadowUrl"]) && $this->fileExists($shadow_url))) { && (!empty($feature["icon"]["shadowUrl"]))) { // Use the cached Shadow IconSize is present for this Icon Url. if (isset($this->iconSizes[$feature["icon"]["shadowUrl"]])) { $feature["icon"]["shadowSize"]["x"] = $this->iconSizes[$feature["icon"]["shadowUrl"]]["x"]; $feature["icon"]["shadowSize"]["y"] = $this->iconSizes[$feature["icon"]["shadowUrl"]]["y"]; } elseif ($this->fileExists($feature["icon"]["shadowUrl"])) { $file_parts = pathinfo($shadow_url); switch ($file_parts['extension']) { case "svg": Loading @@ -482,6 +504,10 @@ class LeafletService { $feature["icon"]["shadowSize"]["y"] = $shadowSize[1]; } } // Cache the Shadow IconSize, so we don't fetch the same icon multiple // times. $this->iconSizes[$feature["icon"]["shadowUrl"]] = $feature["icon"]["shadowSize"]; } } } Loading Loading
src/LeafletService.php +60 −34 Original line number Diff line number Diff line Loading @@ -62,6 +62,13 @@ class LeafletService { */ protected $requestStack; /** * Static cache for icon sizes. * * @var array */ protected $iconSizes = []; /** * Creates an absolute web-accessible URL string. * Loading Loading @@ -438,11 +445,17 @@ class LeafletService { * The feature. */ public function setFeatureIconSizesIfEmptyOrInvalid(array &$feature) { $icon_url = !empty($feature["icon"]["iconUrl"]) ? $this->generateAbsoluteString((string) $feature["icon"]["iconUrl"]) : NULL; $icon_url = $feature["icon"]["iconUrl"] ?? NULL; if (isset($icon_url) && isset($feature["icon"]["iconSize"]) && (empty(intval($feature["icon"]["iconSize"]["x"])) && empty(intval($feature["icon"]["iconSize"]["y"]))) && (!empty($feature["icon"]["iconUrl"]) && $this->fileExists($icon_url))) { && (!empty($feature["icon"]["iconUrl"]))) { // Use the cached IconSize is present for this Icon Url. if (isset($this->iconSizes[$feature["icon"]["iconUrl"]])) { $feature["icon"]["iconSize"]["x"] = $this->iconSizes[$feature["icon"]["iconUrl"]]["x"]; $feature["icon"]["iconSize"]["y"] = $this->iconSizes[$feature["icon"]["iconUrl"]]["y"]; } elseif ($this->fileExists($feature["icon"]["iconUrl"])) { $file_parts = pathinfo($icon_url); switch ($file_parts['extension']) { case "svg": Loading @@ -459,13 +472,22 @@ class LeafletService { $feature["icon"]["iconSize"]["y"] = $iconSize[1]; } } // Cache the IconSize, so we don't fetch the same icon multiple times. $this->iconSizes[$feature["icon"]["iconUrl"]] = $feature["icon"]["iconSize"]; } } $shadow_url = !empty($feature["icon"]["shadowUrl"]) ? $this->generateAbsoluteString($feature["icon"]["shadowUrl"]) : NULL; $shadow_url = $feature["icon"]["shadowUrl"] ?? NULL; if (isset($shadow_url) && isset($feature["icon"]["shadowSize"]) && (empty(intval($feature["icon"]["shadowSize"]["x"])) && empty(intval($feature["icon"]["shadowSize"]["y"]))) && (!empty($feature["icon"]["shadowUrl"]) && $this->fileExists($shadow_url))) { && (!empty($feature["icon"]["shadowUrl"]))) { // Use the cached Shadow IconSize is present for this Icon Url. if (isset($this->iconSizes[$feature["icon"]["shadowUrl"]])) { $feature["icon"]["shadowSize"]["x"] = $this->iconSizes[$feature["icon"]["shadowUrl"]]["x"]; $feature["icon"]["shadowSize"]["y"] = $this->iconSizes[$feature["icon"]["shadowUrl"]]["y"]; } elseif ($this->fileExists($feature["icon"]["shadowUrl"])) { $file_parts = pathinfo($shadow_url); switch ($file_parts['extension']) { case "svg": Loading @@ -482,6 +504,10 @@ class LeafletService { $feature["icon"]["shadowSize"]["y"] = $shadowSize[1]; } } // Cache the Shadow IconSize, so we don't fetch the same icon multiple // times. $this->iconSizes[$feature["icon"]["shadowUrl"]] = $feature["icon"]["shadowSize"]; } } } Loading