Skip to content
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
2 changes: 2 additions & 0 deletions src/State/SerializerAwareProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* Injects serializer in providers.
*
* @author Vincent Chalamon <[email protected]>
*
* @deprecated in 4.2, to be removed in 5.0 because it violates the dependency injection principle.
*/
interface SerializerAwareProviderInterface
Copy link
Member

Choose a reason for hiding this comment

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

add a trigger_deprecation on top of this interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done here, it's not enough?

{
Expand Down
7 changes: 7 additions & 0 deletions src/State/SerializerAwareProviderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ trait SerializerAwareProviderTrait

public function setSerializerLocator(ContainerInterface $serializerLocator): void
{
trigger_deprecation(
'api-platform/core',
'4.2',
'The "%s" interface is deprecated and will be removed in 5.0. It violates the dependency injection principle.',
SerializerAwareProviderInterface::class
);

$this->serializerLocator = $serializerLocator;
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/ApiPlatformBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function build(ContainerBuilder $container): void
{
parent::build($container);

// TODO: remove in 5.x
$container->addCompilerPass(new DataProviderPass());
// Run the compiler pass before the {@see ResolveInstanceofConditionalsPass} to allow autoconfiguration of generated filter definitions.
$container->addCompilerPass(new AttributeFilterPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 101);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
/**
* Registers data providers.
*
* @internal
* @internal since 4.2
*
* @author Kévin Dunglas <[email protected]>
* @author Vincent Chalamon <[email protected]>
*
* TODO: remove in 5.x
*/
final class DataProviderPass implements CompilerPassInterface
{
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/TestBundle/State/SerializableProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* @author Vincent Chalamon <[email protected]>
*
* @deprecated in 4.2, to be removed in 5.0 because it violates the dependency injection principle.
*/
class SerializableProvider implements ProviderInterface, SerializerAwareProviderInterface
{
Expand Down
1 change: 1 addition & 0 deletions tests/Symfony/Bundle/ApiPlatformBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ApiPlatformBundleTest extends TestCase
public function testBuild(): void
{
$containerProphecy = $this->prophesize(ContainerBuilder::class);
// TODO: remove in 5.x
$containerProphecy->addCompilerPass(Argument::type(DataProviderPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled();
$containerProphecy->addCompilerPass(Argument::type(AttributeFilterPass::class), PassConfig::TYPE_BEFORE_OPTIMIZATION, 101)->willReturn($containerProphecy->reveal())->shouldBeCalled();
$containerProphecy->addCompilerPass(Argument::type(AttributeResourcePass::class))->shouldBeCalled()->willReturn($containerProphecy->reveal())->shouldBeCalled();
Expand Down
Loading