merged 2.0

This commit is contained in:
Fabien Potencier 2012-01-17 11:22:54 +01:00
commit 9c3c53a5c1
8 changed files with 89 additions and 8 deletions

View File

@ -566,7 +566,8 @@ class FrameworkExtension extends Extension
private function getValidatorXmlMappingFiles(ContainerBuilder $container)
{
$files = array(__DIR__.'/../../../Component/Form/Resources/config/validation.xml');
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
$files = array(dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
$container->addResource(new FileResource($files[0]));
foreach ($container->getParameter('kernel.bundles') as $bundle) {

View File

@ -2,8 +2,6 @@
<?php echo $view['form']->renderBlock('field_widget'); ?>
<?php else: ?>
<div <?php echo $view['form']->renderBlock('container_attributes') ?>>
<?php echo $view['form']->widget($form['date'])
. ' '
. $view['form']->widget($form['time']) ?>
<?php echo $view['form']->widget($form['date']).' '.$view['form']->widget($form['time']) ?>
</div>
<?php endif ?>

View File

@ -720,7 +720,7 @@ class Response
public function setCache(array $options)
{
if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) {
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_keys($diff))));
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff))));
}
if (isset($options['etag'])) {

View File

@ -61,6 +61,11 @@ class Locale extends \Locale
}
}
$fallbackLocale = self::getFallbackLocale($locale);
if (null !== $fallbackLocale) {
$countries = array_merge(self::getDisplayCountries($fallbackLocale), $countries);
}
$collator->asort($countries);
self::$countries[$locale] = $countries;
@ -108,6 +113,11 @@ class Locale extends \Locale
}
}
$fallbackLocale = self::getFallbackLocale($locale);
if (null !== $fallbackLocale) {
$languages = array_merge(self::getDisplayLanguages($fallbackLocale), $languages);
}
$collator->asort($languages);
self::$languages[$locale] = $languages;
@ -150,6 +160,11 @@ class Locale extends \Locale
$locales[$code] = $name;
}
$fallbackLocale = self::getFallbackLocale($locale);
if (null !== $fallbackLocale) {
$locales = array_merge(self::getDisplayLocales($fallbackLocale), $locales);
}
$collator->asort($locales);
self::$locales[$locale] = $locales;
@ -218,4 +233,23 @@ class Locale extends \Locale
return trim($matches[1]);
}
/**
* Returns the fallback locale for a given locale, if any
*
* @param $locale The locale to find the fallback for
* @return string|null The fallback locale, or null if no parent exists
*/
static protected function getFallbackLocale($locale)
{
if ($locale === self::getDefault()) {
return null;
}
if (false === $pos = strrpos($locale, '_')) {
return self::getDefault();
}
return substr($locale, 0, $pos);
}
}

View File

@ -24,7 +24,7 @@ interface MutableAclProviderInterface extends AclProviderInterface
* @throws AclAlreadyExistsException when there already is an ACL for the given
* object identity
* @param ObjectIdentityInterface $oid
* @return AclInterface
* @return MutableAclInterface
*/
function createAcl(ObjectIdentityInterface $oid);

View File

@ -154,11 +154,11 @@ class PhpEngine implements EngineInterface, \ArrayAccess
protected function evaluate(Storage $template, array $parameters = array())
{
$__template__ = $template;
if (isset($parameters['__template__'])) {
throw new \InvalidArgumentException('Invalid parameter (__template__)');
}
if ($__template__ instanceof FileStorage) {
extract($parameters, EXTR_SKIP);
$view = $this;

View File

@ -254,6 +254,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
$this->fail('->setCache() throws an InvalidArgumentException if an option is not supported');
} catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported');
$this->assertContains('"wrong option"', $e->getMessage());
}
$options = array('etag' => '"whatever"');

View File

@ -0,0 +1,47 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Component\Locale;
use Symfony\Component\Locale\Locale;
class LocaleTest extends \PHPUnit_Framework_TestCase
{
public function testGetDisplayCountriesReturnsFullListForSubLocale()
{
$countriesDe = Locale::getDisplayCountries('de');
$countriesDeCh = Locale::getDisplayCountries('de_CH');
$this->assertEquals(count($countriesDe), count($countriesDeCh));
$this->assertEquals($countriesDe['BD'], 'Bangladesch');
$this->assertEquals($countriesDeCh['BD'], 'Bangladesh');
}
public function testGetDisplayLanguagesReturnsFullListForSubLocale()
{
$languagesDe = Locale::getDisplayLanguages('de');
$languagesDeCh = Locale::getDisplayLanguages('de_CH');
$this->assertEquals(count($languagesDe), count($languagesDeCh));
$this->assertEquals($languagesDe['be'], 'Weißrussisch');
$this->assertEquals($languagesDeCh['be'], 'Weissrussisch');
}
public function testGetDisplayLocalesReturnsFullListForSubLocale()
{
$localesDe = Locale::getDisplayLocales('de');
$localesDeCh = Locale::getDisplayLocales('de_CH');
$this->assertEquals(count($localesDe), count($localesDeCh));
$this->assertEquals($localesDe['be'], 'Weißrussisch');
$this->assertEquals($localesDeCh['be'], 'Weissrussisch');
}
}