forked from Snck3rs/contao-leaflet-maps
Add the file path to the layer label.
This commit is contained in:
48
src/Backend/Renderer/Label/Layer/FileLabelRenderer.php
Normal file
48
src/Backend/Renderer/Label/Layer/FileLabelRenderer.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaflet maps for Contao CMS.
|
||||||
|
*
|
||||||
|
* @package contao-leaflet-maps
|
||||||
|
* @author David Molineus <david.molineus@netzmacht.de>
|
||||||
|
* @copyright 2014-2017 netzmacht David Molineus. All rights reserved.
|
||||||
|
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
||||||
|
|
||||||
|
use Contao\FilesModel;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FileLabelRenderer
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer
|
||||||
|
*/
|
||||||
|
class FileLabelRenderer extends AbstractLabelRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function getLayerType(): string
|
||||||
|
{
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function render(array $row, string $label, Translator $translator): string
|
||||||
|
{
|
||||||
|
$file = FilesModel::findByPk($row['file']);
|
||||||
|
|
||||||
|
if ($file) {
|
||||||
|
$label .= ' <span class="tl_gray">(' . $file->path . ')</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $label;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,3 +84,8 @@ services:
|
|||||||
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\VectorsLabelRenderer
|
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\VectorsLabelRenderer
|
||||||
tags:
|
tags:
|
||||||
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet.layer_label_renderer.file:
|
||||||
|
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\FileLabelRenderer
|
||||||
|
tags:
|
||||||
|
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
||||||
|
|||||||
Reference in New Issue
Block a user