forked from Snck3rs/contao-leaflet-maps
Use the assets manager.
This commit is contained in:
@@ -56,8 +56,8 @@ $container[LeafletServices::MAP_PROVIDER] = $container->share(function ($contain
|
|||||||
/*
|
/*
|
||||||
* Contao assets handler. Loads Leaflet assets as contao (static) assets.
|
* Contao assets handler. Loads Leaflet assets as contao (static) assets.
|
||||||
*/
|
*/
|
||||||
$container[LeafletServices::MAP_ASSETS] = $container->share(function () {
|
$container[LeafletServices::MAP_ASSETS] = $container->share(function ($container) {
|
||||||
return new ContaoAssets();
|
return new ContaoAssets($container[Services::ASSETS_MANAGER]);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet;
|
namespace Netzmacht\Contao\Leaflet;
|
||||||
|
|
||||||
|
use Netzmacht\Contao\Toolkit\View\Assets\AssetsManager;
|
||||||
use Netzmacht\LeafletPHP\Assets;
|
use Netzmacht\LeafletPHP\Assets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,6 +28,23 @@ class ContaoAssets implements Assets
|
|||||||
*/
|
*/
|
||||||
private $map;
|
private $map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assets manager.
|
||||||
|
*
|
||||||
|
* @var AssetsManager
|
||||||
|
*/
|
||||||
|
private $assetsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContaoAssets constructor.
|
||||||
|
*
|
||||||
|
* @param AssetsManager $assetsManager Contao assets manager.
|
||||||
|
*/
|
||||||
|
public function __construct(AssetsManager $assetsManager)
|
||||||
|
{
|
||||||
|
$this->assetsManager = $assetsManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
@@ -40,14 +58,8 @@ class ContaoAssets implements Assets
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case static::TYPE_FILE:
|
case static::TYPE_FILE:
|
||||||
if (!\Config::get('debugMode') && TL_MODE === 'FE') {
|
|
||||||
$script .= '|static';
|
|
||||||
}
|
|
||||||
|
|
||||||
// no break
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$GLOBALS['TL_JAVASCRIPT'][] = $script;
|
$this->assetsManager->addJavascript($script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,13 +76,8 @@ class ContaoAssets implements Assets
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case static::TYPE_FILE:
|
case static::TYPE_FILE:
|
||||||
if (!\Config::get('debugMode')) {
|
|
||||||
$stylesheet .= '|all|static';
|
|
||||||
}
|
|
||||||
// no break
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$GLOBALS['TL_CSS'][] = $stylesheet;
|
$this->assetsManager->addStylesheet($stylesheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user