Skip to content

Commit

Permalink
[3.0][FrameworkBundle] Removed deprecated features
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj authored and fabpot committed Oct 1, 2015
1 parent 3832bec commit fc41cf0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 73 deletions.
6 changes: 6 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -1,6 +1,12 @@
CHANGELOG
=========

3.0.0
-----

* removed `validator.api` parameter
* removed `alias` option of the `form.type` tag

2.8.0
-----

Expand Down
12 changes: 2 additions & 10 deletions src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilder;
Expand Down Expand Up @@ -292,16 +293,7 @@ protected function createForm($type, $data = null, array $options = array())
*/
protected function createFormBuilder($data = null, array $options = array())
{
if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) {
$type = 'Symfony\Component\Form\Extension\Core\Type\FormType';
} else {
// not using the class name is deprecated since Symfony 2.8 and
// is only used for backwards compatibility with older versions
// of the Form component
$type = 'form';
}

return $this->container->get('form.factory')->createBuilder($type, $data, $options);
return $this->container->get('form.factory')->createBuilder(FormType::class, $data, $options);
}

/**
Expand Down
Expand Up @@ -34,15 +34,6 @@ public function process(ContainerBuilder $container)
$types = array();

foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
// The following if-else block is deprecated and will be removed
// in Symfony 3.0
// Deprecation errors are triggered in the form registry
if (isset($tag[0]['alias'])) {
$types[$tag[0]['alias']] = $serviceId;
} else {
$types[$serviceId] = $serviceId;
}

// Support type access by FQCN
$serviceDefinition = $container->getDefinition($serviceId);
$types[$serviceDefinition->getClass()] = $serviceId;
Expand Down
Expand Up @@ -777,12 +777,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder

$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
}

// You can use this parameter to check the API version in your own
// bundle extension classes
// This is set to 2.5-bc for compatibility with Symfony 2.5 and 2.6.
// @deprecated since version 2.7, to be removed in 3.0
$container->setParameter('validator.api', '2.5-bc');
}

private function getValidatorMappingFiles(ContainerBuilder $container)
Expand Down
Expand Up @@ -7,15 +7,6 @@

<xsd:element name="config" type="config" />

<xsd:simpleType name="validator_api_version">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="auto" />
<xsd:enumeration value="2.4" />
<xsd:enumeration value="2.5" />
<xsd:enumeration value="2.5-bc" />
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="config">
<xsd:all>
<xsd:element name="assets" type="assets" minOccurs="0" maxOccurs="1" />
Expand Down Expand Up @@ -180,7 +171,6 @@
<xsd:attribute name="cache" type="xsd:string" />
<xsd:attribute name="enable-annotations" type="xsd:boolean" />
<xsd:attribute name="static-method" type="xsd:boolean" />
<xsd:attribute name="api" type="validator_api_version" />
</xsd:complexType>

<xsd:complexType name="annotations">
Expand Down
Expand Up @@ -59,46 +59,8 @@ public function testAddTaggedTypes()
$extDefinition = $container->getDefinition('form.extension');

$this->assertEquals(array(
// As of Symfony 2.8, the class is used to look up types
__CLASS__.'_Type1' => 'my.type1',
__CLASS__.'_Type2' => 'my.type2',
// Before Symfony 2.8, the service ID was used as default alias
'my.type1' => 'my.type1',
'my.type2' => 'my.type2',
), $extDefinition->getArgument(1));
}

public function testUseCustomAliasIfSet()
{
$container = new ContainerBuilder();
$container->addCompilerPass(new FormPass());

$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
$extDefinition->setArguments(array(
new Reference('service_container'),
array(),
array(),
array(),
));

$definition1 = new Definition(__CLASS__.'_Type1');
$definition1->addTag('form.type', array('alias' => 'mytype1'));
$definition2 = new Definition(__CLASS__.'_Type2');
$definition2->addTag('form.type', array('alias' => 'mytype2'));

$container->setDefinition('form.extension', $extDefinition);
$container->setDefinition('my.type1', $definition1);
$container->setDefinition('my.type2', $definition2);

$container->compile();

$extDefinition = $container->getDefinition('form.extension');

$this->assertEquals(array(
__CLASS__.'_Type1' => 'my.type1',
__CLASS__.'_Type2' => 'my.type2',
'mytype1' => 'my.type1',
'mytype2' => 'my.type2',
), $extDefinition->getArgument(1));
}

Expand Down

0 comments on commit fc41cf0

Please sign in to comment.