mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 19:43:50 +01:00
Ongoing development.
This commit is contained in:
8
module/config/autoload.php
Normal file
8
module/config/autoload.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
TemplateLoader::addFiles(
|
||||
array(
|
||||
'ce_leaflet_map' => 'system/modules/leaflet/templates',
|
||||
'be_leaflet_geocode' => 'system/modules/leaflet/templates',
|
||||
)
|
||||
);
|
||||
@@ -1,5 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Backend module.
|
||||
*/
|
||||
$GLOBALS['BE_MOD']['content']['leaflet'] = array(
|
||||
'tables' => array('tl_leaflet_map')
|
||||
'tables' => array('tl_leaflet_map'),
|
||||
'icon' => 'system/modules/leaflet/assets/img/leaflet.png',
|
||||
);
|
||||
|
||||
/*
|
||||
* Content elements.
|
||||
*/
|
||||
$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\LeafletMapElement';
|
||||
|
||||
|
||||
/*
|
||||
* Models.
|
||||
*/
|
||||
$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel';
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet mappers.
|
||||
*
|
||||
* Mappers do the translations between the database models and the leaflet definition.
|
||||
*/
|
||||
$GLOBALS['LEAFLET_MAPPERS'] = array();
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper';
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet encoders.
|
||||
*
|
||||
* The encoders transforms the definitions into javascript. The encoders has to be an implementation of the
|
||||
* EventDispatcherInterface of the event dispatcher.
|
||||
*
|
||||
* You can define the encoders using the syntax of the cca event dispatcher implementation.
|
||||
*
|
||||
* @see https://github.com/contao-community-alliance/event-dispatcher#event-subscriber-per-configuration
|
||||
*/
|
||||
$GLOBALS['LEAFLET_ENCODERS'] = array();
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Javascript\Subscriber\EncoderSubscriber';
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\MapEncoder';
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\ControlEncoder';
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\GroupEncoder';
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\RasterEncoder';
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\VectorEncoder';
|
||||
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber';
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet assets.
|
||||
*
|
||||
* The leaflet definition are aware of the required javascript libraries. Register the assets so that they are
|
||||
* loaded automatically.
|
||||
*
|
||||
* Each entry is an array of 2 values. The first is the resource. The second is a type. Supported types are:
|
||||
* - url: An valid url.
|
||||
* - file: An file path relative to the Contao Root.
|
||||
* - source: Inline css/javascript.
|
||||
*/
|
||||
$GLOBALS['LEAFLET_ASSETS']['contao'] = array(
|
||||
'javascript' => array(
|
||||
array()
|
||||
)
|
||||
);
|
||||
|
||||
$GLOBALS['LEAFLET_ASSETS']['leaflet'] = array(
|
||||
'css' => array(
|
||||
array('http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css', 'url')
|
||||
),
|
||||
'javascript' => array(
|
||||
array('http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js?3', 'url')
|
||||
)
|
||||
);
|
||||
|
||||
5
module/config/event_subscribers.php
Normal file
5
module/config/event_subscribers.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Netzmacht\Contao\Leaflet\Subscriber\BootSubscriber'
|
||||
);
|
||||
72
module/config/services.php
Normal file
72
module/config/services.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Boot;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\MapService;
|
||||
use Netzmacht\Javascript\Builder;
|
||||
use Netzmacht\Javascript\Encoder;
|
||||
use Netzmacht\LeafletPHP\Leaflet;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
/** @var \Pimple $container */
|
||||
global $container;
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet map service is a simply api entry to to get the leaflet map from the database.
|
||||
*/
|
||||
$container['leaflet.map.service'] = $container->share(function ($container) {
|
||||
return new MapService(
|
||||
$container['leaflet.definition.mapper'],
|
||||
$container['leaflet.definition.builder'],
|
||||
$container['event-dispatcher']
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* The leaflet boot.
|
||||
*/
|
||||
$container['leaflet.boot'] = $container->share(function ($container) {
|
||||
return new Boot($container['event-dispatcher']);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* The definition mapper.
|
||||
*/
|
||||
$container['leaflet.definition.mapper'] = $container->share(function ($container) {
|
||||
/** @var Boot $boot */
|
||||
$boot = $container['leaflet.boot'];
|
||||
$mapper = new DefinitionMapper($container['event-dispatcher']);
|
||||
|
||||
return $boot->initializeDefinitionMapper($mapper);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* The local event dispatcher is used for the leaflet javascript encoding system.
|
||||
*/
|
||||
$container['leaflet.definition.builder.event-dispatcher'] = $container->share(function ($container) {
|
||||
/** @var Boot $boot */
|
||||
$boot = $container['leaflet.boot'];
|
||||
$dispatcher = new EventDispatcher();
|
||||
|
||||
return $boot->initializeEventDispatcher($dispatcher);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* The leaflet builder transforms the definition to javascript.
|
||||
*/
|
||||
$container['leaflet.definition.builder'] = $container->share(function($container) {
|
||||
/** @var Boot $boot */
|
||||
$boot = $container['leaflet.boot'];
|
||||
$dispatcher = $container['leaflet.definition.builder.event-dispatcher'];
|
||||
|
||||
$encoder = new Encoder($dispatcher);
|
||||
$builder = new Builder($encoder, $dispatcher);
|
||||
$leaflet = new Leaflet($builder);
|
||||
|
||||
return $boot->initializeLeafletBuilder($leaflet);
|
||||
});
|
||||
Reference in New Issue
Block a user