8000 Merge branch '2.3' into 2.7 · symfony/symfony@249d130 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 249d130

Browse files
Merge branch '2.3' into 2.7
* 2.3: [Validator] Added Swedish translations improve exceptions when parsing malformed files Dispatch console.terminate *after* console.exception Conflicts: src/Symfony/Component/Console/Application.php src/Symfony/Component/Console/Tests/ApplicationTest.php src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf
2 parents 4ecbc70 + 37827a2 commit 249d130

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,15 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
885885
try {
886886
$exitCode = $command->run($input, $output);
887887
} catch (\Exception $e) {
888+
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
889+
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
890+
891+
$e = $event->getException();
892+
888893
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
889894
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
890895

891-
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
892-
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
893-
894-
throw $event->getException();
896+
throw $e;
895897
}
896898
} else {
897899
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public function testRunWithDispatcher()
884884

885885
$tester = new ApplicationTester($application);
886886
$tester->run(array('command' => 'foo'));
887-
$this->assertEquals('before.foo.after.', $tester->getDisplay());
887+
$this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay());
888888
}
889889

890890
/**
@@ -920,7 +920,7 @@ public function testRunDispatchesAllEventsWithException()
920920

921921
$tester = new ApplicationTester($application);
922922
$tester->run(array('command' => 'foo'));
923-
$this->assertContains('before.foo.after.caught.', $tester->getDisplay());
923+
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
924924
}
925925

926926
public function testRunWithDispatcherSkippingCommand()
@@ -965,14 +965,14 @@ protected function getDispatcher($skipCommand = false)
965965
}
966966
});
967967
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) {
968-
$event->getOutput()->write('after.');
968+
$event->getOutput()->writeln('after.');
969969

970970
if (!$skipCommand) {
971971
$event->setExitCode(113);
972972
}
973973
});
974974
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
975-
$event->getOutput()->writeln('caught.');
975+
$event->getOutput()->write('caught.');
976976

977977
$event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException()));
978978
});

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2020
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2121
use Symfony\Component\Config\Resource\FileResource;
22+
use Symfony\Component\Yaml\Exception\ParseException;
2223
use Symfony\Component\Yaml\Parser as YamlParser;
2324
use Symfony\Component\ExpressionLanguage\Expression;
2425

@@ -316,7 +317,13 @@ protected function loadFile($file)
316317
$this->yamlParser = new YamlParser();
317318
}
318319

319-
return $this->validate($this->yamlParser->parse(file_get_contents($file)), $file);
320+
try {
321+
$configuration = $this->yamlParser->parse(file_get_contents($file));
322+
} catch (ParseException $e) {
323+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
324+
}
325+
326+
return $this->validate($configuration, $file);
320327
}
321328

322329
/**

src/Symfony/Component/Routing/Loader/YamlFileLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Routing\RouteCollection;
1515
use Symfony\Component\Routing\Route;
1616
use Symfony\Component\Config\Resource\FileResource;
17+
use Symfony\Component\Yaml\Exception\ParseException;
1718
use Symfony\Component\Yaml\Parser as YamlParser;
1819
use Symfony\Component\Config\Loader\FileLoader;
1920

@@ -60,7 +61,11 @@ public function load($file, $type = null)
6061
$this->yamlParser = new YamlParser();
6162
}
6263

63-
$config = $this->yamlParser->parse(file_get_contents($path));
64+
try {
65+
$config = $this->yamlParser->parse(file_get_contents($path));
66+
} catch (ParseException $e) {
67+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
68+
}
6469

6570
$collection = new RouteCollection();
6671
$collection->addResource(new FileResource($path));

src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Mapping\Loader;
1313

1414
use Symfony\Component\Validator\Mapping\ClassMetadata;
15+
use Symfony\Component\Yaml\Exception\ParseException;
1516
use Symfony\Component\Yaml\Parser as YamlParser;
1617

1718
/**
@@ -117,7 +118,11 @@ protected function parseNodes(array $nodes)
117118
*/
118119
private function parseFile($path)
119120
{
120-
$classes = $this->yamlParser->parse(file_get_contents($path));
121+
try {
122+
$classes = $this->yamlParser->parse(file_get_contents($path));
123+
} catch (ParseException $e) {
124+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid.', $path), 0, $e);
125+
}
121126

122127
// empty file
123128
if (null === $classes) {

src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@
302302
<source>An empty file is not allowed.</source>
303303
<target>En tom fil är inte tillåten.</target>
304304
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>Värddatorn kunde inte hittas.</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>Detta värde har inte den förväntade teckenkodningen {{ charset }}.</target>
312+
</trans-unit>
305313
</body>
306314
</file>
307315
</xliff>

0 commit comments

Comments
 (0)
0