Removed the magical guessing of the type name to avoid WTF issues
This commit is contained in:
parent
082473659e
commit
ef022c0c6c
@ -17,10 +17,14 @@ RC4 to RC5
|
|||||||
framework:
|
framework:
|
||||||
proxy: true
|
proxy: true
|
||||||
|
|
||||||
|
* To avoid hidden naming collisions, the AbstractType does not try to define
|
||||||
|
the name of form types magically. You now need to implement the `getName()`
|
||||||
|
method explicitly when creating a custom type.
|
||||||
|
|
||||||
RC3 to RC4
|
RC3 to RC4
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* Annotation classes must be annotated with @Annotation
|
* Annotation classes must be annotated with @Annotation
|
||||||
(see the validator constraints for examples)
|
(see the validator constraints for examples)
|
||||||
|
|
||||||
* Annotations are not using the PHP autoloading but their own mechanism. This
|
* Annotations are not using the PHP autoloading but their own mechanism. This
|
||||||
|
@ -125,20 +125,6 @@ abstract class AbstractType implements FormTypeInterface
|
|||||||
return 'form';
|
return 'form';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of this type.
|
|
||||||
*
|
|
||||||
* The default name type is the class name without the Form nor Type suffix
|
|
||||||
*
|
|
||||||
* @return string The name of this type
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
preg_match('/\\\\(\w+?)(Form)?(Type)?$/i', get_class($this), $matches);
|
|
||||||
|
|
||||||
return strtolower($matches[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds extensions for this type.
|
* Adds extensions for this type.
|
||||||
*
|
*
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
<?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\Form;
|
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
|
|
||||||
class AbstractTypeTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
public function testGetNameWithNoSuffix()
|
|
||||||
{
|
|
||||||
$type = new MyTest();
|
|
||||||
|
|
||||||
$this->assertEquals('mytest', $type->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetNameWithTypeSuffix()
|
|
||||||
{
|
|
||||||
$type = new MyTestType();
|
|
||||||
|
|
||||||
$this->assertEquals('mytest', $type->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetNameWithFormSuffix()
|
|
||||||
{
|
|
||||||
$type = new MyTestForm();
|
|
||||||
|
|
||||||
$this->assertEquals('mytest', $type->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetNameWithFormTypeSuffix()
|
|
||||||
{
|
|
||||||
$type = new MyTestFormType();
|
|
||||||
|
|
||||||
$this->assertEquals('mytest', $type->getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyTest extends AbstractType {}
|
|
||||||
|
|
||||||
class MyTestType extends AbstractType {}
|
|
||||||
|
|
||||||
class MyTestForm extends AbstractType {}
|
|
||||||
|
|
||||||
class MyTestFormType extends AbstractType {}
|
|
Reference in New Issue
Block a user