diff --git a/src/TwigComponent/src/Attribute/AsTwigComponent.php b/src/TwigComponent/src/Attribute/AsTwigComponent.php index e2e663fc8a3..3d31240b686 100644 --- a/src/TwigComponent/src/Attribute/AsTwigComponent.php +++ b/src/TwigComponent/src/Attribute/AsTwigComponent.php @@ -12,15 +12,52 @@ namespace Symfony\UX\TwigComponent\Attribute; /** + * An attribute to register a TwigComponent. + * + * @see https://symfony.com/bundles/ux-twig-component + * * @author Kevin Bond */ #[\Attribute(\Attribute::TARGET_CLASS)] class AsTwigComponent { public function __construct( + /** + * The component name (ie: Button). + * + * With the default configuration, the template path is resolved using + * the component's class name. + * + * App\Twig\Components\Alert -> + * App\Twig\Components\Foo\Bar -> + * + * @see https://symfony.com/bundles/ux-twig-component#naming-your-component + */ private ?string $name = null, + + /** + * The template path of the component (ie: components/Button.html.twig). + * + * With the default configuration, the template path is resolved using + * the component's name. + * + * Button -> templates/components/Button.html.twig + * Foo:Bar -> templates/components/Foo/Bar.html.twig + * + * @see https://symfony.com/bundles/ux-twig-component#component-template-path + */ private ?string $template = null, + + /** + * Whether to expose every public property as a Twig variable. + * + * @see https://symfony.com/bundles/ux-twig-component#passing-data-props-into-your-component + */ private bool $exposePublicProps = true, + + /** + * The name of the special "attributes" variable in the template. + */ private string $attributesVar = 'attributes', ) { } diff --git a/src/TwigComponent/src/Attribute/ExposeInTemplate.php b/src/TwigComponent/src/Attribute/ExposeInTemplate.php index dd6d993ae01..d4a3941eb05 100644 --- a/src/TwigComponent/src/Attribute/ExposeInTemplate.php +++ b/src/TwigComponent/src/Attribute/ExposeInTemplate.php @@ -16,6 +16,8 @@ * in a component template (`someProp` vs `this.someProp`). These * properties must be "accessible" (have a getter). * + * @see https://symfony.com/bundles/ux-twig-component#exposeintemplate-attribute + * * @author Kevin Bond */ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD)] diff --git a/src/TwigComponent/src/Attribute/PostMount.php b/src/TwigComponent/src/Attribute/PostMount.php index cdf1ba230f1..276f34e0c59 100644 --- a/src/TwigComponent/src/Attribute/PostMount.php +++ b/src/TwigComponent/src/Attribute/PostMount.php @@ -12,6 +12,10 @@ namespace Symfony\UX\TwigComponent\Attribute; /** + * An attribute to register a PostMount hook. + * + * @see https://symfony.com/bundles/ux-twig-component#postmount-hook + * * @author Kevin Bond */ #[\Attribute(\Attribute::TARGET_METHOD)] diff --git a/src/TwigComponent/src/Attribute/PreMount.php b/src/TwigComponent/src/Attribute/PreMount.php index 3304a16465b..519135b5ec5 100644 --- a/src/TwigComponent/src/Attribute/PreMount.php +++ b/src/TwigComponent/src/Attribute/PreMount.php @@ -12,6 +12,10 @@ namespace Symfony\UX\TwigComponent\Attribute; /** + * An attribute to register a PreMount hook. + * + * @see https://symfony.com/bundles/ux-twig-component#premount-hook + * * @author Kevin Bond */ #[\Attribute(\Attribute::TARGET_METHOD)]