Merge branch '2.5' into 2.6

* 2.5:
  [Validator] use 2.5 API in LengthValidator
  fixed id for translations
  bumped Symfony version to 2.3.26
  Dutch translation for invalid charset message
  German translation for invalid charset message
  Add a Slovenian translation for invalid charset message
  Add a Polish translation.
  Test lowest deps with latest 5.3
  updated VERSION for 2.3.25
  update CONTRIBUTORS for 2.3.25
  updated CHANGELOG for 2.3.25
  Fix docblocks to comments
  Inject the correct EventDispatcher instance
  [Validator] reject ill-formed strings
  [Validator] drop grapheme_strlen in LengthValidator
  Unique Entity Validator Invalid Value
  [FrameworkBundle][config] allow multiple fallback locales.

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
	src/Symfony/Component/Validator/Resources/translations/validators.de.xlf
	src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
	src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf
	src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf
	src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf
	src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf
This commit is contained in:
Nicolas Grekas 2015-02-01 17:10:57 +01:00
commit c47bbbe5d3
31 changed files with 273 additions and 148 deletions

View File

@ -7,7 +7,7 @@ matrix:
- php: 5.4
- php: 5.5
- php: 5.6
- php: 5.3.3
- php: 5.3
env: components=low
- php: 5.6
env: components=high

View File

@ -7,6 +7,28 @@ in 2.3 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1
* 2.3.25 (2015-01-30)
* bug #13528 [Validator] reject ill-formed strings (nicolas-grekas)
* bug #13525 [Validator] UniqueEntityValidator - invalidValue fixed. (Dawid Sajdak)
* bug #13527 [Validator] drop grapheme_strlen in LengthValidator (nicolas-grekas)
* bug #13376 [FrameworkBundle][config] allow multiple fallback locales. (aitboudad)
* bug #12972 Make the container considered non-fresh if the environment parameters are changed (thewilkybarkid)
* bug #13309 [Console] fixed 10531 (nacmartin)
* bug #13352 [Yaml] fixed parse shortcut Key after unindented collection. (aitboudad)
* bug #13039 [HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info (rk3rn3r)
* bug #13250 [Twig][Bridge][TranslationDefaultDomain] add support of named arguments. (aitboudad)
* bug #13332 [Console] ArgvInput and empty tokens (Taluu)
* bug #13293 [EventDispatcher] Add missing checks to RegisterListenersPass (znerol)
* bug #13262 [Yaml] Improve YAML boolean escaping (petert82, larowlan)
* bug #13420 [Debug] fix loading order for legacy classes (nicolas-grekas)
* bug #13371 fix missing comma in YamlDumper (garak)
* bug #13365 [HttpFoundation] Make use of isEmpty() method (xelaris)
* bug #13347 [Console] Helper\TableHelper->addRow optimization (boekkooi)
* bug #13346 [PropertyAccessor] Allow null value for a array (2.3) (boekkooi)
* bug #13170 [Form] Set a child type to text if added to the form without a type. (jakzal)
* bug #13334 [Yaml] Fixed #10597: Improved Yaml directive parsing (VictoriaQ)
* 2.3.24 (2015-01-07)
* bug #13286 [Security] Don't destroy the session on buggy php releases. (derrabus)

View File

@ -13,19 +13,19 @@ Symfony is the result of the work of many people who made the code better
- Kris Wallsmith (kriswallsmith)
- Christophe Coevoet (stof)
- Nicolas Grekas (nicolas-grekas)
- Pascal Borreli (pborreli)
- Jakub Zalas (jakubzalas)
- Pascal Borreli (pborreli)
- Hugo Hamon (hhamon)
- Karma Dordrak (drak)
- Joseph Bielawski (stloyd)
- Hugo Hamon (hhamon)
- Ryan Weaver (weaverryan)
- Lukas Kahwe Smith (lsmith)
- Romain Neutron (romain)
- Jeremy Mikola (jmikola)
- Jean-François Simon (jfsimon)
- Christian Flothmann (xabbuh)
- Benjamin Eberlei (beberlei)
- Igor Wiedler (igorw)
- Christian Flothmann (xabbuh)
- Martin Hasoň (hason)
- Eriksen Costa (eriksencosta)
- Jonathan Wage (jwage)
@ -33,9 +33,9 @@ Symfony is the result of the work of many people who made the code better
- Alexandre Salomé (alexandresalome)
- William Durand (couac)
- ornicar
- Wouter De Jong (wouterj)
- stealth35 (stealth35)
- Alexander Mols (asm89)
- Wouter De Jong (wouterj)
- Bulat Shakirzyanov (avalanche123)
- Francis Besset (francisbesset)
- Saša Stamenković (umpirsky)
@ -44,15 +44,15 @@ Symfony is the result of the work of many people who made the code better
- Konstantin Kudryashov (everzet)
- Bilal Amarni (bamarni)
- Florin Patan (florinpatan)
- Abdellatif Ait Boudad (aitboudad)
- Eric Clemmons (ericclemmons)
- Sarah Khalil (saro0h)
- Andrej Hudec (pulzarraider)
- Deni
- Henrik Westphal (snc)
- Dariusz Górecki (canni)
- Arnout Boks (aboks)
- Christian Raue
- Sarah Khalil (saro0h)
- Ait Boudad Abdellatif (aitboudad)
- Michel Weimerskirch (mweimerskirch)
- Lee McDermott
- Brandon Turner
@ -69,6 +69,7 @@ Symfony is the result of the work of many people who made the code better
- Kevin Bond (kbond)
- Tim Nagel (merk)
- Brice BERNARD (brikou)
- Kévin Dunglas (dunglas)
- marc.weistroff
- lenar
- Graham Campbell (graham)
@ -81,7 +82,7 @@ Symfony is the result of the work of many people who made the code better
- Jérôme Tamarelle (gromnan)
- Adrien Brault (adrienbrault)
- Fabien Pennequin (fabienpennequin)
- Kévin Dunglas (dunglas)
- Peter Kokot (maastermedia)
- Michal Piotrowski (eventhorizon)
- Gordon Franke (gimler)
- Robert Schönthal (digitalkaoz)
@ -89,13 +90,13 @@ Symfony is the result of the work of many people who made the code better
- Sebastian Hörl (blogsh)
- Daniel Gomes (danielcsgomes)
- Hidenori Goto (hidenorigoto)
- Peter Kokot (maastermedia)
- David Buchmann (dbu)
- Jérémy DERUSSÉ (jderusse)
- Pablo Godel (pgodel)
- Eric GELOEN (gelo)
- Peter Rehm (rpet)
- Jérémie Augustin (jaugustin)
- Rafael Dohms (rdohms)
- Jérémy DERUSSÉ (jderusse)
- Stefano Sala (stefano.sala)
- Tigran Azatyan (tigranazatyan)
- Javier Eguiluz (javier.eguiluz)
@ -113,7 +114,6 @@ Symfony is the result of the work of many people who made the code better
- Rouven Weßling (realityking)
- Dmitrii Chekaliuk (lazyhammer)
- Clément JOBEILI (dator)
- Peter Rehm (rpet)
- Dorian Villet (gnutix)
- Richard Miller (mr_r_miller)
- Arnaud Kleinpeter (nanocom)
@ -130,25 +130,27 @@ Symfony is the result of the work of many people who made the code better
- bronze1man
- sun (sun)
- Larry Garfield (crell)
- Issei Murasawa (issei_m)
- Martin Schuhfuß (usefulthink)
- Thomas Rabaix (rande)
- Matthieu Bontemps (mbontemps)
- Pierre Minnieur (pminnieur)
- fivestar
- Dominique Bongiraud
- Iltar van der Berg
- Leszek Prabucki (l3l0)
- François Zaninotto (fzaninotto)
- Dustin Whittle (dustinwhittle)
- jeff
- Justin Hileman (bobthecow)
- Sven Paulus (subsven)
- Alexander Schwenn (xelaris)
- Lars Strojny (lstrojny)
- Rui Marinho (ruimarinho)
- Julien Brochet (mewt)
- Tugdual Saunier (tucksaun)
- Sergey Linnik (linniksa)
- Marcel Beerta (mazen)
- Iltar van der Berg
- Francois Zaninotto
- Alexander Kotynia (olden)
- Daniel Tschinder
@ -158,6 +160,7 @@ Symfony is the result of the work of many people who made the code better
- Roman Marintšenko (inori)
- Xavier Montaña Carreras (xmontana)
- Michele Orselli (orso)
- Chris Wilkinson (thewilkybarkid)
- Xavier Perez
- Arjen Brouwer (arjenjb)
- Katsuhiro OGAWA
@ -167,7 +170,6 @@ Symfony is the result of the work of many people who made the code better
- Joseph Rouff (rouffj)
- Félix Labrecque (woodspire)
- GordonsLondon
- Issei Murasawa (issei_m)
- Jan Sorgalla (jsor)
- Ray
- Chekote
@ -181,10 +183,13 @@ Symfony is the result of the work of many people who made the code better
- Beau Simensen (simensen)
- Robert Kiss (kepten)
- Kim Hemsø Rasmussen (kimhemsoe)
- Florian Lonqueu-Brochard (florianlb)
- Tom Van Looy (tvlooy)
- Wouter Van Hecke
- Joshua Thijssen
- Peter Kruithof (pkruithof)
- Michael Holm (hollo)
- Warnar Boekkooi (boekkooi)
- Marc Weistroff (futurecat)
- Chris Smith (cs278)
- Florian Klein (docteurklein)
@ -195,10 +200,10 @@ Symfony is the result of the work of many people who made the code better
- Bertrand Zuchuat (garfield-fr)
- Gabor Toth (tgabi333)
- realmfoo
- Chris Wilkinson (thewilkybarkid)
- Thomas Tourlourat (armetiz)
- Andrey Esaulov (andremaha)
- Grégoire Passault (gregwar)
- Mikael Pajunen
- Uwe Jäger (uwej711)
- Aurelijus Valeiša (aurelijus)
- Jan Decavele (jandc)
@ -219,7 +224,6 @@ Symfony is the result of the work of many people who made the code better
- alquerci
- Francesco Levorato
- Vitaliy Zakharov (zakharovvi)
- Florian Lonqueu-Brochard (florianlb)
- Gyula Sallai (salla)
- Inal DJAFAR (inalgnu)
- Christian Gärtner (dagardner)
@ -227,7 +231,6 @@ Symfony is the result of the work of many people who made the code better
- Yaroslav Kiliba
- Sébastien Lavoie (lavoiesl)
- Terje Bråten
- Joshua Thijssen
- Kristen Gilden (kgilden)
- Robbert Klarenbeek (robbertkl)
- Blanchon Vincent (blanchonvincent)
@ -239,6 +242,7 @@ Symfony is the result of the work of many people who made the code better
- Philipp Kräutli (pkraeutli)
- Kirill chEbba Chebunin (chebba)
- Greg Thornton (xdissent)
- Baptiste Clavié (talus)
- Grégoire Paris (greg0ire)
- Costin Bereveanu (schniper)
- Loïc Chardonnet (gnusat)
@ -246,7 +250,6 @@ Symfony is the result of the work of many people who made the code better
- Vyacheslav Salakhutdinov (megazoll)
- Alex Pott
- Tamas Szijarto
- Mikael Pajunen
- Pavel Volokitin (pvolok)
- Endre Fejes
- Tobias Naumann (tna)
@ -254,6 +257,7 @@ Symfony is the result of the work of many people who made the code better
- Shein Alexey
- Joe Lencioni
- Kai
- Lee Rowlands
- Maximilian Reichel (phramz)
- Karoly Negyesi (chx)
- Xavier HAUSHERR
@ -275,6 +279,7 @@ Symfony is the result of the work of many people who made the code better
- Michel Salib (michelsalib)
- geoffrey
- Matthieu Auger (matthieuauger)
- Lorenz Schori
- Jeanmonod David (jeanmonod)
- Jan Schumann
- Niklas Fiekas
@ -287,6 +292,7 @@ Symfony is the result of the work of many people who made the code better
- Konstantin Myakshin (koc)
- vagrant
- Asier Illarramendi (doup)
- Alexander M. Turek (derrabus)
- Chris Sedlmayr (catchamonkey)
- Seb Koelen
- Christoph Mewes (xrstf)
@ -306,7 +312,6 @@ Symfony is the result of the work of many people who made the code better
- Jérôme Macias (jeromemacias)
- Fabian Lange (codingfabian)
- Yoshio HANAWA
- Baptiste Clavié (talus)
- Sebastian Bergmann
- Pablo Díez (pablodip)
- Kevin McBride
@ -337,6 +342,7 @@ Symfony is the result of the work of many people who made the code better
- Nils Adermann (naderman)
- Gábor Fási
- Benjamin Leveque (benji07)
- Javier Spagnoletti (phansys)
- sasezaki
- Dawid Pakuła (zulusx)
- Florian Rey (nervo)
@ -348,6 +354,7 @@ Symfony is the result of the work of many people who made the code better
- Ryan
- Alexander Deruwe (aderuwe)
- François Pluchino (francoispluchino)
- Massimiliano Arione (garak)
- Ivan Rey (ivanrey)
- Marcin Chyłek (songoq)
- Ned Schwartz
@ -356,12 +363,10 @@ Symfony is the result of the work of many people who made the code better
- Zach Badgett (zachbadgett)
- Aurélien Fredouelle
- Pavel Campr (pcampr)
- Alexander Schwenn (xelaris)
- Disquedur
- Geoffrey Tran (geoff)
- Jan Behrens
- Sebastian Krebs
- Lorenz Schori
- Christopher Davis (chrisguitarguy)
- Thomas Lallement (raziel057)
- alcaeus
@ -386,8 +391,6 @@ Symfony is the result of the work of many people who made the code better
- Javier López (loalf)
- Reinier Kip
- Dustin Dobervich (dustin10)
- Warnar Boekkooi
- Alexander M. Turek (derrabus)
- Sebastian Marek (proofek)
- Erkhembayar Gantulga (erheme318)
- David Fuhr
@ -410,6 +413,7 @@ Symfony is the result of the work of many people who made the code better
- Antoine Corcy
- Arturs Vonda
- Sascha Grossenbacher
- Szijarto Tamas
- Ben Davies (bendavies)
- Simon Schick (simonsimcity)
- redstar504
@ -472,7 +476,6 @@ Symfony is the result of the work of many people who made the code better
- Loick Piera (pyrech)
- cgonzalez
- Ben
- Lee Rowlands
- Jayson Xu (superjavason)
- Jaik Dean (jaikdean)
- Harm van Tilborg
@ -490,7 +493,6 @@ Symfony is the result of the work of many people who made the code better
- frost-nzcr4
- Abhoryo
- Fabian Vogler (fabian)
- Javier Spagnoletti (phansys)
- Korvin Szanto
- Maksim Kotlyar (makasim)
- Neil Ferreira
@ -538,7 +540,6 @@ Symfony is the result of the work of many people who made the code better
- Maks
- Gábor Tóth
- Daniel Cestari
- Massimiliano Arione (garak)
- Brunet Laurent (lbrunet)
- Magnus Nordlander (magnusnordlander)
- Mikhail Yurasov (mym)
@ -597,6 +598,7 @@ Symfony is the result of the work of many people who made the code better
- Per Sandström (per)
- Goran Juric
- Laurent Ghirardotti (laurentg)
- Jan Rosier (rosier)
- Lin Clark
- Jeremy David (jeremy.david)
- Troy McCabe
@ -604,6 +606,7 @@ Symfony is the result of the work of many people who made the code better
- Boris Vujicic (boris.vujicic)
- Max Beutel
- Catalin Dan
- nacho
- Piotr Antosik (antek88)
- Artem Lopata
- Marcos Quesada (marcos_quesada)
@ -658,7 +661,6 @@ Symfony is the result of the work of many people who made the code better
- Yannick
- Luc Vieillescazes (iamluc)
- Eduardo García Sanz (coma)
- Szijarto Tamas
- Roy Van Ginneken
- David de Boer (ddeboer)
- Gilles Doge (gido)
@ -673,6 +675,7 @@ Symfony is the result of the work of many people who made the code better
- Derek Lambert
- MightyBranch
- Kacper Gunia (cakper)
- Peter Thompson (petert82)
- Felicitus
- Krzysztof Przybyszewski
- Paul Matthews
@ -700,6 +703,7 @@ Symfony is the result of the work of many people who made the code better
- Aharon Perkel
- Abdul.Mohsen B. A. A
- Benoît Burnichon
- pthompson
- Malaney J. Hill
- Christian Flach (cmfcmf)
- Cédric Girard (enk_)
@ -738,6 +742,7 @@ Symfony is the result of the work of many people who made the code better
- Jason Desrosiers
- m.chwedziak
- Lance McNearney
- Frank Neff (fneff)
- Giorgio Premi
- caponica
- Matt Daum (daum)
@ -784,6 +789,7 @@ Symfony is the result of the work of many people who made the code better
- Klaus Silveira (klaussilveira)
- Thomas Chmielowiec (chmielot)
- Jānis Lukss
- rkerner
- Vladyslav Petrovych
- Matthew J Mucklo
- fdgdfg (psampaz)
@ -832,6 +838,7 @@ Symfony is the result of the work of many people who made the code better
- Przemysław Piechota (kibao)
- Leonid Terentyev (li0n)
- Adam Prager (padam87)
- victoria
- Francisco Facioni (fran6co)
- Iwan van Staveren (istaveren)
- Povilas S. (povilas)
@ -912,6 +919,7 @@ Symfony is the result of the work of many people who made the code better
- Daan van Renterghem
- Bram Van der Sype (brammm)
- Julien Moulin (lizjulien)
- Nikita Nefedov (nikita2206)
- Yannick Warnier (ywarnier)
- Kevin Decherf
- Jason Woods
@ -958,6 +966,7 @@ Symfony is the result of the work of many people who made the code better
- Florian Pfitzer (marmelatze)
- Martin Mayer (martin)
- Grzegorz Łukaszewicz (newicz)
- Richard van Laak (rvanlaak)
- grifx
- Robert Campbell
- Matt Lehner
@ -965,6 +974,7 @@ Symfony is the result of the work of many people who made the code better
- Ruben Kruiswijk
- Michael J
- Berny Cantos
- Joseph Maarek
- Alex Pods
- timaschew
- Ian Phillips
@ -1020,6 +1030,7 @@ Symfony is the result of the work of many people who made the code better
- Pablo Monterde Perez (plebs)
- Jimmy Leger (redpanda)
- Cyrille Jouineau (tuxosaurus)
- Vadim Kharitonov (virtuozzz)
- Yorkie Chadwick (yorkie76)
- Yanick Witschi
- Ondrej Mirtes
@ -1128,6 +1139,7 @@ Symfony is the result of the work of many people who made the code better
- Andreas Forsblom (aforsblo)
- Alaattin Kahramanlar (alaattin)
- Alex Olmos (alexolmos)
- Alain Hippolyte (aloneh)
- Antonio Mansilla (amansilla)
- Juan Ases García (ases)
- Daniel Basten (axhm3a)

View File

@ -244,35 +244,34 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
->assertRaised();
}
public function testValidateUniquenessAfterConsideringMultipleQueryResults()
public function testValidateUniquenessWithValidCustomErrorPath()
{
$constraint = new UniqueEntity(array(
'message' => 'myMessage',
'fields' => array('name'),
'fields' => array('name', 'name2'),
'em' => self::EM_NAME,
'errorPath' => "name2",
));
$entity1 = new SingleIntIdEntity(1, 'Foo');
$entity2 = new SingleIntIdEntity(2, 'Foo');
$entity1 = new DoubleNameEntity(1, 'Foo', "Bar");
$entity2 = new DoubleNameEntity(2, 'Foo', "Bar");
$this->validator->validate($entity1, $constraint);
$this->assertNoViolation();
$this->em->persist($entity1);
$this->em->persist($entity2);
$this->em->flush();
$this->validator->validate($entity1, $constraint);
$this->buildViolation('myMessage')
->atPath('property.path.name')
->setInvalidValue('Foo')
->assertRaised();
$this->context->getViolations()->remove(0);
$this->assertNoViolation();
$this->validator->validate($entity2, $constraint);
$this->buildViolation('myMessage')
->atPath('property.path.name')
->setInvalidValue('Foo')
->atPath('property.path.name2')
->setInvalidValue('Bar')
->assertRaised();
}

View File

@ -132,10 +132,11 @@ class UniqueEntityValidator extends ConstraintValidator
}
$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
$invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]];
$this->buildViolation($constraint->message)
->atPath($errorPath)
->setInvalidValue($criteria[$fields[0]])
->setInvalidValue($invalidValue)
->addViolation();
}
}

View File

@ -184,7 +184,7 @@ class ModelChoiceList extends ObjectChoiceList
return array();
}
/**
/*
* This performance optimization reflects a common scenario:
* * A simple select of a model entry.
* * The choice option "expanded" is set to false.
@ -239,7 +239,7 @@ class ModelChoiceList extends ObjectChoiceList
}
if (!$this->loaded) {
/**
/*
* This performance optimization assumes the validation of the respective values will be done by other means.
*
* It correlates with the performance optimization in {@link ModelChoiceList::getChoicesForValues()}

View File

@ -449,8 +449,13 @@ class Configuration implements ConfigurationInterface
->arrayNode('translator')
->info('translator configuration')
->canBeEnabled()
->fixXmlConfig('fallback')
->children()
->scalarNode('fallback')->defaultValue('en')->end()
->arrayNode('fallbacks')
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
->prototype('scalar')->end()
->defaultValue(array('en'))
->end()
->booleanNode('logging')->defaultValue($this->debug)->end()
->end()
->end()

View File

@ -298,7 +298,7 @@ class FrameworkExtension extends Extension
'memcached' => 'Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage',
'redis' => 'Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage',
);
list($class,) = explode(':', $config['dsn'], 2);
list($class, ) = explode(':', $config['dsn'], 2);
if (!isset($supported[$class])) {
throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.', $class));
}
@ -633,10 +633,7 @@ class FrameworkExtension extends Extension
// Use the "real" translator instead of the identity default
$container->setAlias('translator', 'translator.default');
$translator = $container->findDefinition('translator.default');
if (!is_array($config['fallback'])) {
$config['fallback'] = array($config['fallback']);
}
$translator->addMethodCall('setFallbackLocales', array($config['fallback']));
$translator->addMethodCall('setFallbackLocales', array($config['fallbacks']));
$container->setParameter('translator.logging', $config['logging']);

View File

@ -157,6 +157,9 @@
</xsd:complexType>
<xsd:complexType name="translator">
<xsd:sequence>
<xsd:element name="fallback" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="fallback" type="xsd:string" />
<xsd:attribute name="logging" type="xsd:boolean" />

View File

@ -122,7 +122,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
),
'translator' => array(
'enabled' => false,
'fallback' => 'en',
'fallbacks' => array('en'),
'logging' => true,
),
'validation' => array(

View File

@ -0,0 +1,7 @@
<?php
$container->loadFromExtension('framework', array(
'translator' => array(
'fallbacks' => array('en', 'fr'),
),
));

View File

@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:translator enabled="true">
<framework:fallback>en</framework:fallback>
<framework:fallback>fr</framework:fallback>
</framework:translator>
</framework:config>
</container>

View File

@ -0,0 +1,3 @@
framework:
translator:
fallbacks: [en, fr]

View File

@ -261,6 +261,14 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals(array('fr'), $calls[0][1][0]);
}
public function testTranslatorMultipleFullback()
{
$container = $this->createContainerFromFile('translator_fallbacks');
$calls = $container->getDefinition('translator.default')->getMethodCalls();
$this->assertEquals(array('en', 'fr'), $calls[0][1][0]);
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/

View File

@ -216,7 +216,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->dispatcher->removeListener($eventName, $listener);
$info = $this->getListenerInfo($listener, $eventName);
$name = isset($info['class']) ? $info['class'] : $info['type'];
$this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch));
$this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch, $this));
}
}

View File

@ -25,12 +25,14 @@ class WrappedListener
private $called;
private $stoppedPropagation;
private $stopwatch;
private $dispatcher;
public function __construct($listener, $name, Stopwatch $stopwatch)
public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
{
$this->listener = $listener;
$this->name = $name;
$this->stopwatch = $stopwatch;
$this->dispatcher = $dispatcher;
$this->called = false;
$this->stoppedPropagation = false;
}
@ -56,7 +58,7 @@ class WrappedListener
$e = $this->stopwatch->start($this->name, 'event_listener');
call_user_func($this->listener, $event, $eventName, $dispatcher);
call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
if ($e->isStarted()) {
$e->stop();

View File

@ -86,6 +86,20 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
}
public function testGetCalledListenersNested()
{
$tdispatcher = null;
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
$dispatcher->addListener('foo', function (Event $event, $eventName, $dispatcher) use (&$tdispatcher) {
$tdispatcher = $dispatcher;
$dispatcher->dispatch('bar');
});
$dispatcher->addListener('bar', function (Event $event) {});
$dispatcher->dispatch('foo');
$this->assertSame($dispatcher, $tdispatcher);
$this->assertCount(2, $dispatcher->getCalledListeners());
}
public function testLogger()
{
$logger = $this->getMock('Psr\Log\LoggerInterface');

View File

@ -11,11 +11,8 @@
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
/**
* Adds SessionHandler functionality if available.
*
* @see http://php.net/sessionhandler
*/
// Adds SessionHandler functionality if available.
// @see http://php.net/sessionhandler
if (PHP_VERSION_ID >= 50400) {
class NativeSessionHandler extends \SessionHandler
{

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\Exception;
/**
/*
* Fatal Error Exception.
*
* @author Konstanton Myakshin <koc-dp@yandex.ru>

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\Exception;
/**
/*
* FlattenException wraps a PHP Exception to be able to serialize it.
*
* Basically, this class removes all objects from the trace.

View File

@ -373,11 +373,9 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
} elseif ($key === '#') {
$append = $this->selectNodeType($parentNode, $data);
} elseif (is_array($data) && false === is_numeric($key)) {
/**
* Is this array fully numeric keys?
*/
// Is this array fully numeric keys?
if (ctype_digit(implode('', array_keys($data)))) {
/**
/*
* Create nodes to append to $parentNode based on the $key of this array
* Produces <xml><item>0</item><item>1</item></xml>
* From array("item" => array(0,1));.

View File

@ -27,72 +27,52 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
class CardSchemeValidator extends ConstraintValidator
{
protected $schemes = array(
/**
* American Express card numbers start with 34 or 37 and have 15 digits.
*/
// American Express card numbers start with 34 or 37 and have 15 digits.
'AMEX' => array(
'/^3[47][0-9]{13}$/',
),
/**
* China UnionPay cards start with 62 and have between 16 and 19 digits.
* Please note that these cards do not follow Luhn Algorithm as a checksum.
*/
// China UnionPay cards start with 62 and have between 16 and 19 digits.
// Please note that these cards do not follow Luhn Algorithm as a checksum.
'CHINA_UNIONPAY' => array(
'/^62[0-9]{14,17}$/',
),
/**
* Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits.
* There are Diners Club cards that begin with 5 and have 16 digits.
* These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard.
*/
// Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits.
// There are Diners Club cards that begin with 5 and have 16 digits.
// These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard.
'DINERS' => array(
'/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',
),
/**
* Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65.
* All have 16 digits.
*/
// Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65.
// All have 16 digits.
'DISCOVER' => array(
'/^6011[0-9]{12}$/',
'/^64[4-9][0-9]{13}$/',
'/^65[0-9]{14}$/',
'/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/',
),
/**
* InstaPayment cards begin with 637 through 639 and have 16 digits.
*/
// InstaPayment cards begin with 637 through 639 and have 16 digits.
'INSTAPAYMENT' => array(
'/^63[7-9][0-9]{13}$/',
),
/**
* JCB cards beginning with 2131 or 1800 have 15 digits.
* JCB cards beginning with 35 have 16 digits.
*/
// JCB cards beginning with 2131 or 1800 have 15 digits.
// JCB cards beginning with 35 have 16 digits.
'JCB' => array(
'/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/',
),
/**
* Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits.
*/
// Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits.
'LASER' => array(
'/^(6304|670[69]|6771)[0-9]{12,15}$/',
),
/**
* Maestro cards begin with either 5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763 or 0604
* They have between 12 and 19 digits.
*/
// Maestro cards begin with either 5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763 or 0604
// They have between 12 and 19 digits.
'MAESTRO' => array(
'/^(5018|5020|5038|6304|6759|6761|676[23]|0604)[0-9]{8,15}$/',
),
/**
* All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
*/
// All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
'MASTERCARD' => array(
'/^5[1-5][0-9]{14}$/',
),
/**
* All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
*/
// All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
'VISA' => array(
'/^4([0-9]{12}|[0-9]{15})$/',
),

View File

@ -35,6 +35,7 @@ class Length extends Constraint
public $maxMessage = 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.';
public $minMessage = 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.';
public $exactMessage = 'This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.';
public $charsetMessage = 'This value does not match the expected {{ charset }} charset.';
public $max;
public $min;
public $charset = 'UTF-8';

View File

@ -38,13 +38,39 @@ class LengthValidator extends ConstraintValidator
}
$stringValue = (string) $value;
$invalidCharset = false;
if (function_exists('grapheme_strlen') && 'UTF-8' === $constraint->charset) {
$length = grapheme_strlen($stringValue);
if ('UTF8' === $charset = strtoupper($constraint->charset)) {
$charset = 'UTF-8';
}
if (function_exists('iconv_strlen')) {
$length = @iconv_strlen($stringValue, $constraint->charset);
$invalidCharset = false === $length;
} elseif (function_exists('mb_strlen')) {
$length = mb_strlen($stringValue, $constraint->charset);
} else {
if (mb_check_encoding($stringValue, $constraint->charset)) {
$length = mb_strlen($stringValue, $constraint->charset);
} else {
$invalidCharset = true;
}
} elseif ('UTF-8' !== $charset) {
$length = strlen($stringValue);
} elseif (!preg_match('//u', $stringValue)) {
$invalidCharset = true;
} elseif (function_exists('utf8_decode')) {
$length = strlen(utf8_decode($stringValue));
} else {
preg_replace('/./u', '', $stringValue, -1, $length);
}
if ($invalidCharset) {
$this->buildViolation($constraint->charsetMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ charset }}', $constraint->charset)
->setInvalidValue($value)
->addViolation();
return;
}
if (null !== $constraint->max && $length > $constraint->max) {

View File

@ -302,6 +302,10 @@
<source>An empty file is not allowed.</source>
<target>Eine leere Datei ist nicht erlaubt.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Dieser Wert entspricht nicht dem erwarteten Zeichensatz {{ charset }}.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -302,6 +302,10 @@
<source>An empty file is not allowed.</source>
<target>An empty file is not allowed.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>This value does not match the expected {{ charset }} charset.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -302,6 +302,10 @@
<source>An empty file is not allowed.</source>
<target>Un fichier vide n'est pas autorisé.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Cette valeur ne correspond pas au jeu de caractères {{ charset }} attendu.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -302,6 +302,10 @@
<source>An empty file is not allowed.</source>
<target>Lege bestanden zijn niet toegestaan.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Deze waarde is niet in de verwachte tekencodering {{ charset }}.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -302,6 +302,10 @@
<source>An empty file is not allowed.</source>
<target>Plik nie może być pusty.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Ta wartość nie pasuje do oczekiwanego zestawu znaków {{ charset }}.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -302,6 +302,10 @@
<source>An empty file is not allowed.</source>
<target>Prazna datoteka ni dovoljena.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Ta vrednost se ne ujema s pričakovanim naborom znakov {{ charset }}.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -54,12 +54,12 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
return array(
array(12),
array('12'),
array('üü', true),
array('éé', true),
array('üü'),
array('éé'),
array(123),
array('123'),
array('üüü', true),
array('ééé', true),
array('üüü'),
array('ééé'),
);
}
@ -68,8 +68,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
return array(
array(1234),
array('1234'),
array('üüüü', true),
array('éééé', true),
array('üüüü'),
array('éééé'),
);
}
@ -78,24 +78,34 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
return array(
array(12345),
array('12345'),
array('üüüüü', true),
array('ééééé', true),
array('üüüüü'),
array('ééééé'),
array(123456),
array('123456'),
array('üüüüüü', true),
array('éééééé', true),
array('üüüüüü'),
array('éééééé'),
);
}
public function getOneCharset()
{
if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) {
$this->markTestSkipped('Mbstring or iconv is required for this test.');
}
return array(
array("é", "utf8", true),
array("\xE9", "CP1252", true),
array("\xE9", "XXX", false),
array("\xE9", "utf8", false),
);
}
/**
* @dataProvider getFiveOrMoreCharacters
*/
public function testValidValuesMin($value, $mbOnly = false)
public function testValidValuesMin($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(array('min' => 5));
$this->validator->validate($value, $constraint);
@ -105,12 +115,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getThreeOrLessCharacters
*/
public function testValidValuesMax($value, $mbOnly = false)
public function testValidValuesMax($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(array('max' => 3));
$this->validator->validate($value, $constraint);
@ -120,12 +126,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getFourCharacters
*/
public function testValidValuesExact($value, $mbOnly = false)
public function testValidValuesExact($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(4);
$this->validator->validate($value, $constraint);
@ -135,12 +137,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getThreeOrLessCharacters
*/
public function testInvalidValuesMin($value, $mbOnly = false)
public function testInvalidValuesMin($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(array(
'min' => 4,
'minMessage' => 'myMessage',
@ -160,12 +158,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getFiveOrMoreCharacters
*/
public function testInvalidValuesMax($value, $mbOnly = false)
public function testInvalidValuesMax($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(array(
'max' => 4,
'maxMessage' => 'myMessage',
@ -185,12 +179,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getThreeOrLessCharacters
*/
public function testInvalidValuesExactLessThanFour($value, $mbOnly = false)
public function testInvalidValuesExactLessThanFour($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(array(
'min' => 4,
'max' => 4,
@ -211,12 +201,8 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
/**
* @dataProvider getFiveOrMoreCharacters
*/
public function testInvalidValuesExactMoreThanFour($value, $mbOnly = false)
public function testInvalidValuesExactMoreThanFour($value)
{
if ($mbOnly && !function_exists('mb_strlen')) {
$this->markTestSkipped('mb_strlen does not exist');
}
$constraint = new Length(array(
'min' => 4,
'max' => 4,
@ -234,6 +220,31 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
->assertRaised();
}
/**
* @dataProvider getOneCharset
*/
public function testOneCharset($value, $charset, $isValid)
{
$constraint = new Length(array(
'min' => 1,
'max' => 1,
'charset' => $charset,
'charsetMessage' => 'myMessage',
));
$this->validator->validate($value, $constraint);
if ($isValid) {
$this->assertNoViolation();
} else {
$this->buildViolation('myMessage')
->setParameter('{{ value }}', '"'.$value.'"')
->setParameter('{{ charset }}', $charset)
->setInvalidValue($value)
->assertRaised();
}
}
public function testConstraintGetDefaultOption()
{
$constraint = new Length(5);