Skip to content

Commit e7e734d

Browse files
[DependencyInjection] Deprecate ContainerAwareInterface and ContainerAwareTrait
1 parent 52a9292 commit e7e734d

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

UPGRADE-6.4.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
UPGRADE FROM 6.3 to 6.4
22
=======================
33

4+
DependencyInjection
5+
-------------------
6+
7+
* Deprecate `ContainerAwareInterface` and `ContainerAwareTrait`, use dependency injection instead
8+
9+
Before:
10+
```php
11+
class MyService implements ContainerAwareInterface
12+
{
13+
use ContainerAwareTrait;
14+
15+
// ...
16+
}
17+
```
18+
19+
After:
20+
```php
21+
class MyService
22+
{
23+
private ContainerInterface $container;
24+
25+
// Inject the container through the constructor...
26+
public function __construct(ContainerInterface $container)
27+
{
28+
$this->container = $container;
29+
}
30+
31+
// ... or by using the #[Required] attribute
32+
#[Required]
33+
public function setContainer(ContainerInterface $container): void
34+
{
35+
$this->container = $container;
36+
}
37+
}
38+
```
39+
440
DoctrineBridge
541
--------------
642

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.4
5+
---
6+
7+
* Deprecate `ContainerAwareInterface` and `ContainerAwareTrait`, use dependency injection instead
8+
49
6.3
510
---
611

src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* ContainerAwareInterface should be implemented by classes that depends on a Container.
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
18+
*
19+
* @deprecated since Symfony 6.4, use dependency injection instead
1820
*/
1921
interface ContainerAwareInterface
2022
{

src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* ContainerAware trait.
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
18+
*
19+
* @deprecated since Symfony 6.4, use dependency injection instead
1820
*/
1921
trait ContainerAwareTrait
2022
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy