1 | <?php |
||
19 | class EntityBrowserForm extends FormBase implements EntityBrowserFormInterface { |
||
20 | |||
21 | /** |
||
22 | * UUID generator service. |
||
23 | * |
||
24 | * @var \Drupal\Component\Uuid\UuidInterface |
||
25 | */ |
||
26 | protected $uuidGenerator; |
||
27 | |||
28 | /** |
||
29 | * The entity browser object. |
||
30 | * |
||
31 | * @var \Drupal\entity_browser\EntityBrowserInterface |
||
32 | */ |
||
33 | protected $entityBrowser; |
||
34 | |||
35 | /** |
||
36 | * The entity browser selection storage. |
||
37 | * |
||
38 | * @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface |
||
39 | */ |
||
40 | protected $selectionStorage; |
||
41 | |||
42 | /** |
||
43 | * The renderer service. |
||
44 | * |
||
45 | * @var \Drupal\Core\Render\RendererInterface |
||
46 | */ |
||
47 | protected $renderer; |
||
48 | |||
49 | /** |
||
50 | * Constructs a EntityBrowserForm object. |
||
51 | * |
||
52 | * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator |
||
53 | * The UUID generator service. |
||
54 | * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $selection_storage |
||
55 | * Selection storage. |
||
56 | * @param \Drupal\Core\Render\RendererInterface $renderer |
||
57 | * The renderer service. |
||
58 | */ |
||
59 | public function __construct(UuidInterface $uuid_generator, KeyValueStoreExpirableInterface $selection_storage, RendererInterface $renderer) { |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public static function create(ContainerInterface $container) { |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function getFormId() { |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function setEntityBrowser(EntityBrowserInterface $entity_browser) { |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function getEntityBrowser() { |
||
96 | |||
97 | /** |
||
98 | * Initializes form state. |
||
99 | * |
||
100 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
101 | * Form state object. |
||
102 | */ |
||
103 | protected function init(FormStateInterface $form_state) { |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | public function buildForm(array $form, FormStateInterface $form_state) { |
||
186 | |||
187 | /** |
||
188 | * Check if entity browser with selected configuration combination can work. |
||
189 | */ |
||
190 | protected function isFunctionalForm() { |
||
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | */ |
||
205 | public function validateForm(array &$form, FormStateInterface $form_state) { |
||
210 | |||
211 | /** |
||
212 | * {@inheritdoc} |
||
213 | */ |
||
214 | public function submitForm(array &$form, FormStateInterface $form_state) { |
||
239 | |||
240 | /** |
||
241 | * Returns the widget that is currently selected. |
||
242 | * |
||
243 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
244 | * The current state of the form. |
||
245 | * |
||
246 | * @return string |
||
247 | * ID of currently selected widget. |
||
248 | */ |
||
249 | protected function getCurrentWidget(FormStateInterface $form_state) { |
||
257 | |||
258 | /** |
||
259 | * Sets widget that is currently active. |
||
260 | * |
||
261 | * @param string $widget |
||
262 | * New active widget UUID. |
||
263 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
264 | * Form state. |
||
265 | */ |
||
266 | protected function setCurrentWidget($widget, FormStateInterface $form_state) { |
||
269 | |||
270 | /** |
||
271 | * Indicates selection is done. |
||
272 | * |
||
273 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
274 | * Form state. |
||
275 | * |
||
276 | * @return bool |
||
277 | * Indicates selection is done. |
||
278 | */ |
||
279 | protected function isSelectionCompleted(FormStateInterface $form_state) { |
||
282 | |||
283 | /** |
||
284 | * Returns currently selected entities. |
||
285 | * |
||
286 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
287 | * Form state. |
||
288 | * |
||
289 | * @return \Drupal\Core\Entity\EntityInterface[] |
||
290 | * Array of currently selected entities. |
||
291 | */ |
||
292 | protected function getSelectedEntities(FormStateInterface $form_state) { |
||
295 | |||
296 | } |
||
297 |