Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #54365 [DependencyInjection] Apply attribute configurator to …
…child classes (GromNaN) This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [DependencyInjection] Apply attribute configurator to child classes | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Fix #52898 | License | MIT This allows extending attribute classes registered for autoconfiguration. Use-case: Share configuration between several classes with pre-configured attribute classes. As described in #52898 (bus name for `AsMessageHandler`, schedule name for `AsCronTask` and `AsPeriodicTask`) The child-class attribute is handled by the same function as it's parent class that is registered for autoconfiguration. This means any additional property will be ignored (unless supported, which could be new feature for the `AsTaggedItem` attribute configurator). If there is a configurator for the child class, the configurator for the parent class is not called. Commits ------- 69dc71b [DependencyInjection] Apply attribute configurator to child classes
- Loading branch information
Showing
7 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Symfony/Component/DependencyInjection/Tests/Fixtures/Attribute/CustomChildAttribute.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Attribute; | ||
|
||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_PARAMETER)] | ||
class CustomChildAttribute extends CustomAnyAttribute | ||
{ | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Symfony/Component/DependencyInjection/Tests/Fixtures/TaggedService5.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures; | ||
|
||
use Symfony\Component\DependencyInjection\Tests\Fixtures\Attribute\CustomChildAttribute; | ||
|
||
#[CustomChildAttribute] | ||
final class TaggedService5 | ||
{ | ||
#[CustomChildAttribute] | ||
public string $name; | ||
|
||
public function __construct( | ||
#[CustomChildAttribute] | ||
private string $param1, | ||
) {} | ||
|
||
#[CustomChildAttribute] | ||
public function fooAction( | ||
#[CustomChildAttribute] | ||
string $param1 | ||
) {} | ||
} |