Skip to content

Commit 52dc225

Browse files
committed
minor #1229 [TwigComponent][Doc] AsTwigComponent docblocks (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent][Doc] AsTwigComponent docblocks Add some documentation on the AsTwigComponent attribute. Commits ------- 6c2a4a7 [TwigComponent][Doc] AsTwigComponent docblocks
2 parents 262db2b + 6c2a4a7 commit 52dc225

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/TwigComponent/src/Attribute/AsTwigComponent.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,52 @@
1212
namespace Symfony\UX\TwigComponent\Attribute;
1313

1414
/**
15+
* An attribute to register a TwigComponent.
16+
*
17+
* @see https://symfony.com/bundles/ux-twig-component
18+
*
1519
* @author Kevin Bond <[email protected]>
1620
*/
1721
#[\Attribute(\Attribute::TARGET_CLASS)]
1822
class AsTwigComponent
1923
{
2024
public function __construct(
25+
/**
26+
* The component name (ie: Button).
27+
*
28+
* With the default configuration, the template path is resolved using
29+
* the component's class name.
30+
*
31+
* App\Twig\Components\Alert -> <twig:Alert />
32+
* App\Twig\Components\Foo\Bar -> <twig:Foo:Bar />
33+
*
34+
* @see https://symfony.com/bundles/ux-twig-component#naming-your-component
35+
*/
2136
private ?string $name = null,
37+
38+
/**
39+
* The template path of the component (ie: components/Button.html.twig).
40+
*
41+
* With the default configuration, the template path is resolved using
42+
* the component's name.
43+
*
44+
* Button -> templates/components/Button.html.twig
45+
* Foo:Bar -> templates/components/Foo/Bar.html.twig
46+
*
47+
* @see https://symfony.com/bundles/ux-twig-component#component-template-path
48+
*/
2249
private ?string $template = null,
50+
51+
/**
52+
* Whether to expose every public property as a Twig variable.
53+
*
54+
* @see https://symfony.com/bundles/ux-twig-component#passing-data-props-into-your-component
55+
*/
2356
private bool $exposePublicProps = true,
57+
58+
/**
59+
* The name of the special "attributes" variable in the template.
60+
*/
2461
private string $attributesVar = 'attributes',
2562
) {
2663
}

src/TwigComponent/src/Attribute/ExposeInTemplate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* in a component template (`someProp` vs `this.someProp`). These
1717
* properties must be "accessible" (have a getter).
1818
*
19+
* @see https://symfony.com/bundles/ux-twig-component#exposeintemplate-attribute
20+
*
1921
* @author Kevin Bond <[email protected]>
2022
*/
2123
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD)]

src/TwigComponent/src/Attribute/PostMount.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
namespace Symfony\UX\TwigComponent\Attribute;
1313

1414
/**
15+
* An attribute to register a PostMount hook.
16+
*
17+
* @see https://symfony.com/bundles/ux-twig-component#postmount-hook
18+
*
1519
* @author Kevin Bond <[email protected]>
1620
*/
1721
#[\Attribute(\Attribute::TARGET_METHOD)]

src/TwigComponent/src/Attribute/PreMount.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
namespace Symfony\UX\TwigComponent\Attribute;
1313

1414
/**
15+
* An attribute to register a PreMount hook.
16+
*
17+
* @see https://symfony.com/bundles/ux-twig-component#premount-hook
18+
*
1519
* @author Kevin Bond <[email protected]>
1620
*/
1721
#[\Attribute(\Attribute::TARGET_METHOD)]

0 commit comments

Comments
 (0)