Files
contao-leaflet-maps/src/Backend/Renderer/Label/Layer/MarkersLabelRenderer.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2017-10-06 10:07:19 +02:00
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
2017-10-11 15:00:48 +02:00
* @copyright 2014-2017 netzmacht David Molineus. All rights reserved.
2017-10-06 10:07:19 +02:00
* @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 Netzmacht\Contao\Leaflet\Model\MarkerModel;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
2017-10-06 10:07:19 +02:00
use Symfony\Component\Translation\TranslatorInterface as Translator;
/**
* Class MarkersLabelRenderer.
*
* @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer
*/
final class MarkersLabelRenderer extends AbstractLabelRenderer
{
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* FileLabelRenderer constructor.
*
* @param RepositoryManager $repositoryManager Repository manager.
*/
public function __construct(RepositoryManager $repositoryManager)
{
$this->repositoryManager = $repositoryManager;
}
2017-10-06 10:07:19 +02:00
/**
* {@inheritdoc}
*/
protected function getLayerType(): string
{
return 'markers';
}
/**
* {@inheritdoc}
*/
public function render(array $row, string $label, Translator $translator): string
{
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
2017-10-18 16:46:05 +02:00
$count = $repository->countBy(['pid=?'], [$row['pid']]);
2017-10-18 16:36:36 +02:00
$label .= sprintf(
2017-10-06 10:07:19 +02:00
'<span class="tl_gray"> (%s %s)</span>',
$count,
$translator->trans('countEntries', [], 'contao_tl_leaflet_layer')
);
return $label;
}
}