-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChip.php
More file actions
51 lines (43 loc) · 1.31 KB
/
Chip.php
File metadata and controls
51 lines (43 loc) · 1.31 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
47
48
49
50
51
<?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\ExposeInTemplate;
use Symfony\UX\TwigComponent\Attribute\PreMount;
#[AsTwigComponent('ibexa:chip')]
final class Chip
{
public bool $error = false;
#[ExposeInTemplate('is_deletable')]
public bool $isDeletable = true;
public bool $disabled = false;
/**
* @param array<string, mixed> $props
*
* @return array<string, mixed>
*/
#[PreMount]
public function validate(array $props): array
{
$resolver = new OptionsResolver();
$resolver->setIgnoreUndefined();
$resolver
->define('error')
->allowedTypes('bool')
->default(false);
$resolver
->define('isDeletable')
->allowedTypes('bool')
->default(true);
$resolver
->define('disabled')
->allowedTypes('bool')
->default(false);
return $resolver->resolve($props) + $props;
}
}