Skip to content

Commit

Permalink
Fix some deprecations (#5)
Browse files Browse the repository at this point in the history
* Removed the TreeBuilder deprecation

* Fixed the getExtendedTypes() deprecation

* Fixed a code error

* Fixed syntax issue
  • Loading branch information
javiereguiluz authored and tgalopin committed Apr 2, 2019
1 parent fe9c3d1 commit aabcda7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();

$rootNode = $treeBuilder->root('html_sanitizer');
$treeBuilder = new TreeBuilder('html_sanitizer');
$rootNode = $this->getRootNode($treeBuilder, 'html_sanitizer');

$rootNode
->children()
Expand All @@ -40,4 +39,14 @@ public function getConfigTreeBuilder()

return $treeBuilder;
}

private function getRootNode(TreeBuilder $treeBuilder, $name)
{
// BC layer for symfony/config 4.1 and older
if (!\method_exists($treeBuilder, 'getRootNode')) {
return $treeBuilder->root($name);
}

return $treeBuilder->getRootNode();
}
}
8 changes: 7 additions & 1 deletion src/Form/TextTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ public function __construct(ContainerInterface $sanitizers, string $default)
$this->default = $default;
}

// needed for BC reasons
public function getExtendedType()
{
return TextType::class;
return self::getExtendedTypes()[0];
}

public static function getExtendedTypes()
{
return [TextType::class];
}

public function configureOptions(OptionsResolver $resolver)
Expand Down

1 comment on commit aabcda7

@TomaszGasior
Copy link

Choose a reason for hiding this comment

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

Could you please tag this commit as new release, allowing people to use it in composer.json? Thank you!

Please sign in to comment.