1 | <?php |
||
31 | 1 | final class WidgetsManager implements \ArrayAccess, \IteratorAggregate |
|
32 | { |
||
33 | /** |
||
34 | * Implement nette smart magic |
||
35 | */ |
||
36 | 1 | use Nette\SmartObject; |
|
37 | |||
38 | /** |
||
39 | * @var Widgets\IFactory[][] |
||
40 | */ |
||
41 | private $widgets = [ |
||
42 | 'default' => [] |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * Checks whether a widget is registered |
||
47 | * |
||
48 | * @param string $type |
||
49 | * @param string $group |
||
50 | * |
||
51 | * @return bool |
||
52 | */ |
||
53 | public function has(string $type, string $group = 'default') : bool |
||
57 | |||
58 | /** |
||
59 | * Gets a widget |
||
60 | * |
||
61 | * @param string $type |
||
62 | * @param string $group |
||
63 | * |
||
64 | * @return Widgets\IFactory|NULL |
||
65 | */ |
||
66 | public function get(string $type, string $group = 'default') : ?Widgets\IFactory |
||
75 | |||
76 | /** |
||
77 | * Helper method for widgets factories registering |
||
78 | * |
||
79 | * @param Widgets\IFactory $factory |
||
80 | * @param string $type |
||
81 | * @param string $group |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public function register(Widgets\IFactory $factory, string $type, string $group = 'default') : void |
||
92 | |||
93 | /** |
||
94 | * Implements the \IteratorAggregate |
||
95 | * |
||
96 | * @return \Iterator |
||
97 | */ |
||
98 | public function getIterator() |
||
102 | |||
103 | /** |
||
104 | * Implements the \ArrayAccess |
||
105 | * |
||
106 | * @param string $offset |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function offsetExists($offset) |
||
114 | |||
115 | /** |
||
116 | * Implements the \ArrayAccess |
||
117 | * |
||
118 | * @param string $offset |
||
119 | * |
||
120 | * @return Widgets\IFactory[] |
||
121 | */ |
||
122 | public function offsetGet($offset) |
||
126 | |||
127 | /** |
||
128 | * Implements the \ArrayAccess |
||
129 | * |
||
130 | * @param string $offset |
||
131 | * @param Widgets\IFactory[]|NULL $value |
||
132 | */ |
||
133 | public function offsetSet($offset, $value) |
||
137 | |||
138 | /** |
||
139 | * Implements the \ArrayAccess |
||
140 | * |
||
141 | * @param string $offset |
||
142 | */ |
||
143 | public function offsetUnset($offset) |
||
147 | } |
||
148 |