Skip to content

[TwigComponent][Doc] AsTwigComponent docblocks #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/TwigComponent/src/Attribute/AsTwigComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
#[\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 -> <twig:Alert />
* App\Twig\Components\Foo\Bar -> <twig: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',
) {
}
Expand Down
2 changes: 2 additions & 0 deletions src/TwigComponent/src/Attribute/ExposeInTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD)]
Expand Down
4 changes: 4 additions & 0 deletions src/TwigComponent/src/Attribute/PostMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
Expand Down
4 changes: 4 additions & 0 deletions src/TwigComponent/src/Attribute/PreMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
Expand Down