1 | <?php |
||
26 | final class FormRegistry extends Emitter implements EmitterInterface |
||
27 | { |
||
28 | const PARSER_YAML = 'yaml'; |
||
29 | const PARSER_PHP = 'php'; |
||
30 | |||
31 | /** |
||
32 | * @var string parser type |
||
33 | */ |
||
34 | private $parser; |
||
35 | |||
36 | /** |
||
37 | * @var FormRegistry |
||
38 | */ |
||
39 | private static $instance; |
||
40 | |||
41 | /** |
||
42 | * FormRegistry constructor, singleton pattern |
||
43 | */ |
||
44 | 2 | private function __construct() |
|
56 | |||
57 | /** |
||
58 | * @var array List of known parser types |
||
59 | */ |
||
60 | private static $knownParsers = [ |
||
61 | self::PARSER_YAML => YamlParser::class, |
||
62 | self::PARSER_PHP => PhpParser::class |
||
63 | ]; |
||
64 | |||
65 | /** |
||
66 | * Generates a for for the provided definitions file |
||
67 | * |
||
68 | * @param string $defFile The path to the form definition file |
||
69 | * @param string $type Parser type |
||
70 | * |
||
71 | * @return FormInterface |
||
72 | */ |
||
73 | 4 | public function get($defFile, $type = self::PARSER_YAML) |
|
83 | |||
84 | /** |
||
85 | * Returns a self instance |
||
86 | * |
||
87 | * @return FormRegistry|static |
||
88 | */ |
||
89 | 4 | public static function getInstance() |
|
96 | |||
97 | /** |
||
98 | * Generates a for for the provided definitions file |
||
99 | * |
||
100 | * @param string $defFile The path to the form definition file |
||
101 | * @param string $type Parser type |
||
102 | * |
||
103 | * @return FormInterface |
||
104 | */ |
||
105 | 2 | public static function getForm($defFile, $type = self::PARSER_YAML) |
|
109 | } |