Rename Reference to expression.

This commit is contained in:
David Molineus
2015-01-08 12:52:32 +01:00
parent 135bd9f7c6
commit 7520cbd55e
2 changed files with 8 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper; use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
use Netzmacht\Contao\Leaflet\Model\MarkerModel; use Netzmacht\Contao\Leaflet\Model\MarkerModel;
use Netzmacht\Contao\Leaflet\Request\RequestUrl; use Netzmacht\Contao\Leaflet\Request\RequestUrl;
use Netzmacht\Javascript\Type\Value\Reference; use Netzmacht\Javascript\Type\Value\Expression;
use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection; use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection;
use Netzmacht\LeafletPHP\Definition\Group\GeoJson; use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
@@ -42,16 +42,13 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function createInstance(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) protected function getClassName(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
{ {
if ($model->deferred) { if ($model->deferred) {
$reflector = new \ReflectionClass('Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax'); return 'Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax';
$instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $bounds));
return $instance;
} }
return parent::createInstance($model, $mapper, $bounds); return parent::getClassName($model, $mapper, $bounds);
} }
/** /**
@@ -76,7 +73,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
} }
if ($definition instanceof GeoJson) { if ($definition instanceof GeoJson) {
$definition->setPointToLayer(new Reference('ContaoLeaflet.pointToLayer', 'ContaoLeaflet')); $definition->setPointToLayer(new Expression('ContaoLeaflet.pointToLayer.bind(ContaoLeaflet)'));
} }
} }

View File

@@ -16,7 +16,7 @@ use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
use Netzmacht\Contao\Leaflet\Model\MarkerModel; use Netzmacht\Contao\Leaflet\Model\MarkerModel;
use Netzmacht\Contao\Leaflet\Model\VectorModel; use Netzmacht\Contao\Leaflet\Model\VectorModel;
use Netzmacht\Contao\Leaflet\Request\RequestUrl; use Netzmacht\Contao\Leaflet\Request\RequestUrl;
use Netzmacht\Javascript\Type\Value\Reference; use Netzmacht\Javascript\Type\Value\Expression;
use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection; use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection;
use Netzmacht\LeafletPHP\Definition\Group\GeoJson; use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
@@ -77,8 +77,8 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
} }
if ($definition instanceof GeoJson) { if ($definition instanceof GeoJson) {
$definition->setOnEachFeature(new Reference('ContaoLeaflet.onEachFeature', 'ContaoLeaflet')); $definition->setOnEachFeature(new Expression('ContaoLeaflet.onEachFeature.bind(ContaoLeaflet)'));
$definition->setPointToLayer(new Reference('ContaoLeaflet.pointToLayer', 'ContaoLeaflet')); $definition->setPointToLayer(new Expression('ContaoLeaflet.pointToLayer.bind(ContaoLeaflet)'));
} }
} }