mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-30 12:03:44 +01:00
Use latest Repository feature to replace static model calls.
This commit is contained in:
@@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||
|
||||
/**
|
||||
@@ -24,12 +25,29 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||
*/
|
||||
final class ReferenceLabelRenderer extends AbstractLabelRenderer
|
||||
{
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* FileLabelRenderer constructor.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getLayerType(): string
|
||||
{
|
||||
return 'vectors';
|
||||
return 'reference';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +55,8 @@ final class ReferenceLabelRenderer extends AbstractLabelRenderer
|
||||
*/
|
||||
public function render(array $row, string $label, Translator $translator): string
|
||||
{
|
||||
$reference = LayerModel::findByPk($row['reference']);
|
||||
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||
$reference = $repository->find((int) $row['reference']);
|
||||
|
||||
if ($reference) {
|
||||
$label .= '<span class="tl_gray"> (' . $reference->title . ')</span>';
|
||||
|
||||
Reference in New Issue
Block a user