forked from Snck3rs/contao-leaflet-maps
Support local aliases (close #33).
This commit is contained in:
@@ -170,6 +170,33 @@ $container[LeafletServices::ALIAS_GENERATOR] = $container->share(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Leaflet alias generator.
|
||||
*
|
||||
* @return \Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator
|
||||
*/
|
||||
$container[LeafletServices::PARENT_ALIAS_GENERATOR] = $container->share(
|
||||
function ($container) {
|
||||
return function ($dataContainerName, $aliasField, $fields) use ($container) {
|
||||
$filters = [
|
||||
new ExistingAliasFilter(),
|
||||
new SlugifyFilter($fields),
|
||||
new DefaultAliasFilter($dataContainerName),
|
||||
new SuffixFilter(),
|
||||
];
|
||||
|
||||
$validator = new UniqueDatabaseValueValidator(
|
||||
$container[Services::DATABASE_CONNECTION],
|
||||
$dataContainerName,
|
||||
$aliasField,
|
||||
['pid']
|
||||
);
|
||||
|
||||
return new FilterBasedAliasGenerator($filters, $validator, $dataContainerName, $aliasField, '_');
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Callback helper class for tl_leaflet_map.
|
||||
*
|
||||
|
||||
@@ -22,7 +22,6 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
|
||||
(
|
||||
'id' => 'primary',
|
||||
'pid' => 'index',
|
||||
'alias' => 'unique',
|
||||
)
|
||||
)
|
||||
),
|
||||
@@ -167,12 +166,12 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
|
||||
'tl_leaflet_control',
|
||||
'alias',
|
||||
['title'],
|
||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR
|
||||
\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::PARENT_ALIAS_GENERATOR
|
||||
),
|
||||
\Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'),
|
||||
),
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'nullIfEmpty' => true),
|
||||
'sql' => "varchar(255) NULL"
|
||||
),
|
||||
'type' => array
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user