Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -543,29 +543,29 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
if (class_exists('Symfony\Component\Validator\Validator')) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validator');

$dirs[] = dirname($r->getFilename()).'/Resources/translations';
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
}
if (class_exists('Symfony\Component\Form\Form')) {
$r = new \ReflectionClass('Symfony\Component\Form\Form');

$dirs[] = dirname($r->getFilename()).'/Resources/translations';
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
}
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');

if (file_exists(dirname($r->getFilename()).'/../composer.json')) {
if (file_exists(dirname($r->getFileName()).'/../composer.json')) {
// with Symfony 2.4, the Security component was split into several subpackages
// and the translations have been moved to the symfony/security-core package
$dirs[] = dirname($r->getFilename()).'/../Resources/translations';
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
} else {
// in Symfony 2.3, translations are located in the symfony/security package
$dirs[] = dirname($r->getFilename()).'/../../Resources/translations';
$dirs[] = dirname($r->getFileName()).'/../../Resources/translations';
}
}
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
$reflection = new \ReflectionClass($class);
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) {
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
$dirs[] = $dir;
}
if (is_dir($dir = sprintf($overridePath, $bundle))) {
Expand Down Expand Up @@ -645,7 +645,7 @@ private function getValidatorXmlMappingFiles(ContainerBuilder $container)

foreach ($container->getParameter('kernel.bundles') as $bundle) {
$reflection = new \ReflectionClass($bundle);
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.xml')) {
if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.xml')) {
$files[] = realpath($file);
$container->addResource(new FileResource($file));
}
Expand All @@ -660,7 +660,7 @@ private function getValidatorYamlMappingFiles(ContainerBuilder $container)

foreach ($container->getParameter('kernel.bundles') as $bundle) {
$reflection = new \ReflectionClass($bundle);
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.yml')) {
if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.yml')) {
$files[] = realpath($file);
$container->addResource(new FileResource($file));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,12 @@ public function testTranslator()
'->registerTranslatorConfiguration() finds Form translation resources'
);
$ref = new \ReflectionClass('Symfony\Component\Security\Core\SecurityContext');
$ref = dirname($ref->getFileName());
if (!file_exists($ref.'/composer.json')) {
$ref = dirname($ref);
}
$this->assertContains(
strtr(dirname(dirname($ref->getFileName())).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR),
strtr($ref.'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR),
$files,
'->registerTranslatorConfiguration() finds Security translation resources'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ public function testGetSetToken()
$context->setToken($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
$this->assertSame($token, $context->getToken());
}

public function testTranslationsAreNotInCore()
{
$this->assertFalse(file_exists(__DIR__.'/../../Core/Resources/translations/'));
}
}