Add the file path to the layer label.

This commit is contained in:
David Molineus
2017-10-17 18:18:33 +02:00
parent c465b724f4
commit 60306459d2
2 changed files with 53 additions and 0 deletions

View 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;
}
}

View File

@@ -84,3 +84,8 @@ services:
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\VectorsLabelRenderer
tags:
- { 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' }