Extract geo json creation to an event subscriber.

This commit is contained in:
David Molineus
2015-01-23 13:04:04 +01:00
parent 0a5dc97f4b
commit b53887d78b
6 changed files with 266 additions and 40 deletions

View File

@@ -0,0 +1,91 @@
<?php
/**
* @package dev
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2015 netzmacht creative David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Event;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\GeoJson\GeoJsonObject;
use Symfony\Component\EventDispatcher\Event;
/**
* Class ConvertToGeoJsonEvent is emitted when the DefinitionMapper converts a definition to a geo json feature.
*
* @package Netzmacht\Contao\Leaflet\Event
*/
class ConvertToGeoJsonEvent extends Event
{
const NAME = 'leaflet.mapper.convert-to-geojson';
/**
* The definition.
*
* @var Definition
*/
private $definition;
/**
* The GeoJSON object.
*
* @var GeoJsonObject
*/
private $geoJson;
/**
* The definition model.
*
* @var mixed
*/
private $model;
/**
* Construct.
*
* @param Definition $definition The definition.
* @param GeoJsonObject $geoJson The GeoJSON object.
* @param mixed $model The corresponding model. Usually a \Model but could be everything.
*/
public function __construct(Definition $definition, GeoJsonObject $geoJson, $model)
{
$this->definition = $definition;
$this->geoJson = $geoJson;
$this->model = $model;
}
/**
* Get the definition.
*
* @return Definition
*/
public function getDefinition()
{
return $this->definition;
}
/**
* Get the geoJson representation.
*
* @return GeoJsonObject
*/
public function getGeoJson()
{
return $this->geoJson;
}
/**
* Get the model.
*
* @return mixed
*/
public function getModel()
{
return $this->model;
}
}