Skip to content

Commit 1ea281f

Browse files
Merge branch '2.8'
* 2.8: [Form] Cleanup Added the renamed options of the collection type to the upgrade information Conflicts: UPGRADE-2.8.md src/Symfony/Component/Form/FormFactory.php src/Symfony/Component/Form/Tests/FormFactoryTest.php
2 parents fdb419e + 6df8bad commit 1ea281f

File tree

5 files changed

+8
-174
lines changed

5 files changed

+8
-174
lines changed

UPGRADE-3.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ UPGRADE FROM 2.x to 3.0
272272
// ...
273273
}
274274
```
275+
276+
* The option "options" of the CollectionType has been renamed to "entry_options".
277+
278+
* The option "type" of the CollectionType has been renamed to "entry_type".
279+
As a value for the option you must provide the fully-qualified class name (FQCN)
280+
now as well.
275281

276282
* The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace.
277283

src/Symfony/Component/Form/FormFactory.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form;
1313

1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
15-
use Symfony\Component\Form\Util\StringUtil;
1615

1716
class FormFactory implements FormFactoryInterface
1817
{
@@ -65,11 +64,7 @@ public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Typ
6564
throw new UnexpectedTypeException($type, 'string');
6665
}
6766

68-
if (null === $name = $this->registry->getType($type)->getBlockPrefix()) {
69-
$name = StringUtil::fqcnToBlockPrefix($type);
70-
}
71-
72-
return $this->createNamedBuilder($name, $type, $data, $options);
67+
return $this->createNamedBuilder($this->registry->getType($type)->getBlockPrefix(), $type, $data, $options);
7368
}
7469

7570
/**

src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ protected function setUp()
6767
public function testExtractConfiguration()
6868
{
6969
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
70-
$type->expects($this->any())
71-
->method('getName')
72-
->will($this->returnValue('type_name'));
7370
$type->expects($this->any())
7471
->method('getInnerType')
7572
->will($this->returnValue(new \stdClass()));
@@ -91,9 +88,6 @@ public function testExtractConfiguration()
9188
public function testExtractConfigurationSortsPassedOptions()
9289
{
9390
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
94-
$type->expects($this->any())
95-
->method('getName')
96-
->will($this->returnValue('type_name'));
9791
$type->expects($this->any())
9892
->method('getInnerType')
9993
->will($this->returnValue(new \stdClass()));
@@ -128,9 +122,6 @@ public function testExtractConfigurationSortsPassedOptions()
128122
public function testExtractConfigurationSortsResolvedOptions()
129123
{
130124
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
131-
$type->expects($this->any())
132-
->method('getName')
133-
->will($this->returnValue('type_name'));
134125
$type->expects($this->any())
135126
->method('getInnerType')
136127
->will($this->returnValue(new \stdClass()));
@@ -162,9 +153,6 @@ public function testExtractConfigurationSortsResolvedOptions()
162153
public function testExtractConfigurationBuildsIdRecursively()
163154
{
164155
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
165-
$type->expects($this->any())
166-
->method('getName')
167-
->will($this->returnValue('type_name'));
168156
$type->expects($this->any())
169157
->method('getInnerType')
170158
->will($this->returnValue(new \stdClass()));

src/Symfony/Component/Form/Tests/FormFactoryTest.php

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -208,161 +208,6 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString()
208208
$this->assertSame('FORM', $this->factory->create('TYPE', null, $options));
209209
}
210210

211-
public function testCreateUsesTypeNameIfTypeGivenAsString()
212-
{
213-
$options = array('a' => '1', 'b' => '2');
214-
$resolvedOptions = array('a' => '2', 'b' => '3');
215-
$resolvedType = $this->getMockResolvedType();
216-
217-
$this->registry->expects($this->any())
218-
->method('getType')
219-
->with('TYPE')
220-
->will($this->returnValue($resolvedType));
221-
222-
$resolvedType->expects($this->once())
223-
->method('createBuilder')
224-
->with($this->factory, 'type', $options)
225-
->will($this->returnValue($this->builder));
226-
227-
$this->builder->expects($this->any())
228-
->method('getOptions')
229-
->will($this->returnValue($resolvedOptions));
230-
231-
$resolvedType->expects($this->once())
232-
->method('buildForm')
233-
->with($this->builder, $resolvedOptions);
234-
235-
$this->builder->expects($this->once())
236-
->method('getForm')
237-
->will($this->returnValue('FORM'));
238-
239-
$this->assertSame('FORM', $this->factory->create('TYPE', null, $options));
240-
}
241-
242-
public function testCreateStripsNamespaceOffTypeName()
243-
{
244-
$options = array('a' => '1', 'b' => '2');
245-
$resolvedOptions = array('a' => '2', 'b' => '3');
246-
$resolvedType = $this->getMockResolvedType();
247-
248-
$this->registry->expects($this->any())
249-
->method('getType')
250-
->with('Vendor\Name\Space\UserForm')
251-
->will($this->returnValue($resolvedType));
252-
253-
$resolvedType->expects($this->once())
254-
->method('createBuilder')
255-
->with($this->factory, 'user_form', $options)
256-
->will($this->returnValue($this->builder));
257-
258-
$this->builder->expects($this->any())
259-
->method('getOptions')
260-
->will($this->returnValue($resolvedOptions));
261-
262-
$resolvedType->expects($this->once())
263-
->method('buildForm')
264-
->with($this->builder, $resolvedOptions);
265-
266-
$this->builder->expects($this->once())
267-
->method('getForm')
268-
->will($this->returnValue('FORM'));
269-
270-
$this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\UserForm', null, $options));
271-
}
272-
273-
public function testCreateStripsTypeSuffixOffTypeName()
274-
{
275-
$options = array('a' => '1', 'b' => '2');
276-
$resolvedOptions = array('a' => '2', 'b' => '3');
277-
$resolvedType = $this->getMockResolvedType();
278-
279-
$this->registry->expects($this->any())
280-
->method('getType')
281-
->with('Vendor\Name\Space\UserType')
282-
->will($this->returnValue($resolvedType));
283-
284-
$resolvedType->expects($this->once())
285-
->method('createBuilder')
286-
->with($this->factory, 'user', $options)
287-
->will($this->returnValue($this->builder));
288-
289-
$this->builder->expects($this->any())
290-
->method('getOptions')
291-
->will($this->returnValue($resolvedOptions));
292-
293-
$resolvedType->expects($this->once())
294-
->method('buildForm')
295-
->with($this->builder, $resolvedOptions);
296-
297-
$this->builder->expects($this->once())
298-
->method('getForm')
299-
->will($this->returnValue('FORM'));
300-
301-
$this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\UserType', null, $options));
302-
}
303-
304-
public function testCreateDoesNotStripTypeSuffixIfResultEmpty()
305-
{
306-
$options = array('a' => '1', 'b' => '2');
307-
$resolvedOptions = array('a' => '2', 'b' => '3');
308-
$resolvedType = $this->getMockResolvedType();
309-
310-
$this->registry->expects($this->any())
311-
->method('getType')
312-
->with('Vendor\Name\Space\Type')
313-
->will($this->returnValue($resolvedType));
314-
315-
$resolvedType->expects($this->once())
316-
->method('createBuilder')
317-
->with($this->factory, 'type', $options)
318-
->will($this->returnValue($this->builder));
319-
320-
$this->builder->expects($this->any())
321-
->method('getOptions')
322-
->will($this->returnValue($resolvedOptions));
323-
324-
$resolvedType->expects($this->once())
325-
->method('buildForm')
326-
->with($this->builder, $resolvedOptions);
327-
328-
$this->builder->expects($this->once())
329-
->method('getForm')
330-
->will($this->returnValue('FORM'));
331-
332-
$this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\Type', null, $options));
333-
}
334-
335-
public function testCreateConvertsTypeToUnderscoreSyntax()
336-
{
337-
$options = array('a' => '1', 'b' => '2');
338-
$resolvedOptions = array('a' => '2', 'b' => '3');
339-
$resolvedType = $this->getMockResolvedType();
340-
341-
$this->registry->expects($this->any())
342-
->method('getType')
343-
->with('Vendor\Name\Space\MyProfileHTMLType')
344-
->will($this->returnValue($resolvedType));
345-
346-
$resolvedType->expects($this->once())
347-
->method('createBuilder')
348-
->with($this->factory, 'my_profile_html', $options)
349-
->will($this->returnValue($this->builder));
350-
351-
$this->builder->expects($this->any())
352-
->method('getOptions')
353-
->will($this->returnValue($resolvedOptions));
354-
355-
$resolvedType->expects($this->once())
356-
->method('buildForm')
357-
->with($this->builder, $resolvedOptions);
358-
359-
$this->builder->expects($this->once())
360-
->method('getForm')
361-
->will($this->returnValue('FORM'));
362-
363-
$this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\MyProfileHTMLType', null, $options));
364-
}
365-
366211
public function testCreateNamed()
367212
{
368213
$options = array('a' => '1', 'b' => '2');

src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public function provideTypeClassBlockPrefixTuples()
361361
*/
362362
private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractType')
363363
{
364-
return $this->getMock($typeClass, array('getName', 'getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'));
364+
return $this->getMock($typeClass, array('getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'));
365365
}
366366

367367
/**

0 commit comments

Comments
 (0)