1 | <?php |
||
18 | class EntityBrowserForm extends FormBase implements EntityBrowserFormInterface { |
||
19 | |||
20 | /** |
||
21 | * UUID generator service. |
||
22 | * |
||
23 | * @var \Drupal\Component\Uuid\UuidInterface |
||
24 | */ |
||
25 | protected $uuidGenerator; |
||
26 | |||
27 | /** |
||
28 | * The entity browser object. |
||
29 | * |
||
30 | * @var \Drupal\entity_browser\EntityBrowserInterface |
||
31 | */ |
||
32 | protected $entityBrowser; |
||
33 | |||
34 | /** |
||
35 | * The entity browser selection storage. |
||
36 | * |
||
37 | * @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface |
||
38 | */ |
||
39 | protected $selectionStorage; |
||
40 | |||
41 | /** |
||
42 | * Constructs a EntityBrowserForm object. |
||
43 | * |
||
44 | * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator |
||
45 | * The UUID generator service. |
||
46 | * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $selection_storage |
||
47 | * Selection storage. |
||
48 | */ |
||
49 | public function __construct(UuidInterface $uuid_generator, KeyValueStoreExpirableInterface $selection_storage) { |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public static function create(ContainerInterface $container) { |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | public function getFormId() { |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function setEntityBrowser(EntityBrowserInterface $entity_browser) { |
||
77 | |||
78 | /** |
||
79 | * Initializes form state. |
||
80 | * |
||
81 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
82 | * Form state object. |
||
83 | */ |
||
84 | protected function init(FormStateInterface $form_state) { |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | public function buildForm(array $form, FormStateInterface $form_state) { |
||
149 | |||
150 | /** |
||
151 | * Check if entity browser with selected configuration combination can work. |
||
152 | */ |
||
153 | protected function isFunctionalForm() { |
||
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | public function validateForm(array &$form, FormStateInterface $form_state) { |
||
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | public function submitForm(array &$form, FormStateInterface $form_state) { |
||
202 | |||
203 | /** |
||
204 | * Returns the widget that is currently selected. |
||
205 | * |
||
206 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
207 | * The current state of the form. |
||
208 | * |
||
209 | * @return string |
||
210 | * ID of currently selected widget. |
||
211 | */ |
||
212 | protected function getCurrentWidget(FormStateInterface $form_state) { |
||
220 | |||
221 | /** |
||
222 | * Sets widget that is currently active. |
||
223 | * |
||
224 | * @param string $widget |
||
225 | * New active widget UUID. |
||
226 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
227 | * Form state. |
||
228 | */ |
||
229 | protected function setCurrentWidget($widget, FormStateInterface $form_state) { |
||
232 | |||
233 | /** |
||
234 | * Indicates selection is done. |
||
235 | * |
||
236 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
237 | * Form state. |
||
238 | * |
||
239 | * @return bool |
||
240 | * Indicates selection is done. |
||
241 | */ |
||
242 | protected function isSelectionCompleted(FormStateInterface $form_state) { |
||
245 | |||
246 | /** |
||
247 | * Returns currently selected entities. |
||
248 | * |
||
249 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
||
250 | * Form state. |
||
251 | * |
||
252 | * @return \Drupal\Core\Entity\EntityInterface[] |
||
253 | * Array of currently selected entities. |
||
254 | */ |
||
255 | protected function getSelectedEntities(FormStateInterface $form_state) { |
||
258 | |||
259 | } |
||
260 |