Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP][3.0][Form] Removed usage of deprecated form tag attributes #16046

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

Merged
merged 1 commit into from
Oct 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container)

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

// Builds an array with service IDs as keys and tag aliases as values
// Builds an array with fully-qualified type class names as keys and service IDs as values
$types = array();

foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
Expand All @@ -46,12 +46,8 @@ public function process(ContainerBuilder $container)
foreach ($container->findTaggedServiceIds('form.type_extension') as $serviceId => $tag) {
if (isset($tag[0]['extended_type'])) {
$extendedType = $tag[0]['extended_type'];
} elseif (isset($tag[0]['alias'])) {
@trigger_error('The alias option of the form.type_extension tag is deprecated since version 2.8 and will be removed in 3.0. Use the extended_type option instead.', E_USER_DEPRECATED);
$extendedType = $tag[0]['alias'];
} else {
@trigger_error('The extended_type option of the form.type_extension tag is required since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
$extendedType = $serviceId;
throw new \InvalidArgumentException(sprintf('Tagged form type extension must have the extended type configured using the extended_type/extended-type attribute, none was configured for the "%s" service.', $serviceId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Tagged form type extensionS" as this is valid for every type extension

}

$typeExtensions[$extendedType][] = $serviceId;
Expand Down
62 changes: 31 additions & 31 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,97 +50,97 @@

<service id="form.type.form" class="Symfony\Component\Form\Extension\Core\Type\FormType">
<argument type="service" id="form.property_accessor" />
<tag name="form.type" alias="form" />
<tag name="form.type" />
</service>
<service id="form.type.birthday" class="Symfony\Component\Form\Extension\Core\Type\BirthdayType">
<tag name="form.type" alias="birthday" />
<tag name="form.type" />
</service>
<service id="form.type.checkbox" class="Symfony\Component\Form\Extension\Core\Type\CheckboxType">
<tag name="form.type" alias="checkbox" />
<tag name="form.type" />
</service>
<service id="form.type.choice" class="Symfony\Component\Form\Extension\Core\Type\ChoiceType">
<tag name="form.type" alias="choice" />
<tag name="form.type" />
</service>
<service id="form.type.collection" class="Symfony\Component\Form\Extension\Core\Type\CollectionType">
<tag name="form.type" alias="collection" />
<tag name="form.type" />
</service>
<service id="form.type.country" class="Symfony\Component\Form\Extension\Core\Type\CountryType">
<tag name="form.type" alias="country" />
<tag name="form.type" />
</service>
<service id="form.type.date" class="Symfony\Component\Form\Extension\Core\Type\DateType">
<tag name="form.type" alias="date" />
<tag name="form.type" />
</service>
<service id="form.type.datetime" class="Symfony\Component\Form\Extension\Core\Type\DateTimeType">
<tag name="form.type" alias="datetime" />
<tag name="form.type" />
</service>
<service id="form.type.email" class="Symfony\Component\Form\Extension\Core\Type\EmailType">
<tag name="form.type" alias="email" />
<tag name="form.type" />
</service>
<service id="form.type.file" class="Symfony\Component\Form\Extension\Core\Type\FileType">
<tag name="form.type" alias="file" />
<tag name="form.type" />
</service>
<service id="form.type.hidden" class="Symfony\Component\Form\Extension\Core\Type\HiddenType">
<tag name="form.type" alias="hidden" />
<tag name="form.type" />
</service>
<service id="form.type.integer" class="Symfony\Component\Form\Extension\Core\Type\IntegerType">
<tag name="form.type" alias="integer" />
<tag name="form.type" />
</service>
<service id="form.type.language" class="Symfony\Component\Form\Extension\Core\Type\LanguageType">
<tag name="form.type" alias="language" />
<tag name="form.type" />
</service>
<service id="form.type.locale" class="Symfony\Component\Form\Extension\Core\Type\LocaleType">
<tag name="form.type" alias="locale" />
<tag name="form.type" />
</service>
<service id="form.type.money" class="Symfony\Component\Form\Extension\Core\Type\MoneyType">
<tag name="form.type" alias="money" />
<tag name="form.type" />
</service>
<service id="form.type.number" class="Symfony\Component\Form\Extension\Core\Type\NumberType">
<tag name="form.type" alias="number" />
<tag name="form.type" />
</service>
<service id="form.type.password" class="Symfony\Component\Form\Extension\Core\Type\PasswordType">
<tag name="form.type" alias="password" />
<tag name="form.type" />
</service>
<service id="form.type.percent" class="Symfony\Component\Form\Extension\Core\Type\PercentType">
<tag name="form.type" alias="percent" />
<tag name="form.type" />
</service>
<service id="form.type.radio" class="Symfony\Component\Form\Extension\Core\Type\RadioType">
<tag name="form.type" alias="radio" />
<tag name="form.type" />
</service>
<service id="form.type.range" class="Symfony\Component\Form\Extension\Core\Type\RangeType">
<tag name="form.type" alias="range" />
<tag name="form.type" />
</service>
<service id="form.type.repeated" class="Symfony\Component\Form\Extension\Core\Type\RepeatedType">
<tag name="form.type" alias="repeated" />
<tag name="form.type" />
</service>
<service id="form.type.search" class="Symfony\Component\Form\Extension\Core\Type\SearchType">
<tag name="form.type" alias="search" />
<tag name="form.type" />
</service>
<service id="form.type.textarea" class="Symfony\Component\Form\Extension\Core\Type\TextareaType">
<tag name="form.type" alias="textarea" />
<tag name="form.type" />
</service>
<service id="form.type.text" class="Symfony\Component\Form\Extension\Core\Type\TextType">
<tag name="form.type" alias="text" />
<tag name="form.type" />
</service>
<service id="form.type.time" class="Symfony\Component\Form\Extension\Core\Type\TimeType">
<tag name="form.type" alias="time" />
<tag name="form.type" />
</service>
<service id="form.type.timezone" class="Symfony\Component\Form\Extension\Core\Type\TimezoneType">
<tag name="form.type" alias="timezone" />
<tag name="form.type" />
</service>
<service id="form.type.url" class="Symfony\Component\Form\Extension\Core\Type\UrlType">
<tag name="form.type" alias="url" />
<tag name="form.type" />
</service>
<service id="form.type.button" class="Symfony\Component\Form\Extension\Core\Type\ButtonType">
<tag name="form.type" alias="button" />
<tag name="form.type" />
</service>
<service id="form.type.submit" class="Symfony\Component\Form\Extension\Core\Type\SubmitType">
<tag name="form.type" alias="submit" />
<tag name="form.type" />
</service>
<service id="form.type.reset" class="Symfony\Component\Form\Extension\Core\Type\ResetType">
<tag name="form.type" alias="reset" />
<tag name="form.type" />
</service>
<service id="form.type.currency" class="Symfony\Component\Form\Extension\Core\Type\CurrencyType">
<tag name="form.type" alias="currency" />
<tag name="form.type" />
</service>

<!-- FormTypeHttpFoundationExtension -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ public function testAddTaggedTypes()
array(),
));

$definition1 = new Definition(__CLASS__.'_Type1');
$definition1->addTag('form.type');
$definition2 = new Definition(__CLASS__.'_Type2');
$definition2->addTag('form.type');

$container->setDefinition('form.extension', $extDefinition);
$container->setDefinition('my.type1', $definition1);
$container->setDefinition('my.type2', $definition2);
$container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type');
$container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type');

$container->compile();

Expand Down Expand Up @@ -100,9 +95,10 @@ public function testAddTaggedTypeExtensions()
}

/**
* @group legacy
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage extended-type attribute, none was configured for the "my.type_extension" service
*/
public function testAliasOptionForTaggedTypeExtensions()
public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttribute()
{
$container = new ContainerBuilder();
$container->addCompilerPass(new FormPass());
Expand All @@ -115,23 +111,10 @@ public function testAliasOptionForTaggedTypeExtensions()
));

$container->setDefinition('form.extension', $extDefinition);
$container->register('my.type_extension1', 'stdClass')
->addTag('form.type_extension', array('alias' => 'type1'));
$container->register('my.type_extension2', 'stdClass')
->addTag('form.type_extension', array('alias' => 'type2'));
$container->register('my.type_extension', 'stdClass')
->addTag('form.type_extension');

$container->compile();

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

$this->assertSame(array(
'type1' => array(
'my.type_extension1',
),
'type2' => array(
'my.type_extension2',
),
), $extDefinition->getArgument(2));
}

public function testAddTaggedGuessers()
Expand Down