mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 11:04:08 +01:00
Fix api inconsistency for Contao 3.5 (See #37).
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Boot;
|
use Netzmacht\Contao\Leaflet\Boot;
|
||||||
use Netzmacht\Contao\Leaflet\ContaoAssets;
|
use Netzmacht\Contao\Leaflet\ContaoAssets;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\Helper\FrontendApi;
|
use Netzmacht\Contao\Leaflet\Frontend\Helper\InsertTagReplacer;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\MapService;
|
use Netzmacht\Contao\Leaflet\MapService;
|
||||||
@@ -114,7 +114,7 @@ $container['leaflet.definition.builder'] = $container->share(function($container
|
|||||||
});
|
});
|
||||||
|
|
||||||
$container['leaflet.frontend.value-filter'] = $container->share(function() {
|
$container['leaflet.frontend.value-filter'] = $container->share(function() {
|
||||||
return new ValueFilter(new FrontendApi());
|
return new ValueFilter(new InsertTagReplacer());
|
||||||
});
|
});
|
||||||
|
|
||||||
$container['leaflet.service-container'] = $container->share(function($container) {
|
$container['leaflet.service-container'] = $container->share(function($container) {
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?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\Frontend\Helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is a helper to replace insert tags.
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\Frontend\Helper
|
||||||
|
*/
|
||||||
|
class InsertTagReplacer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Replace insert tags with their values.
|
||||||
|
*
|
||||||
|
* @param string $buffer The text with the tags to be replaced.
|
||||||
|
* @param boolean $cache If false, non-cacheable tags will be replaced.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function replace($buffer, $cache = true)
|
||||||
|
{
|
||||||
|
if (version_compare(VERSION, '3.5', '<')) {
|
||||||
|
$frontendApi = new FrontendApi();
|
||||||
|
|
||||||
|
return $frontendApi->replaceInsertTags($buffer, $cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
$replacer = new \InsertTags();
|
||||||
|
return $replacer->replace($buffer, $cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Frontend;
|
namespace Netzmacht\Contao\Leaflet\Frontend;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\Helper\FrontendApi;
|
use Netzmacht\Contao\Leaflet\Frontend\Helper\InsertTagReplacer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ValueFilter is a service class which can be used to filter values before passing them to an definition object.
|
* Class ValueFilter is a service class which can be used to filter values before passing them to an definition object.
|
||||||
@@ -23,18 +23,18 @@ class ValueFilter
|
|||||||
/**
|
/**
|
||||||
* The frontend api of Contao.
|
* The frontend api of Contao.
|
||||||
*
|
*
|
||||||
* @var FrontendApi
|
* @var InsertTagReplacer
|
||||||
*/
|
*/
|
||||||
private $api;
|
private $insertTagReplacer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param FrontendApi $api The frontend api of Contao.
|
* @param InsertTagReplacer $replacer The insert tag replacer.
|
||||||
*/
|
*/
|
||||||
public function __construct($api)
|
public function __construct($replacer)
|
||||||
{
|
{
|
||||||
$this->api = $api;
|
$this->insertTagReplacer = $replacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +49,6 @@ class ValueFilter
|
|||||||
*/
|
*/
|
||||||
public function filter($value)
|
public function filter($value)
|
||||||
{
|
{
|
||||||
return $this->api->replaceInsertTags($value);
|
return $this->insertTagReplacer->replace($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user