Merge branch '2.7' into 2.8
* 2.7: [Validator] Added Swedish translations improve exceptions when parsing malformed files Dispatch console.terminate *after* console.exception
This commit is contained in:
commit
4b68eb1f3e
@ -885,13 +885,15 @@ class Application
|
||||
try {
|
||||
$exitCode = $command->run($input, $output);
|
||||
} catch (\Exception $e) {
|
||||
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
|
||||
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
|
||||
|
||||
$e = $event->getException();
|
||||
|
||||
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
|
||||
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
|
||||
|
||||
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
|
||||
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
|
||||
|
||||
throw $event->getException();
|
||||
throw $e;
|
||||
}
|
||||
} else {
|
||||
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
|
||||
|
@ -884,7 +884,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo'));
|
||||
$this->assertEquals('before.foo.after.', $tester->getDisplay());
|
||||
$this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -920,7 +920,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo'));
|
||||
$this->assertContains('before.foo.after.caught.', $tester->getDisplay());
|
||||
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testRunWithDispatcherSkippingCommand()
|
||||
@ -965,14 +965,14 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
});
|
||||
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) {
|
||||
$event->getOutput()->write('after.');
|
||||
$event->getOutput()->writeln('after.');
|
||||
|
||||
if (!$skipCommand) {
|
||||
$event->setExitCode(113);
|
||||
}
|
||||
});
|
||||
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
|
||||
$event->getOutput()->writeln('caught.');
|
||||
$event->getOutput()->write('caught.');
|
||||
|
||||
$event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException()));
|
||||
});
|
||||
|
@ -53,7 +53,7 @@ class Debug
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
if ($displayErrors) {
|
||||
ErrorHandler::register(new ErrorHandler(new BufferingLogger()))->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
|
||||
ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
|
||||
} else {
|
||||
ErrorHandler::register()->throwAt(0, true);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
@ -324,7 +325,13 @@ class YamlFileLoader extends FileLoader
|
||||
$this->yamlParser = new YamlParser();
|
||||
}
|
||||
|
||||
return $this->validate($this->yamlParser->parse(file_get_contents($file)), $file);
|
||||
try {
|
||||
$configuration = $this->yamlParser->parse(file_get_contents($file));
|
||||
} catch (ParseException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
|
||||
}
|
||||
|
||||
return $this->validate($configuration, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Routing\Loader;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
|
||||
@ -60,7 +61,11 @@ class YamlFileLoader extends FileLoader
|
||||
$this->yamlParser = new YamlParser();
|
||||
}
|
||||
|
||||
$config = $this->yamlParser->parse(file_get_contents($path));
|
||||
try {
|
||||
$config = $this->yamlParser->parse(file_get_contents($path));
|
||||
} catch (ParseException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
|
||||
}
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->addResource(new FileResource($path));
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
@ -117,7 +118,11 @@ class YamlFileLoader extends FileLoader
|
||||
*/
|
||||
private function parseFile($path)
|
||||
{
|
||||
$classes = $this->yamlParser->parse(file_get_contents($path));
|
||||
try {
|
||||
$classes = $this->yamlParser->parse(file_get_contents($path));
|
||||
} catch (ParseException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid.', $path), 0, $e);
|
||||
}
|
||||
|
||||
// empty file
|
||||
if (null === $classes) {
|
||||
|
@ -302,6 +302,14 @@
|
||||
<source>An empty file is not allowed.</source>
|
||||
<target>En tom fil är inte tillåten.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="79">
|
||||
<source>The host could not be resolved.</source>
|
||||
<target>Värddatorn kunde inte hittas.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="80">
|
||||
<source>This value does not match the expected {{ charset }} charset.</source>
|
||||
<target>Detta värde har inte den förväntade teckenkodningen {{ charset }}.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
Reference in New Issue
Block a user