Issues (116)

src/Registry/RegistryInterface.php (2 issues)

1
<?php
2
3
namespace Bdf\Form\Registry;
4
5
use Bdf\Form\Button\ButtonBuilderInterface;
6
use Bdf\Form\Child\ChildBuilderInterface;
7
use Bdf\Form\ElementBuilderInterface;
8
use Bdf\Form\Filter\FilterInterface;
9
use Bdf\Form\Transformer\TransformerInterface;
10
use LogicException;
11
use Symfony\Component\Form\DataTransformerInterface;
12
use Symfony\Component\Validator\Constraint;
13
14
/**
15
 * Registry for form components
16
 */
17
interface RegistryInterface
18
{
19
    /**
20
     * Create the filter
21
     *
22
     * @param FilterInterface|callable|string $filter
23
     *
24
     * @return FilterInterface
25
     */
26
    public function filter($filter): FilterInterface;
27
28
    /**
29
     * Create the constraint
30
     *
31
     * @param Constraint|callable|array|string $constraint
32
     *
33
     * @return Constraint
34
     */
35
    public function constraint($constraint): Constraint;
36
37
    /**
38
     * Create a view transformer
39
     *
40
     * @param callable|TransformerInterface|DataTransformerInterface $transformer
41
     *
42
     * @return TransformerInterface
43
     *
44
     * @throws LogicException If the transformer is invalid
45
     */
46
    public function transformer($transformer): TransformerInterface;
47
48
    /**
49
     * Create the child builder
50
     *
51
     * Usage:
52
     * <code>
53
     * $registry->childBuilder(Form::class, 'embedded'); // Create an embedded form builder
54
     * $registry->childBuilder(MyCustomForm::class, 'custom'); // Create a custom embedded form builder
55
     * $registry->childBuilder(IntegerElement::class, 'foo'); // Create builder for integer element "foo"
56
     * </code>
57
     *
58
     * @param class-string<E> $element The element class name
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<E> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<E>.
Loading history...
59
     * @param string $name The child name
60
     *
61
     * @return ChildBuilderInterface<ElementBuilderInterface<E>>
62
     *
63
     * @template E as \Bdf\Form\ElementInterface
64
     *
65
     * @throws \InvalidArgumentException When cannot found the element builder
66
     */
67
    public function childBuilder(string $element, string $name): ChildBuilderInterface;
68
69
    /**
70
     * Create the element build for an element
71
     *
72
     * Usage:
73
     * <code>
74
     * $registry->elementBuilder(Form::class); // Create the form builder
75
     * $registry->elementBuilder(MyCustomForm::class); // Should also works with custom forms
76
     * $registry->elementBuilder(IntegerElement::class); // For a leaf element
77
     * </code>
78
     *
79
     * @param class-string<E> $element The element class name
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<E> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<E>.
Loading history...
80
     *
81
     * @return ElementBuilderInterface<E>
82
     *
83
     * @template E as \Bdf\Form\ElementInterface
84
     *
85
     * @throws \InvalidArgumentException When cannot found the element builder
86
     */
87
    public function elementBuilder(string $element): ElementBuilderInterface;
88
89
    /**
90
     * Create the build for a button
91
     *
92
     * @param string $name The button name
93
     *
94
     * @return ButtonBuilderInterface
95
     */
96
    public function buttonBuilder(string $name): ButtonBuilderInterface;
97
}
98