Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[3.0][FrameworkBundle] Removed deprecated features #15904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Removed usage of the form type name instead of class name
  • Loading branch information
wouterj committed Sep 26, 2015
commit 536c547d82dfa7a15a9d840a1e5d5117eb6c273a
12 changes: 2 additions & 10 deletions 12 src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.