From 8300531de32216c765cecae6c51bfe0a4be88cfd Mon Sep 17 00:00:00 2001 From: David Molineus Date: Fri, 6 Oct 2017 09:28:33 +0200 Subject: [PATCH] Restructure config files, add extension and complete mappers services. --- .../NetzmachtContaoLeafletExtension.php | 51 +++++ .../config/{parameters => }/amenities.yml | 0 src/Resources/config/config.yml | 68 ++++++- .../config/{services => }/encoders.yml | 0 .../config/{services => }/filters.yml | 0 .../config/{services => }/listeners.yml | 0 src/Resources/config/mappers.yml | 177 ++++++++++++++++++ src/Resources/config/parameters/common.yml | 60 ------ .../config/{parameters => }/providers.yml | 0 .../config/{services => }/services.yml | 3 + src/Resources/config/services/mappers.yml | 33 ---- 11 files changed, 291 insertions(+), 101 deletions(-) create mode 100644 src/DependencyInjection/NetzmachtContaoLeafletExtension.php rename src/Resources/config/{parameters => }/amenities.yml (100%) rename src/Resources/config/{services => }/encoders.yml (100%) rename src/Resources/config/{services => }/filters.yml (100%) rename src/Resources/config/{services => }/listeners.yml (100%) create mode 100644 src/Resources/config/mappers.yml delete mode 100644 src/Resources/config/parameters/common.yml rename src/Resources/config/{parameters => }/providers.yml (100%) rename src/Resources/config/{services => }/services.yml (57%) delete mode 100644 src/Resources/config/services/mappers.yml diff --git a/src/DependencyInjection/NetzmachtContaoLeafletExtension.php b/src/DependencyInjection/NetzmachtContaoLeafletExtension.php new file mode 100644 index 0000000..076c91e --- /dev/null +++ b/src/DependencyInjection/NetzmachtContaoLeafletExtension.php @@ -0,0 +1,51 @@ + + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +namespace Netzmacht\Contao\Leaflet\DependencyInjection; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +/** + * Class NetzmachtContaoLeafletExtension. + * + * @package Netzmacht\Contao\Leaflet\DependencyInjection + */ +class NetzmachtContaoLeafletExtension extends Extension +{ + /** + * {@inheritdoc} + */ + public function load(array $configs, ContainerBuilder $container) + { + $loader = new YamlFileLoader( + $container, + new FileLocator(dirname(__DIR__) .'/Resources/config') + ); + + // Common config, services and listeners + $loader->load('config.yml'); + $loader->load('services.yml'); + $loader->load('listeners.yml'); + + // Amenities and providers config + $loader->load('amenities.yml'); + $loader->load('providers.yml'); + + // Other services + $loader->load('filters.yml'); + $loader->load('mappers.yml'); + $loader->load('encoders.yml'); + } +} diff --git a/src/Resources/config/parameters/amenities.yml b/src/Resources/config/amenities.yml similarity index 100% rename from src/Resources/config/parameters/amenities.yml rename to src/Resources/config/amenities.yml diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml index b2db1a6..1624280 100644 --- a/src/Resources/config/config.yml +++ b/src/Resources/config/config.yml @@ -1,8 +1,60 @@ -imports: - - { resource: parameters/common.yml } - - { resource: parameters/amenities.yml } - - { resource: parameters/providers.yml } - - { resource: services/encoders.yml } - - { resource: services/mappers.yml } - - { resource: services/services.yml } - - { resource: services/listeners.yml } +parameters: + # leaflet controls. + # + # Supported leaflet control types. Register your type for the database driven definition here. + netzmacht.contao_leaflet_maps.controls: + - 'zoom' + - 'layers' + - 'scale' + - 'attribution' + - 'loading' + - 'fullscreen' + + # Leaflet icons. + # + # Supported leaflet icon types. Register you type for the database driven definition here. + netzmacht.contao_leaflet_maps.icons: + - 'image' + - 'div' + - 'extra' + + # The style concept is not part of the LeafletJS library. Styles are extracted from the Path options. Instead + # of defining the style for every vector again, manage them at one place. + # + # The goal is to provide different style strategies. For instance a random style chooser, one which uses a color + # range and so one. + netzmacht.contao_leaflet_maps.styles: + - 'fixed' + + # Leaflet vectors. + # + # Supported leaflet vector types. Register you type for the database driven definition here. + netzmacht.contao_leaflet_maps.vectors: + - 'polyline' + - 'polygon' + - 'multiPolyline' + - 'multiPolygon' + - 'rectangle' + - 'circle' + - 'circleMarker' + + # When creating a GeoJSON feature of a map object a feature.properties.model object is passed. + # Define the properties you always want to set. + # + # For more control you can subscribe the ConvertToGeoJsonEvent. + # + # The entry can be a string or an array. If an array is passed, the 2nd value is the type. Following types + # are supported. + # - array: Use deserialize before adding the value + # - file: Thread value a uuid and find the path. + # - files: Thread values as a list of file uuids and get an array of paths. + netzmacht.contao_leaflet_maps.feature_model_properties: + tl_leaflet_marker: + - 'id' + - 'title' + - 'alias' + + tl_leaflet_vector: + - 'id' + - 'title' + - 'alias' diff --git a/src/Resources/config/services/encoders.yml b/src/Resources/config/encoders.yml similarity index 100% rename from src/Resources/config/services/encoders.yml rename to src/Resources/config/encoders.yml diff --git a/src/Resources/config/services/filters.yml b/src/Resources/config/filters.yml similarity index 100% rename from src/Resources/config/services/filters.yml rename to src/Resources/config/filters.yml diff --git a/src/Resources/config/services/listeners.yml b/src/Resources/config/listeners.yml similarity index 100% rename from src/Resources/config/services/listeners.yml rename to src/Resources/config/listeners.yml diff --git a/src/Resources/config/mappers.yml b/src/Resources/config/mappers.yml new file mode 100644 index 0000000..5265dde --- /dev/null +++ b/src/Resources/config/mappers.yml @@ -0,0 +1,177 @@ +# Leaflet mappers. +# +# Mappers translate between the database models and the leaflet definition. +services: + _defaults: + public: false + + + # Map mapper + netzmacht.contao_leaflet_maps.mapper.map: + class: Netzmacht\Contao\Leaflet\Mapper\MapMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + + # Layer mappers + netzmacht.contao_leaflet_maps.mapper.tile_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\TileLayerMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.provider_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper + arguments: + - '%netzmacht.contao_leaflet_maps.providers%' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.markers_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.group_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.vectors_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.reference_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.overpass_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.marker_cluster_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper + arguments: + - '@netzmacht.contao_leaflet_maps.map.assets' + tags: + - { name: netzmacht.contao_leflet_maps.mapper } + + + # Control mappers + netzmacht.contao_leaflet_maps.mapper.zoom_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.scale_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\ScaleControlMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.layers_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.attribution_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\AttributionControlMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.loading_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.fullscreen_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + + # Vector mappers + netzmacht.contao_leaflet_maps.mapper.polyline: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.multi_polyline: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.polygon: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.multi_polygon: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.circle: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.circle_mapper: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.rectangle_mapper: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + + # Miscellaneous mappers + netzmacht.contao_leaflet_maps.mapper.popup: + class: Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.image_icon: + class: Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.div_icon: + class: Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.extra_markers: + class: Netzmacht\Contao\Leaflet\Mapper\Type\ExtraMarkersIconMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.fixed_style: + class: Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + + netzmacht.contao_leaflet_maps.mapper.marker: + class: Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper + arguments: + - '@netzmacht.contao_leaflet_maps.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet_maps.mapper } + diff --git a/src/Resources/config/parameters/common.yml b/src/Resources/config/parameters/common.yml deleted file mode 100644 index cfaa383..0000000 --- a/src/Resources/config/parameters/common.yml +++ /dev/null @@ -1,60 +0,0 @@ -parameters: - # leaflet controls. - # - # Supported leaflet control types. Register your type for the database driven definition here. - netzmacht.contao_leaflet_maps.controls: - - 'zoom' - - 'layers' - - 'scale' - - 'attribution' - - 'loading' - - 'fullscreen' - - # Leaflet icons. - # - # Supported leaflet icon types. Register you type for the database driven definition here. - netzmacht.contao_leaflet_maps.icons: - - 'image' - - 'div' - - 'extra' - - # The style concept is not part of the LeafletJS library. Styles are extracted from the Path options. Instead - # of defining the style for every vector again, manage them at one place. - # - # The goal is to provide different style strategies. For instance a random style chooser, one which uses a color - # range and so one. - netzmacht.contao_leaflet_maps.styles: - - 'fixed' - - # Leaflet vectors. - # - # Supported leaflet vector types. Register you type for the database driven definition here. - netzmacht.contao_leaflet_maps.vectors: - - 'polyline' - - 'polygon' - - 'multiPolyline' - - 'multiPolygon' - - 'rectangle' - - 'circle' - - 'circleMarker' - - # When creating a GeoJSON feature of a map object a feature.properties.model object is passed. - # Define the properties you always want to set. - # - # For more control you can subscribe the ConvertToGeoJsonEvent. - # - # The entry can be a string or an array. If an array is passed, the 2nd value is the type. Following types - # are supported. - # - array: Use deserialize before adding the value - # - file: Thread value a uuid and find the path. - # - files: Thread values as a list of file uuids and get an array of paths. - netzmacht.contao_leaflet_maps.feature_model_properties: - tl_leaflet_marker: - - 'id' - - 'title' - - 'alias' - - tl_leaflet_vector: - - 'id' - - 'title' - - 'alias' diff --git a/src/Resources/config/parameters/providers.yml b/src/Resources/config/providers.yml similarity index 100% rename from src/Resources/config/parameters/providers.yml rename to src/Resources/config/providers.yml diff --git a/src/Resources/config/services/services.yml b/src/Resources/config/services.yml similarity index 57% rename from src/Resources/config/services/services.yml rename to src/Resources/config/services.yml index 99f8863..e0f2c45 100644 --- a/src/Resources/config/services/services.yml +++ b/src/Resources/config/services.yml @@ -1,3 +1,6 @@ services: netzmacht.contao_leaflet_maps.frontend.value_filter: class: + + netzmacht.contao_leaflet_maps.map.assets: + class: diff --git a/src/Resources/config/services/mappers.yml b/src/Resources/config/services/mappers.yml deleted file mode 100644 index 3ed87a9..0000000 --- a/src/Resources/config/services/mappers.yml +++ /dev/null @@ -1,33 +0,0 @@ -services: - netzmacht.contao_leaflet_maps.mapper.popup: - class: Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper - tags: - - { name: netzmacht.contao_leaflet_maps.mapper } - - netzmacht.contao_leaflet_maps.mapper.image_icon: - class: Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper - tags: - - { name: netzmacht.contao_leaflet_maps.mapper } - - netzmacht.contao_leaflet_maps.mapper.div_icon: - class: Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper - tags: - - { name: netzmacht.contao_leaflet_maps.mapper } - - netzmacht.contao_leaflet_maps.mapper.extra_markers: - class: Netzmacht\Contao\Leaflet\Mapper\Type\ExtraMarkersIconMapper - tags: - - { name: netzmacht.contao_leaflet_maps.mapper } - - netzmacht.contao_leaflet_maps.mapper.fixed_style: - class: Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper - tags: - - { name: netzmacht.contao_leaflet_maps.mapper } - - netzmacht.contao_leaflet_maps.mapper.marker: - class: Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper - arguments: - - '@netzmacht.contao_leaflet_maps.frontend.value_filter' - tags: - - { name: netzmacht.contao_leaflet_maps.mapper } -