Skip to content

Commit

Permalink
Deprecate JMS related code
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and jordisala1991 committed Dec 24, 2021
1 parent f6e691b commit 619a6a3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Bridge/Symfony/DependencyInjection/Configuration.php
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\Form\Bridge\Symfony\DependencyInjection;

use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand All @@ -31,6 +32,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$rootNode = $treeBuilder->getRootNode();

$this->addFlashMessageSection($rootNode);
// NEXT_MAJOR: Remove this line and the jms/serializer and jms/metadata dependency.
$this->addSerializerFormats($rootNode);

return $treeBuilder;
Expand Down Expand Up @@ -62,6 +64,8 @@ private function addFlashMessageSection(ArrayNodeDefinition $node): void
}

/**
* NEXT_MAJOR: Remove this method.
*
* Adds configuration for serializer formats.
*
* @psalm-suppress PossiblyNullReference, PossiblyUndefinedMethod
Expand All @@ -73,6 +77,12 @@ private function addSerializerFormats(ArrayNodeDefinition $node): void
$node
->children()
->arrayNode('serializer')
->setDeprecated(
...$this->forConfig(
'The "%node%" option is deprecated since sonata-project/form-extensions 1.x.',
'1.x'
)
)
->addDefaultsIfNotSet()
->children()
->arrayNode('formats')
Expand All @@ -84,4 +94,23 @@ private function addSerializerFormats(ArrayNodeDefinition $node): void
->end()
->end();
}

/**
* NEXT_MAJOR: Remove this method.
*
* @return string[]
*/
private function forConfig(string $message, string $version): array
{
// @phpstan-ignore-next-line
if (method_exists(BaseNode::class, 'getDeprecation')) {
return [
'sonata-project/form-extension',
$version,
$message,
];
}

return [$message];
}
}
Expand Up @@ -54,10 +54,13 @@ public function load(array $configs, ContainerBuilder $container): void

$container->setParameter('sonata.form.form_type', $config['form_type']);

// NEXT_MAJOR: Remove this call.
$this->configureSerializerFormats($config);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @param mixed[] $config
*/
private function configureSerializerFormats(array $config): void
Expand Down
4 changes: 4 additions & 0 deletions src/Serializer/BaseSerializerHandler.php
Expand Up @@ -21,6 +21,10 @@
use Sonata\Doctrine\Model\ManagerInterface;

/**
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/form-extensions version 1.x and will be removed in 2.0.
*
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
*/
abstract class BaseSerializerHandler implements SerializerHandlerInterface
Expand Down
4 changes: 4 additions & 0 deletions src/Serializer/SerializerHandlerInterface.php
Expand Up @@ -16,6 +16,10 @@
use JMS\Serializer\Handler\SubscribingHandlerInterface;

/**
* NEXT_MAJOR: Remove this interface.
*
* @deprecated since sonata-project/form-extensions version 1.x and will be removed in 2.0.
*
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
*/
interface SerializerHandlerInterface extends SubscribingHandlerInterface
Expand Down
4 changes: 4 additions & 0 deletions src/Type/BaseDoctrineORMSerializationType.php
Expand Up @@ -25,6 +25,10 @@
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/form-extensions version 1.x and will be removed in 2.0.
*
* This is a doctrine serialization form type that generates a form type from class serialization metadata
* and doctrine metadata.
*
Expand Down

0 comments on commit 619a6a3

Please sign in to comment.