Merge branch '2.7' into 2.8
* 2.7: [TwigBridge] fix tests Tag the FormFieldRegistry as being internal [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds [Validator] Added missing swedish translation [TranslationDebug] workaround for getFallbackLocales. [Translation] fixed nested fallback catalogue using multiple locales. fixed phpdoc [Command] Fixed method comments as phpDoc syntax
This commit is contained in:
commit
2cf474e2eb
@ -80,7 +80,13 @@ if ($this->env->isDebug()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EOTXT;
|
EOTXT;
|
||||||
$expected = preg_replace('/%(.*?)%/', PHP_VERSION_ID >= 50400 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected);
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
|
||||||
|
} elseif (PHP_VERSION_ID >= 50400) {
|
||||||
|
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
|
||||||
|
} else {
|
||||||
|
$expected = preg_replace('/%(.*?)%/', '$this->getContext($context, "$1")', $expected);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
||||||
}
|
}
|
||||||
@ -106,7 +112,14 @@ if ($this->env->isDebug()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EOTXT;
|
EOTXT;
|
||||||
$expected = preg_replace('/%(.*?)%/', PHP_VERSION_ID >= 50400 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected);
|
|
||||||
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
|
||||||
|
} elseif (PHP_VERSION_ID >= 50400) {
|
||||||
|
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
|
||||||
|
} else {
|
||||||
|
$expected = preg_replace('/%(.*?)%/', '$this->getContext($context, "$1")', $expected);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,10 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getVariableGetter($name)
|
protected function getVariableGetter($name)
|
||||||
{
|
{
|
||||||
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
return sprintf('($context["%s"] ?? null)', $name, $name);
|
||||||
|
}
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,10 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getVariableGetter($name)
|
protected function getVariableGetter($name)
|
||||||
{
|
{
|
||||||
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
return sprintf('($context["%s"] ?? null)', $name, $name);
|
||||||
|
}
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,10 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getVariableGetterWithoutStrictCheck($name)
|
protected function getVariableGetterWithoutStrictCheck($name)
|
||||||
{
|
{
|
||||||
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
return sprintf('($context["%s"] ?? null)', $name, $name);
|
||||||
|
}
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||||
}
|
}
|
||||||
@ -48,10 +52,14 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getVariableGetterWithStrictCheck($name)
|
protected function getVariableGetterWithStrictCheck($name)
|
||||||
{
|
{
|
||||||
if (version_compare(\Twig_Environment::VERSION, '2.0.0-DEV', '>=')) {
|
if (\Twig_Environment::MAJOR_VERSION >= 2) {
|
||||||
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name);
|
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
|
||||||
|
}
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.9",
|
"php": ">=5.3.9",
|
||||||
"twig/twig": "~1.27|~2.0"
|
"twig/twig": "~1.28|~2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/asset": "~2.7|~3.0.0",
|
"symfony/asset": "~2.7|~3.0.0",
|
||||||
|
@ -21,6 +21,8 @@ use Symfony\Component\HttpKernel\Kernel;
|
|||||||
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
use Symfony\Component\Translation\Translator;
|
use Symfony\Component\Translation\Translator;
|
||||||
|
use Symfony\Component\Translation\DataCollectorTranslator;
|
||||||
|
use Symfony\Component\Translation\LoggingTranslator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps finding unused or missing translation messages in a given locale
|
* Helps finding unused or missing translation messages in a given locale
|
||||||
@ -301,7 +303,7 @@ EOF
|
|||||||
{
|
{
|
||||||
$fallbackCatalogues = array();
|
$fallbackCatalogues = array();
|
||||||
$translator = $this->getContainer()->get('translator');
|
$translator = $this->getContainer()->get('translator');
|
||||||
if ($translator instanceof Translator) {
|
if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) {
|
||||||
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
|
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
|
||||||
if ($fallbackLocale === $locale) {
|
if ($fallbackLocale === $locale) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -205,8 +205,6 @@ class Command
|
|||||||
*
|
*
|
||||||
* @return int The command exit code
|
* @return int The command exit code
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @see setCode()
|
* @see setCode()
|
||||||
* @see execute()
|
* @see execute()
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,8 @@ use Symfony\Component\DomCrawler\Field\FormField;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an internal class that must not be used directly.
|
* This is an internal class that must not be used directly.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
class FormFieldRegistry
|
class FormFieldRegistry
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormEvent;
|
||||||
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\ReversedTransformer;
|
use Symfony\Component\Form\ReversedTransformer;
|
||||||
@ -54,6 +56,17 @@ class TimeType extends AbstractType
|
|||||||
|
|
||||||
if ('single_text' === $options['widget']) {
|
if ('single_text' === $options['widget']) {
|
||||||
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
|
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
|
||||||
|
|
||||||
|
// handle seconds ignored by user's browser when with_seconds enabled
|
||||||
|
// https://codereview.chromium.org/450533009/
|
||||||
|
if ($options['with_seconds']) {
|
||||||
|
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $e) {
|
||||||
|
$data = $e->getData();
|
||||||
|
if ($data && preg_match('/^\d{2}:\d{2}$/', $data)) {
|
||||||
|
$e->setData($data.':00');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$hourOptions = $minuteOptions = $secondOptions = array(
|
$hourOptions = $minuteOptions = $secondOptions = array(
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
|
@ -231,6 +231,22 @@ class TimeTypeTest extends TestCase
|
|||||||
$this->assertEquals('03', $form->getViewData());
|
$this->assertEquals('03', $form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSubmitWithSecondsAndBrowserOmissionSeconds()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
|
'input' => 'string',
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
$form->submit('03:04');
|
||||||
|
|
||||||
|
$this->assertEquals('03:04:00', $form->getData());
|
||||||
|
$this->assertEquals('03:04:00', $form->getViewData());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetDataWithoutMinutes()
|
public function testSetDataWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
|
@ -88,6 +88,20 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
|||||||
return $this->translator->getCatalogue($locale);
|
return $this->translator->getCatalogue($locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fallback locales.
|
||||||
|
*
|
||||||
|
* @return array $locales The fallback locales
|
||||||
|
*/
|
||||||
|
public function getFallbackLocales()
|
||||||
|
{
|
||||||
|
if ($this->translator instanceof Translator) {
|
||||||
|
return $this->translator->getFallbackLocales();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes through all unknown calls onto the translator object.
|
* Passes through all unknown calls onto the translator object.
|
||||||
*/
|
*/
|
||||||
|
@ -88,6 +88,20 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface
|
|||||||
return $this->translator->getCatalogue($locale);
|
return $this->translator->getCatalogue($locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fallback locales.
|
||||||
|
*
|
||||||
|
* @return array $locales The fallback locales
|
||||||
|
*/
|
||||||
|
public function getFallbackLocales()
|
||||||
|
{
|
||||||
|
if ($this->translator instanceof Translator) {
|
||||||
|
return $this->translator->getFallbackLocales();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes through all unknown calls onto the translator object.
|
* Passes through all unknown calls onto the translator object.
|
||||||
*/
|
*/
|
||||||
|
@ -273,6 +273,16 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$translator->trans('foo');
|
$translator->trans('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNestedFallbackCatalogueWhenUsingMultipleLocales()
|
||||||
|
{
|
||||||
|
$translator = new Translator('fr');
|
||||||
|
$translator->setFallbackLocales(array('ru', 'en'));
|
||||||
|
|
||||||
|
$translator->getCatalogue('fr');
|
||||||
|
|
||||||
|
$this->assertNotNull($translator->getCatalogue('ru')->getFallbackCatalogue());
|
||||||
|
}
|
||||||
|
|
||||||
public function testFallbackCatalogueResources()
|
public function testFallbackCatalogueResources()
|
||||||
{
|
{
|
||||||
$translator = new Translator('en_GB', new MessageSelector());
|
$translator = new Translator('en_GB', new MessageSelector());
|
||||||
|
@ -159,7 +159,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If a locale contains invalid characters
|
* @throws \InvalidArgumentException If a locale contains invalid characters
|
||||||
*
|
*
|
||||||
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead.
|
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead
|
||||||
*/
|
*/
|
||||||
public function setFallbackLocale($locales)
|
public function setFallbackLocale($locales)
|
||||||
{
|
{
|
||||||
@ -424,7 +424,7 @@ EOF
|
|||||||
|
|
||||||
foreach ($this->computeFallbackLocales($locale) as $fallback) {
|
foreach ($this->computeFallbackLocales($locale) as $fallback) {
|
||||||
if (!isset($this->catalogues[$fallback])) {
|
if (!isset($this->catalogues[$fallback])) {
|
||||||
$this->doLoadCatalogue($fallback);
|
$this->loadCatalogue($fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
|
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
|
||||||
|
@ -310,6 +310,10 @@
|
|||||||
<source>This value does not match the expected {{ charset }} charset.</source>
|
<source>This value does not match the expected {{ charset }} charset.</source>
|
||||||
<target>Detta värde har inte den förväntade teckenkodningen {{ charset }}.</target>
|
<target>Detta värde har inte den förväntade teckenkodningen {{ charset }}.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="81">
|
||||||
|
<source>This is not a valid Business Identifier Code (BIC).</source>
|
||||||
|
<target>Detta är inte en giltig BIC-kod.</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
@ -28,7 +28,7 @@ class Inline
|
|||||||
private static $objectForMap = false;
|
private static $objectForMap = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a YAML string to a PHP array.
|
* Converts a YAML string to a PHP value.
|
||||||
*
|
*
|
||||||
* @param string $value A YAML string
|
* @param string $value A YAML string
|
||||||
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||||
@ -36,7 +36,7 @@ class Inline
|
|||||||
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
||||||
* @param array $references Mapping of variable names to values
|
* @param array $references Mapping of variable names to values
|
||||||
*
|
*
|
||||||
* @return array A PHP array representing the YAML string
|
* @return mixed A PHP value
|
||||||
*
|
*
|
||||||
* @throws ParseException
|
* @throws ParseException
|
||||||
*/
|
*/
|
||||||
@ -90,7 +90,7 @@ class Inline
|
|||||||
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||||
* @param bool $objectSupport true if object support is enabled, false otherwise
|
* @param bool $objectSupport true if object support is enabled, false otherwise
|
||||||
*
|
*
|
||||||
* @return string The YAML string representing the PHP array
|
* @return string The YAML string representing the PHP value
|
||||||
*
|
*
|
||||||
* @throws DumpException When trying to dump PHP resource
|
* @throws DumpException When trying to dump PHP resource
|
||||||
*/
|
*/
|
||||||
@ -210,7 +210,7 @@ class Inline
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a scalar to a YAML string.
|
* Parses a YAML scalar.
|
||||||
*
|
*
|
||||||
* @param string $scalar
|
* @param string $scalar
|
||||||
* @param string $delimiters
|
* @param string $delimiters
|
||||||
@ -219,7 +219,7 @@ class Inline
|
|||||||
* @param bool $evaluate
|
* @param bool $evaluate
|
||||||
* @param array $references
|
* @param array $references
|
||||||
*
|
*
|
||||||
* @return string A YAML string
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws ParseException When malformed inline YAML string is parsed
|
* @throws ParseException When malformed inline YAML string is parsed
|
||||||
*
|
*
|
||||||
@ -271,12 +271,12 @@ class Inline
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a quoted scalar to YAML.
|
* Parses a YAML quoted scalar.
|
||||||
*
|
*
|
||||||
* @param string $scalar
|
* @param string $scalar
|
||||||
* @param int &$i
|
* @param int &$i
|
||||||
*
|
*
|
||||||
* @return string A YAML string
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws ParseException When malformed inline YAML string is parsed
|
* @throws ParseException When malformed inline YAML string is parsed
|
||||||
*/
|
*/
|
||||||
@ -301,13 +301,13 @@ class Inline
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a sequence to a YAML string.
|
* Parses a YAML sequence.
|
||||||
*
|
*
|
||||||
* @param string $sequence
|
* @param string $sequence
|
||||||
* @param int &$i
|
* @param int &$i
|
||||||
* @param array $references
|
* @param array $references
|
||||||
*
|
*
|
||||||
* @return string A YAML string
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws ParseException When malformed inline YAML string is parsed
|
* @throws ParseException When malformed inline YAML string is parsed
|
||||||
*/
|
*/
|
||||||
@ -360,13 +360,13 @@ class Inline
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a mapping to a YAML string.
|
* Parses a YAML mapping.
|
||||||
*
|
*
|
||||||
* @param string $mapping
|
* @param string $mapping
|
||||||
* @param int &$i
|
* @param int &$i
|
||||||
* @param array $references
|
* @param array $references
|
||||||
*
|
*
|
||||||
* @return string A YAML string
|
* @return array|\stdClass
|
||||||
*
|
*
|
||||||
* @throws ParseException When malformed inline YAML string is parsed
|
* @throws ParseException When malformed inline YAML string is parsed
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user