merged 2.0

This commit is contained in:
Fabien Potencier 2011-11-23 11:23:27 +01:00
commit a1d12324f9
5 changed files with 38 additions and 1 deletions

View File

@ -12,9 +12,19 @@
namespace Symfony\Component\Form\Extension\Core\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
class TextareaType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form)
{
$view->set('pattern', null);
}
/**
* {@inheritdoc}
*/

View File

@ -220,6 +220,10 @@ class FormFactory implements FormFactoryInterface
while (null !== $type) {
if ($type instanceof FormTypeInterface) {
if ($type->getName() == $type->getParent($options)) {
throw new FormException(sprintf('The form type name "%s" for class "%s" cannot be the same as the parent type.', $type->getName(), get_class($type)));
}
$this->addType($type);
} else {
$type = $this->getType($type);

View File

@ -523,7 +523,8 @@ class Request
if ($this->server->has('HTTP_CLIENT_IP')) {
return $this->server->get('HTTP_CLIENT_IP');
} elseif (self::$trustProxy && $this->server->has('HTTP_X_FORWARDED_FOR')) {
return $this->server->get('HTTP_X_FORWARDED_FOR');
$clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'), 2);
return isset($clientIp[0]) ? trim($clientIp[0]) : '';
}
}
@ -948,6 +949,24 @@ class Request
$this->format = $format;
}
public function setLocale($locale)
{
if (!$this->hasSession()) {
throw new \LogicException('Forward compatibility for Request::setLocale() requires the session to be set.');
}
$this->session->setLocale($locale);
}
public function getLocale()
{
if (!$this->hasSession()) {
throw new \LogicException('Forward compatibility for Request::getLocale() requires the session to be set.');
}
return $this->session->getLocale();
}
/**
* Gets the format associated with the request.
*

View File

@ -1491,11 +1491,13 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
{
$form = $this->factory->createNamed('textarea', 'na&me', 'foo&bar', array(
'property_path' => 'name',
'pattern' => 'foo',
));
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/textarea
[@name="na&me"]
[not(@pattern)]
[.="foo&bar"]
'
);

View File

@ -544,6 +544,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase
array('88.88.88.88', true, '127.0.0.1', null, '88.88.88.88'),
array('::1', false, '::1', null, null),
array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null),
array('2620:0:1cfe:face:b00c::3', true, '::1', null, '2620:0:1cfe:face:b00c::3, ::1'),
array('88.88.88.88', true, '123.45.67.89', null, '88.88.88.88, 87.65.43.21, 127.0.0.1'),
);
}