-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChoiceInputLabel.php
More file actions
46 lines (39 loc) · 1.2 KB
/
ChoiceInputLabel.php
File metadata and controls
46 lines (39 loc) · 1.2 KB
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
39
40
41
42
43
44
45
46
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\DesignSystemTwig\Twig\Components;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
use Symfony\UX\TwigComponent\Attribute\PreMount;
#[AsTwigComponent('ibexa:choice_input_label')]
final class ChoiceInputLabel
{
public string $content = '';
public string $for;
/**
* @param array<string, mixed> $props
*
* @return array<string, mixed>
*/
#[PreMount]
public function validate(array $props): array
{
$resolver = new OptionsResolver();
$resolver->setIgnoreUndefined();
$resolver
->define('content')
->allowedTypes('string')
->default('');
$resolver
->define('for')
->required()
->allowedTypes('string')
->allowedValues(static function (string $value): bool {
return trim($value) !== '';
});
return $resolver->resolve($props) + $props;
}
}