Files
contao-leaflet-maps/src/Dca/VectorCallbacks.php

67 lines
1.4 KiB
PHP
Raw Normal View History

2015-01-07 17:59:56 +01:00
<?php
/**
2016-10-11 10:40:15 +02:00
* @package contao-leaflet-maps
2015-01-07 17:59:56 +01:00
* @author David Molineus <david.molineus@netzmacht.de>
2016-10-11 10:40:15 +02:00
* @copyright 2014-2016 netzmacht David Molineus
2015-01-07 17:59:56 +01:00
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Dca;
2016-10-06 11:44:56 +02:00
use Netzmacht\Contao\Toolkit\Dca\Callback\Callbacks;
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
2015-01-09 11:53:58 +01:00
use Netzmacht\Contao\Leaflet\Model\StyleModel;
2015-01-12 19:03:29 +01:00
/**
* Helper class for the tl_leaflet_vector dca.
*
* @package Netzmacht\Contao\Leaflet\Dca
*/
2016-10-06 11:44:56 +02:00
class VectorCallbacks extends Callbacks
2015-01-07 17:59:56 +01:00
{
2016-10-06 11:44:56 +02:00
/**
* Name of the data container.
*
* @var string
*/
protected static $name = 'tl_leaflet_vector';
/**
* Helper service name.
*
* @var string
*/
protected static $serviceName = 'leaflet.dca.vector-callbacks';
2015-01-12 19:03:29 +01:00
/**
* Generate the row label.
*
* @param array $row Current data row.
*
* @return string
*/
2015-01-07 17:59:56 +01:00
public function generateRow($row)
{
2016-10-06 11:44:56 +02:00
return sprintf(
2016-10-06 11:50:00 +02:00
'%s <span class="tl_gray">(%s)</span>',
2016-10-06 11:44:56 +02:00
$row['title'],
$this->getFormatter()->formatValue('type', $row['type'])
);
2015-01-07 17:59:56 +01:00
}
2015-01-09 11:53:58 +01:00
/**
* Get all styles.
*
* @return array
*/
public function getStyles()
{
$collection = StyleModel::findAll(array('order' => 'title'));
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
2015-01-09 11:53:58 +01:00
}
2015-01-07 17:59:56 +01:00
}