Refactor frontend integration using dependency injection.

This commit is contained in:
David Molineus
2016-10-06 08:34:55 +02:00
parent 4e4380270b
commit 2c9dd0ad48
4 changed files with 53 additions and 10 deletions

View File

@@ -14,6 +14,7 @@ use Netzmacht\Contao\Leaflet\Alias\DefaultAliasFilter;
use Netzmacht\Contao\Leaflet\Boot;
use Netzmacht\Contao\Leaflet\ContaoAssets;
use Netzmacht\Contao\Leaflet\Dca\ControlCallbacks;
use Netzmacht\Contao\Leaflet\Dca\FrontendIntegration;
use Netzmacht\Contao\Leaflet\Dca\LayerCallbacks;
use Netzmacht\Contao\Leaflet\Dca\MapCallbacks;
use Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices;
@@ -199,6 +200,19 @@ $container['leaflet.dca.control-callbacks'] = $container->share(
}
);
/**
* Callback helper class for frontend integration.
*
* @return FrontendIntegration
*/
$container['leaflet.dca.frontend-integration'] = $container->share(
function ($container) {
return new FrontendIntegration(
$container[Services::TRANSLATOR]
);
}
);
/**
* Component factory for content element.
*

View File

@@ -22,9 +22,9 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'],
'inputType' => 'select',
'exclude' => true,
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getMaps'),
'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'),
'wizard' => array(
array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getEditMapLink'),
\Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'),
),
'eval' => array(
'tl_class' => 'w50 wizard',

View File

@@ -22,9 +22,9 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'],
'inputType' => 'select',
'exclude' => true,
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getMaps'),
'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'),
'wizard' => array(
array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getEditMapLink'),
\Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'),
),
'eval' => array(
'tl_class' => 'w50 wizard',