diff --git a/CHANGELOG.md b/CHANGELOG.md index 91ace23..99b1fc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Deprecate `Netzmacht\Contao\Leaflet\Frontend\RequestUrl`. Use router to generate request url for layer data. - Deprecate `Netzmacht\Contao\Leaflet\Frontend\DataController`. Use introduced endpoint to get map data. + +### Changed + + - Rewritten about page using own route (#48). ### Fixed diff --git a/src/Backend/About.php b/src/Backend/Action/AboutAction.php similarity index 65% rename from src/Backend/About.php rename to src/Backend/Action/AboutAction.php index 5678f3a..8e0e178 100644 --- a/src/Backend/About.php +++ b/src/Backend/Action/AboutAction.php @@ -10,32 +10,59 @@ * @filesource */ -namespace Netzmacht\Contao\Leaflet\Backend; +namespace Netzmacht\Contao\Leaflet\Backend\Action; -use Contao\BackendTemplate; +use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as Engine; +use Symfony\Component\HttpFoundation\Response; /** * Credits backend module. * * @package Netzmacht\Contao\Leaflet\Backend */ -class About +final class AboutAction { + /** + * Templating engine. + * + * @var Engine + */ + private $engine; + + /** + * Project directory. + * + * @var string + */ + private $projectDir; + + /** + * AboutAction constructor. + * + * @param Engine $engine Templating engine. + * @param string $projectDir Project directory. + */ + public function __construct(Engine $engine, string $projectDir) + { + $this->engine = $engine; + $this->projectDir = $projectDir; + } + /** * Generate the backend view. * * @return string */ - public function generate() + public function __invoke(): Response { - $template = new BackendTemplate('be_leaflet_about'); + $data = [ + 'headline' => 'Leaftlet maps integration for Contao CMS', + 'libraries' => $this->getLibraries(), + ]; - $template->headline = 'Leaftlet maps integration for Contao CMS'; - $template->libraries = $this->getLibraries(); + [$data['version'], $data['dependencies']] = $this->extractFromComposer(); - list($template->version, $template->dependencies) = $this->extractFromComposer(); - - return $template->parse(); + return $this->engine->renderResponse('@NetzmachtContaoLeaflet/backend/about.html.twig', $data); } /** @@ -45,7 +72,7 @@ class About * * @SuppressWarnings(PHPMD.Superglobals) */ - private function getLibraries() + private function getLibraries(): array { return array_map( function ($library) { @@ -70,7 +97,7 @@ class About array_filter( $GLOBALS['LEAFLET_LIBRARIES'], function ($library) { - return isset($library['name']) && isset($library['license']); + return isset($library['name'], $library['license']); } ) ); @@ -81,10 +108,10 @@ class About * * @return array */ - private function extractFromComposer() + private function extractFromComposer(): array { - $extFile = TL_ROOT . '/vendor/netzmacht/contao-leaflet-maps/composer.json'; - $lockFile = TL_ROOT . '/composer.lock'; + $extFile = $this->projectDir . '/vendor/netzmacht/contao-leaflet-maps/composer.json'; + $lockFile = $this->projectDir . '/composer.lock'; if (!file_exists($extFile) || !file_exists($lockFile)) { return []; diff --git a/src/Bundle/ContaoManager/Plugin.php b/src/Bundle/ContaoManager/Plugin.php index f9f6d52..b5420a1 100644 --- a/src/Bundle/ContaoManager/Plugin.php +++ b/src/Bundle/ContaoManager/Plugin.php @@ -61,11 +61,6 @@ class Plugin implements BundlePluginInterface, RoutingPluginInterface return null; } - $collection = $loader->load(__DIR__ . '/../Resources/config/routing.yml'); - if ($collection instanceof RouteCollection) { - $collection->addPrefix('leaflet/api'); - } - - return $collection; + return $loader->load(__DIR__ . '/../Resources/config/routing.yml'); } } diff --git a/src/Bundle/Resources/config/listeners.yml b/src/Bundle/Resources/config/listeners.yml index 16622f6..afd2b09 100644 --- a/src/Bundle/Resources/config/listeners.yml +++ b/src/Bundle/Resources/config/listeners.yml @@ -113,3 +113,13 @@ services: - '@netzmacht.contao_leaflet.definition.builder' tags: - { name: 'contao.hook', hook: 'initializeSystem', method: 'onInitializeSystem' } + + netzmacht.contao_leaflet.listeners.backend_menu: + class: Netzmacht\Contao\Leaflet\Listener\Backend\UserNavigationListener + arguments: + - '@request_stack' + - '@router' + - '@translator' + - '@netzmacht.contao_toolkit.assets_manager' + tags: + - { name: 'contao.hook', hook: 'getUserNavigation', method: '__invoke'} diff --git a/src/Bundle/Resources/config/routing.yml b/src/Bundle/Resources/config/routing.yml index 371ec1a..b210bcc 100644 --- a/src/Bundle/Resources/config/routing.yml +++ b/src/Bundle/Resources/config/routing.yml @@ -1,5 +1,5 @@ leaflet_layer: - path: /layer/{layerId} + path: /leaflet/api/layer/{layerId} controller: Netzmacht\Contao\Leaflet\Frontend\Action\LayerDataAction defaults: _leaflet_scope: page @@ -9,3 +9,10 @@ leaflet_layer: _format: geojson context: \w+ contextId: \d+ + +leaflet_backend_about: + path: /contao/leaflet/about + controller: Netzmacht\Contao\Leaflet\Backend\Action\AboutAction + defaults: + _scope: backend + _backend_module: leaflet_about diff --git a/src/Bundle/Resources/config/services.yml b/src/Bundle/Resources/config/services.yml index 454f01c..e7cff08 100644 --- a/src/Bundle/Resources/config/services.yml +++ b/src/Bundle/Resources/config/services.yml @@ -131,3 +131,8 @@ services: arguments: - '@netzmacht.contao_leaflet.map.provider' - '@netzmacht.contao_leaflet.filter_factory' + + Netzmacht\Contao\Leaflet\Backend\Action\AboutAction: + arguments: + - '@templating' + - '%kernel.project_dir%' diff --git a/src/Bundle/Resources/contao/config/config.php b/src/Bundle/Resources/contao/config/config.php index 29595b8..9f4431c 100644 --- a/src/Bundle/Resources/contao/config/config.php +++ b/src/Bundle/Resources/contao/config/config.php @@ -40,11 +40,6 @@ array_insert( 'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css', 'javascript' => 'bundles/netzmachtcontaoleaflet/js/backend.js', ], - 'leaflet_about' => [ - 'callback' => Netzmacht\Contao\Leaflet\Backend\About::class, - 'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png', - 'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css', - ], ], ] ); diff --git a/src/Bundle/Resources/contao/templates/be_leaflet_about.html5 b/src/Bundle/Resources/contao/templates/be_leaflet_about.html5 deleted file mode 100644 index 15835f2..0000000 --- a/src/Bundle/Resources/contao/templates/be_leaflet_about.html5 +++ /dev/null @@ -1,140 +0,0 @@ -
- The Leaflet maps integration for Contao CMS is an Open Source Software license under the LGPL 3.0. - This extension is only exists because of great other Open Source Software which it heavenly depends on. -
-- This software ships with an visible attribution to netzmacht creative in the map attribution - control. - If you want to remove this attribution, you have to purchase a commercial license. - For more details visit the project - website. -
-
-
- netzmacht
- David Molineus
-
- DAB Bank München
- IBAN: DE52701204008354237003
- BIC: DABBDEMMXXX
-
If you found a bug, got some troubles or have a feature request - feel free to open an issue.
- -There are many ways you can contribute. Translations, - documentation or code contributions are welcome. -
- -Contao Leaflet is not feature complete. Have a look at the list of planned feature and support - them.
- -If you have special requirements you can hire me for an individual development.
- -If you want to remove the attribution in the attribution control, you can purchase a commercial - license.
- -| Name | -Version | -License | -Homepage | -
|---|---|---|---|
| Libraries | -|||
| - | - | - | - |
| Graphics | -|||
| Farm Fresh-Web Icons | -3.9.2 | -CC BY 3.0 US | -fatcow.com/free-icons | -
| Web Blog Icons by SEM Labs | -3.9.2 | -CC BY 4.0 | -semlabs.co.uk | -
| Dependencies | -|||
| - | - | - | - |
+ The Leaflet maps integration for Contao CMS is an Open Source Software license under the LGPL 3.0. + This extension is only exists because of great other Open Source Software which it heavenly depends on. +
++ This software ships with an visible attribution to netzmacht creative in the map attribution + control. + If you want to remove this attribution, you have to purchase a commercial license. + For more details visit the project + website. +
+If you found a bug, got some troubles or have a feature request - feel free to open an issue.
+ +There are many ways you can contribute. Translations, + documentation or code contributions are welcome. +
+ +Contao Leaflet is not feature complete. Have a look at the list of planned feature and support + them.
+ +If you have special requirements you can hire me for an individual development.
+ +If you want to remove the attribution in the attribution control, you can purchase a commercial + license.
+ +| Name | +Version | +License | +Homepage | +
|---|---|---|---|
| Libraries | +|||
| {{ library.name }} | +{{ library.version }} | +{{ library.license|raw }} | +{{ library.homepage|raw }} | +
| Graphics | +|||
| Farm Fresh-Web Icons | +3.9.2 | +CC BY 3.0 US | +fatcow.com/free-icons | +
| Web Blog Icons by SEM Labs | +3.9.2 | +CC BY 4.0 | +semlabs.co.uk | +
| Dependencies | +|||
| {{ dep.name }} | +{{ dep.version }} | +{{ dep.license|raw }} | +{{ dep.homepage|raw }} | +