mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-30 03:54:10 +01:00
Use the framework.
This commit is contained in:
@@ -39,6 +39,8 @@ services:
|
|||||||
|
|
||||||
netzmacht.contao_leaflet.frontend.value_filter:
|
netzmacht.contao_leaflet.frontend.value_filter:
|
||||||
class: Netzmacht\Contao\Leaflet\Frontend\ValueFilter
|
class: Netzmacht\Contao\Leaflet\Frontend\ValueFilter
|
||||||
|
arguments:
|
||||||
|
- '@contao.framework'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.map.assets:
|
netzmacht.contao_leaflet.map.assets:
|
||||||
class: Netzmacht\Contao\Leaflet\Encoder\ContaoAssets
|
class: Netzmacht\Contao\Leaflet\Encoder\ContaoAssets
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Frontend;
|
namespace Netzmacht\Contao\Leaflet\Frontend;
|
||||||
|
|
||||||
use Contao\Controller;
|
use Contao\CoreBundle\Framework\ContaoFrameworkInterface as ContaoFramework;
|
||||||
|
use Contao\InsertTags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -21,6 +22,45 @@ use Contao\Controller;
|
|||||||
*/
|
*/
|
||||||
class ValueFilter
|
class ValueFilter
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Contao framework.
|
||||||
|
*
|
||||||
|
* @var ContaoFramework
|
||||||
|
*/
|
||||||
|
private $framework;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert tags.
|
||||||
|
*
|
||||||
|
* @var InsertTags
|
||||||
|
*/
|
||||||
|
private $replacer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ValueFilter constructor.
|
||||||
|
*
|
||||||
|
* @param ContaoFramework $framework Contao framework.
|
||||||
|
*/
|
||||||
|
public function __construct(ContaoFramework $framework)
|
||||||
|
{
|
||||||
|
$this->framework = $framework;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the replacer.
|
||||||
|
*
|
||||||
|
* @return InsertTags
|
||||||
|
*/
|
||||||
|
private function getReplacer(): InsertTags
|
||||||
|
{
|
||||||
|
if ($this->replacer === null) {
|
||||||
|
$this->framework->initialize();
|
||||||
|
$this->replacer = $this->framework->createInstance(InsertTags::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->replacer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a value so it can be passed to the frontend.
|
* Filter a value so it can be passed to the frontend.
|
||||||
*
|
*
|
||||||
@@ -33,6 +73,6 @@ class ValueFilter
|
|||||||
*/
|
*/
|
||||||
public function filter($value)
|
public function filter($value)
|
||||||
{
|
{
|
||||||
return Controller::replaceInsertTags($value);
|
return $this->getReplacer()->replace($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user