Only load icon file if an icon exists (Fix #44).

This commit is contained in:
David Molineus
2017-05-04 14:31:31 +02:00
parent 8920be6649
commit 722e17b29c

View File

@@ -71,6 +71,13 @@ class BootSubscriber implements EventSubscriberInterface
*/ */
private $definitionMapper; private $definitionMapper;
/**
* Flag for loading icon file.
*
* @var bool
*/
private $loadIconFile = false;
/** /**
* BootSubscriber constructor. * BootSubscriber constructor.
* *
@@ -190,8 +197,11 @@ class BootSubscriber implements EventSubscriberInterface
public function loadAssets() public function loadAssets()
{ {
$this->assets->addJavascript('assets/leaflet/maps/contao-leaflet.js', ContaoAssets::TYPE_FILE); $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); $this->assets->addJavascript('assets/leaflet/js/icons.js', ContaoAssets::TYPE_FILE);
} }
}
/** /**
* Load icons. * Load icons.
@@ -233,6 +243,8 @@ class BootSubscriber implements EventSubscriberInterface
$file = new \File('assets/leaflet/js/icons.js'); $file = new \File('assets/leaflet/js/icons.js');
$file->write($buffer); $file->write($buffer);
$file->close(); $file->close();
$this->loadIconFile = true;
} }
} }