function AddAutoMappingConfigurationPass::getRegexp
Builds a regexp to check if a class is auto-mapped.
1 call to AddAutoMappingConfigurationPass::getRegexp()
- AddAutoMappingConfigurationPass::process in vendor/
symfony/ validator/ DependencyInjection/ AddAutoMappingConfigurationPass.php - You can modify the container here before it is dumped to PHP code.
File
-
vendor/
symfony/ validator/ DependencyInjection/ AddAutoMappingConfigurationPass.php, line 60
Class
- AddAutoMappingConfigurationPass
- Injects the automapping configuration as last argument of loaders tagged with the "validator.auto_mapper" tag.
Namespace
Symfony\Component\Validator\DependencyInjectionCode
private function getRegexp(array $patterns) : ?string {
if (!$patterns) {
return null;
}
$regexps = [];
foreach ($patterns as $pattern) {
// Escape namespace
$regex = preg_quote(ltrim($pattern, '\\'));
// Wildcards * and **
$regex = strtr($regex, [
'\\*\\*' => '.*?',
'\\*' => '[^\\\\]*?',
]);
// If this class does not end by a slash, anchor the end
if (!str_ends_with($regex, '\\')) {
$regex .= '$';
}
$regexps[] = '^' . $regex;
}
return \sprintf('{%s}', implode('|', $regexps));
}