Validate vector coordinates.

This commit is contained in:
David Molineus
2016-10-06 09:52:07 +02:00
parent a6ffe76134
commit d7d76913b1
2 changed files with 24 additions and 1 deletions

View File

@@ -339,6 +339,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
'inputType' => 'textarea', 'inputType' => 'textarea',
'search' => false, 'search' => false,
'eval' => array('mandatory' => true, 'alwaysSave' => true), 'eval' => array('mandatory' => true, 'alwaysSave' => true),
'save_callback' => array(
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateMultipleCoordinates')
),
'sql' => "longblob NULL" 'sql' => "longblob NULL"
), ),
'multiData' => array 'multiData' => array
@@ -361,6 +364,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
) )
) )
), ),
'save_callback' => array(
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateMultipleCoordinateSets')
),
'sql' => "longblob NULL" 'sql' => "longblob NULL"
), ),
'bounds' => array 'bounds' => array

View File

@@ -88,7 +88,24 @@ class Validator
} }
foreach ($lines as $coordinate) { foreach ($lines as $coordinate) {
LatLng::fromString($coordinate); $this->validateCoordinates($coordinate);
}
return $values;
}
/**
* Validate multiple coordinate sets.
*
* @param mixed $values Given value.
*
* @return mixed
*/
public function validateMultipleCoordinateSets($values)
{
$sets = deserialize($values, true);
foreach ($sets as $lines) {
$this->validateMultipleCoordinates($lines);
} }
return $values; return $values;