mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 11:04:08 +01:00
Only load icon file if an icon exists (Fix #44).
This commit is contained in:
@@ -71,6 +71,13 @@ class BootSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
private $definitionMapper;
|
||||
|
||||
/**
|
||||
* Flag for loading icon file.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $loadIconFile = false;
|
||||
|
||||
/**
|
||||
* BootSubscriber constructor.
|
||||
*
|
||||
@@ -190,8 +197,11 @@ class BootSubscriber implements EventSubscriberInterface
|
||||
public function loadAssets()
|
||||
{
|
||||
$this->assets->addJavascript('assets/leaflet/maps/contao-leaflet.js', ContaoAssets::TYPE_FILE);
|
||||
|
||||
if ($this->loadIconFile) {
|
||||
$this->assets->addJavascript('assets/leaflet/js/icons.js', ContaoAssets::TYPE_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load icons.
|
||||
@@ -233,6 +243,8 @@ class BootSubscriber implements EventSubscriberInterface
|
||||
$file = new \File('assets/leaflet/js/icons.js');
|
||||
$file->write($buffer);
|
||||
$file->close();
|
||||
|
||||
$this->loadIconFile = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user