forked from Snck3rs/contao-leaflet-maps
Rework validator callbacks to a listener service.
This commit is contained in:
@@ -10,9 +10,8 @@
|
|||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Dca;
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory;
|
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
@@ -40,18 +39,6 @@ class Validator
|
|||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the callback definition.
|
|
||||||
*
|
|
||||||
* @param string $methodName Callback method name.
|
|
||||||
*
|
|
||||||
* @return callable
|
|
||||||
*/
|
|
||||||
public static function callback($methodName)
|
|
||||||
{
|
|
||||||
return CallbackFactory::service('leaflet.dca.validator', $methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate coordinates.
|
* Validate coordinates.
|
||||||
*
|
*
|
||||||
@@ -5,6 +5,11 @@ services:
|
|||||||
- '@filesystem'
|
- '@filesystem'
|
||||||
- '%netzmacht.contao_leaflet_maps.cache_dir%'
|
- '%netzmacht.contao_leaflet_maps.cache_dir%'
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet_maps.listeners.dca.validator:
|
||||||
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\Validator
|
||||||
|
arguments:
|
||||||
|
- '@translator'
|
||||||
|
|
||||||
netzmacht.contao_leaflet_maps.listeners.dca.map:
|
netzmacht.contao_leaflet_maps.listeners.dca.map:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\MapDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\MapDcaListener
|
||||||
arguments:
|
arguments:
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::PARENT_ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::PARENT_ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
),
|
),
|
||||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||||
'sql' => 'varchar(255) NULL'
|
'sql' => 'varchar(255) NULL'
|
||||||
@@ -293,7 +293,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates']
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'maxlength' => 255,
|
'maxlength' => 255,
|
||||||
@@ -308,7 +308,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates']
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'maxlength' => 255,
|
'maxlength' => 255,
|
||||||
@@ -323,7 +323,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates']
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'maxlength' => 255,
|
'maxlength' => 255,
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
],
|
],
|
||||||
'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true],
|
'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true],
|
||||||
'sql' => 'varchar(255) NULL',
|
'sql' => 'varchar(255) NULL',
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias']
|
||||||
),
|
),
|
||||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||||
'sql' => 'varchar(255) NULL'
|
'sql' => 'varchar(255) NULL'
|
||||||
@@ -191,7 +191,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates'],
|
||||||
),
|
),
|
||||||
'wizard' => array(
|
'wizard' => array(
|
||||||
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'getGeocoder']
|
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'getGeocoder']
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
),
|
),
|
||||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||||
'sql' => 'varchar(255) NULL'
|
'sql' => 'varchar(255) NULL'
|
||||||
@@ -192,7 +192,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates'],
|
||||||
array('netzmacht.contao_leaflet_maps.listeners.dca.marker', 'saveCoordinates')
|
array('netzmacht.contao_leaflet_maps.listeners.dca.marker', 'saveCoordinates')
|
||||||
),
|
),
|
||||||
'load_callback' => array(
|
'load_callback' => array(
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
),
|
),
|
||||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||||
'sql' => 'varchar(255) NULL'
|
'sql' => 'varchar(255) NULL'
|
||||||
@@ -236,7 +236,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates']
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'maxlength' => 255,
|
'maxlength' => 255,
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_style'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
),
|
),
|
||||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||||
'sql' => 'varchar(255) NULL'
|
'sql' => 'varchar(255) NULL'
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
['title'],
|
['title'],
|
||||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||||
),
|
),
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateAlias'],
|
||||||
),
|
),
|
||||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||||
'sql' => 'varchar(255) NULL'
|
'sql' => 'varchar(255) NULL'
|
||||||
@@ -319,7 +319,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'text',
|
'inputType' => 'text',
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateCoordinates']
|
||||||
),
|
),
|
||||||
'wizard' => array(
|
'wizard' => array(
|
||||||
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'getGeocoder']
|
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'getGeocoder']
|
||||||
@@ -348,7 +348,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'search' => false,
|
'search' => false,
|
||||||
'eval' => array('mandatory' => true, 'alwaysSave' => true),
|
'eval' => array('mandatory' => true, 'alwaysSave' => true),
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateMultipleCoordinates')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateMultipleCoordinates']
|
||||||
),
|
),
|
||||||
'sql' => 'longblob NULL'
|
'sql' => 'longblob NULL'
|
||||||
),
|
),
|
||||||
@@ -373,7 +373,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
'save_callback' => array(
|
'save_callback' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateMultipleCoordinateSets')
|
['netzmacht.contao_leaflet_maps.listeners.dca.validator', 'validateMultipleCoordinateSets']
|
||||||
),
|
),
|
||||||
'sql' => 'longblob NULL'
|
'sql' => 'longblob NULL'
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user