protected function loadResourcesFromDirs($dirs)
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig();
$whitelistRegexp = Kdyby\Translation\Translator::buildWhitelistRegexp($config['whitelist']);
$translator = $builder->getDefinition($this->prefix('default'));
$mask = array_map(function ($value) {
return '*.*.' . $value;
}, array_keys($this->loaders));
foreach (Finder::findFiles($mask)->from($dirs) as $file) {
/** @var \SplFileInfo $file */
if (!($m = Strings::match($file->getFilename(), '~^(?P<domain>.*?)\\.(?P<locale>[^\\.]+)\\.(?P<format>[^\\.]+)$~'))) {
continue;
}
if ($whitelistRegexp && !preg_match($whitelistRegexp, $m['locale']) && $builder->parameters['productionMode']) {
continue;
// ignore in production mode, there is no need to pass the ignored resources
}
$this->validateResource($m['format'], $file->getPathname(), $m['locale'], $m['domain']);
$translator->addSetup('addResource', [$m['format'], $file->getPathname(), $m['locale'], $m['domain']]);
$builder->addDependency($file->getPathname());
}
}