Verified Commit 96664ce8 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3427741 by longwave, sakthi_dev, Spokje: Notify downstream users that...

Issue #3427741 by longwave, sakthi_dev, Spokje: Notify downstream users that ContainerAware is going away
parent 5085b5a0
Loading
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -52,6 +52,10 @@

# Temporarily for testing Symfony 6.4.
%Since symfony/dependency-injection 6.4: "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" is deprecated, use dependency injection instead.%
%The ".*" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The ".*" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The ".*" interface extends "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Core\\Logger\\LoggerChannelFactory" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Core\\Logger\\LoggerChannelFactory" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Core\\Queue\\QueueFactory" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Core\\Queue\\QueueFactory" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Tests\\Core\\Controller\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Tests\\Core\\DependencyInjection\\DependencySerializationTestDummy" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The "Drupal\\Tests\\Core\\Utility\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public function getInstanceFromDefinition($definition) {
    }

    if ($instance instanceof ContainerAwareInterface) {
      @trigger_error('Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661', E_USER_DEPRECATED);
      $instance->setContainer($this->container);
    }

+15 −2
Original line number Diff line number Diff line
@@ -52,8 +52,12 @@ protected function setUp(): void {
   * Tests createController().
   *
   * @dataProvider providerTestCreateController
   * @group legacy
   */
  public function testCreateController($controller, $class, $output) {
  public function testCreateController($controller, $class, $output, string $deprecation = NULL) {
    if ($deprecation) {
      $this->expectDeprecation($deprecation);
    }
    $this->container->set('some_service', new MockController());
    $result = $this->controllerResolver->getControllerFromDefinition($controller);
    $this->assertCallableController($result, $class, $output);
@@ -71,7 +75,12 @@ public static function providerTestCreateController() {
      // Tests a class with injection.
      ['Drupal\Tests\Core\Controller\MockContainerInjection::getResult', 'Drupal\Tests\Core\Controller\MockContainerInjection', 'This used injection.'],
      // Tests a ContainerAware class.
      ['Drupal\Tests\Core\Controller\MockContainerAware::getResult', 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'],
      [
        'Drupal\Tests\Core\Controller\MockContainerAware::getResult',
        'Drupal\Tests\Core\Controller\MockContainerAware',
        'This is container aware.',
        'Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661',
      ],
    ];
  }

@@ -95,8 +104,12 @@ public function testCreateControllerInvalidName() {
   * Tests getController().
   *
   * @dataProvider providerTestGetController
   * @group legacy
   */
  public function testGetController($attributes, $class, $output = NULL) {
    if ($class) {
      $this->expectDeprecation('Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661');
    }
    $request = new Request([], [], $attributes);
    $result = $this->controllerResolver->getController($request);
    if ($class) {
+6 −1
Original line number Diff line number Diff line
@@ -42,8 +42,12 @@ protected function setUp(): void {
  /**
   * @dataProvider callableResolverTestCases
   * @covers ::getCallableFromDefinition
   * @group legacy
   */
  public function testCallbackResolver($definition, $result) {
  public function testCallbackResolver($definition, $result, string $deprecation = NULL) {
    if ($deprecation) {
      $this->expectDeprecation($deprecation);
    }
    $argument = 'bar';
    $this->assertEquals($result . '+' . $argument, $this->resolver->getCallableFromDefinition($definition)($argument));
  }
@@ -98,6 +102,7 @@ function ($suffix) {
      'Non-static function, instantiated by class resolver, container aware' => [
        '\Drupal\Tests\Core\Utility\MockContainerAware::getResult',
        'Drupal\Tests\Core\Utility\MockContainerAware::getResult',
        'Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661',
      ],
      'Service notation' => [
        'test_service:method',