[Form] Move CSRF options from types to the CSRF extension
This commit is contained in:
parent
fdbdcbbd0a
commit
ba31b5acc5
@ -121,7 +121,6 @@ class ChoiceType extends AbstractType
|
|||||||
'choice_list' => null,
|
'choice_list' => null,
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
'preferred_choices' => array(),
|
'preferred_choices' => array(),
|
||||||
'csrf_protection' => false,
|
|
||||||
'empty_data' => $multiple || $expanded ? array() : '',
|
'empty_data' => $multiple || $expanded ? array() : '',
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
);
|
);
|
||||||
|
@ -123,7 +123,6 @@ class DateType extends AbstractType
|
|||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'data_timezone' => null,
|
'data_timezone' => null,
|
||||||
'user_timezone' => null,
|
'user_timezone' => null,
|
||||||
'csrf_protection' => false,
|
|
||||||
// Don't modify \DateTime classes by reference, we treat
|
// Don't modify \DateTime classes by reference, we treat
|
||||||
// them like immutable value objects
|
// them like immutable value objects
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
|
@ -58,7 +58,6 @@ class FileType extends AbstractType
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'csrf_protection' => false,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ class RepeatedType extends AbstractType
|
|||||||
'options' => array(),
|
'options' => array(),
|
||||||
'first_name' => 'first',
|
'first_name' => 'first',
|
||||||
'second_name' => 'second',
|
'second_name' => 'second',
|
||||||
'csrf_protection' => false,
|
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,6 @@ class TimeType extends AbstractType
|
|||||||
'pattern' => null,
|
'pattern' => null,
|
||||||
'data_timezone' => null,
|
'data_timezone' => null,
|
||||||
'user_timezone' => null,
|
'user_timezone' => null,
|
||||||
'csrf_protection' => false,
|
|
||||||
// Don't modify \DateTime classes by reference, we treat
|
// Don't modify \DateTime classes by reference, we treat
|
||||||
// them like immutable value objects
|
// them like immutable value objects
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
|
@ -34,7 +34,12 @@ class CsrfExtension extends AbstractExtension
|
|||||||
protected function loadTypeExtensions()
|
protected function loadTypeExtensions()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
new Type\ChoiceTypeCsrfExtension(),
|
||||||
|
new Type\DateTypeCsrfExtension(),
|
||||||
|
new Type\FileTypeCsrfExtension(),
|
||||||
new Type\FormTypeCsrfExtension(),
|
new Type\FormTypeCsrfExtension(),
|
||||||
|
new Type\RepeatedTypeCsrfExtension(),
|
||||||
|
new Type\TimeTypeCsrfExtension(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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\Component\Form\Extension\Csrf\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
|
||||||
|
class ChoiceTypeCsrfExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
return array('csrf_protection' => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'choice';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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\Component\Form\Extension\Csrf\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
|
||||||
|
class DateTypeCsrfExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
return array('csrf_protection' => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'date';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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\Component\Form\Extension\Csrf\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
|
||||||
|
class FileTypeCsrfExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
return array('csrf_protection' => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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\Component\Form\Extension\Csrf\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
|
||||||
|
class RepeatedTypeCsrfExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
return array('csrf_protection' => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'repeated';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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\Component\Form\Extension\Csrf\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
|
||||||
|
class TimeTypeCsrfExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
return array('csrf_protection' => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'time';
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user