-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAsFlasherFactory.php
38 lines (35 loc) · 1.05 KB
/
AsFlasherFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace Flasher\Symfony\Attribute;
/**
* AsFlasherFactory - Attribute for tagging notification factories.
*
* This attribute enables auto-configuration of notification factory services in Symfony.
* When applied to a factory class, it automatically registers the class with the container
* using the specified alias, making it available to the PHPFlasher system.
*
* Design patterns:
* - Attribute-based Configuration: Uses PHP 8 attributes for declarative service configuration
* - Service Tagging: Implements Symfony's tag-based service discovery mechanism
*
* Usage:
* ```php
* #[AsFlasherFactory('toastr')]
* class ToastrFactory implements NotificationFactoryInterface
* {
* // ...
* }
* ```
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
final readonly class AsFlasherFactory
{
/**
* Creates a new AsFlasherFactory attribute.
*
* @param string $alias The unique alias for the notification factory (e.g., 'toastr', 'noty')
*/
public function __construct(public string $alias)
{
}
}