[Form] Using new methods instead of the deprecated
This commit is contained in:
parent
ff4d446c5e
commit
b4e2818608
@ -99,15 +99,15 @@ class DateTimeType extends AbstractType
|
||||
}
|
||||
|
||||
if ('string' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'])
|
||||
));
|
||||
} elseif ('timestamp' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToTimestampTransformer($options['data_timezone'], $options['data_timezone'])
|
||||
));
|
||||
} elseif ('array' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], $parts)
|
||||
));
|
||||
}
|
||||
|
@ -117,15 +117,15 @@ class DateType extends AbstractType
|
||||
}
|
||||
|
||||
if ('string' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'Y-m-d')
|
||||
));
|
||||
} elseif ('timestamp' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToTimestampTransformer($options['data_timezone'], $options['data_timezone'])
|
||||
));
|
||||
} elseif ('array' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], array('year', 'month', 'day'))
|
||||
));
|
||||
}
|
||||
|
@ -96,15 +96,15 @@ class TimeType extends AbstractType
|
||||
}
|
||||
|
||||
if ('string' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'H:i:s')
|
||||
));
|
||||
} elseif ('timestamp' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToTimestampTransformer($options['data_timezone'], $options['data_timezone'])
|
||||
));
|
||||
} elseif ('array' === $options['input']) {
|
||||
$builder->appendNormTransformer(new ReversedTransformer(
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], $parts)
|
||||
));
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class FormTypeTest extends TypeTestCase
|
||||
public function testBoundDataIsTrimmedBeforeTransforming()
|
||||
{
|
||||
$form = $this->factory->createBuilder('form')
|
||||
->appendClientTransformer(new FixedDataTransformer(array(
|
||||
->addViewTransformer(new FixedDataTransformer(array(
|
||||
null => '',
|
||||
'reverse[a]' => 'a',
|
||||
)))
|
||||
@ -88,7 +88,7 @@ class FormTypeTest extends TypeTestCase
|
||||
public function testBoundDataIsNotTrimmedBeforeTransformingIfNoTrimming()
|
||||
{
|
||||
$form = $this->factory->createBuilder('form', null, array('trim' => false))
|
||||
->appendClientTransformer(new FixedDataTransformer(array(
|
||||
->addViewTransformer(new FixedDataTransformer(array(
|
||||
null => '',
|
||||
'reverse[ a ]' => ' a ',
|
||||
)))
|
||||
@ -312,7 +312,7 @@ class FormTypeTest extends TypeTestCase
|
||||
public function testBindWithEmptyDataPassesEmptyStringToTransformerIfNoChildren()
|
||||
{
|
||||
$form = $this->factory->createBuilder('form')
|
||||
->appendClientTransformer(new FixedDataTransformer(array(
|
||||
->addViewTransformer(new FixedDataTransformer(array(
|
||||
// required for the initial, internal setData(null)
|
||||
null => 'null',
|
||||
// required to test that bind(null) is converted to ''
|
||||
@ -460,7 +460,7 @@ class FormTypeTest extends TypeTestCase
|
||||
|
||||
$builder = $this->factory->createBuilder('form', $author);
|
||||
$builder->add('referenceCopy', 'form');
|
||||
$builder->get('referenceCopy')->appendClientTransformer(new CallbackTransformer(
|
||||
$builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer(
|
||||
function () {},
|
||||
function ($value) { // reverseTransform
|
||||
return 'foobar';
|
||||
@ -485,7 +485,7 @@ class FormTypeTest extends TypeTestCase
|
||||
$builder = $this->factory->createBuilder('form');
|
||||
$builder->setData($author);
|
||||
$builder->add('referenceCopy', 'form');
|
||||
$builder->get('referenceCopy')->appendClientTransformer(new CallbackTransformer(
|
||||
$builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer(
|
||||
function () {},
|
||||
function ($value) use ($ref2) { // reverseTransform
|
||||
return $ref2;
|
||||
|
Reference in New Issue
Block a user