diff --git a/src/Form/AddChildrenForm.php b/src/Form/AddChildrenForm.php index a07698b6..4df05ea5 100644 --- a/src/Form/AddChildrenForm.php +++ b/src/Form/AddChildrenForm.php @@ -155,19 +155,7 @@ class AddChildrenForm extends AddMediaForm { } } - // Media use checkboxes. - $options = []; - $terms = $this->entityTypeManager->getStorage('taxonomy_term')->loadTree('islandora_media_use', 0, NULL, TRUE); - foreach ($terms as $term) { - $options[$term->id()] = $term->getName(); - }; - $form['use'] = [ - '#type' => 'checkboxes', - '#title' => $this->t('Usage'), - '#description' => $this->t("Defined by Portland Common Data Model: Use Extension https://pcdm.org/2015/05/12/use. ''Original File'' will trigger creation of derivatives."), - '#options' => $options, - '#required' => TRUE, - ]; + $this->addMediaUseTerms($form); $form['submit'] = [ '#type' => 'submit', diff --git a/src/Form/AddMediaForm.php b/src/Form/AddMediaForm.php index d77029da..0b1daec8 100644 --- a/src/Form/AddMediaForm.php +++ b/src/Form/AddMediaForm.php @@ -169,7 +169,23 @@ class AddMediaForm extends FormBase { '#multiple' => TRUE, ]; - // Media use checkboxes. + $this->addMediaUseTerms($form); + + $form['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Submit'), + ]; + + return $form; + } + + /** + * Helper function to add media use checkboxes to the form. + * + * @param array $form + * Form array. + */ + protected function addMediaUseTerms(&array $form) { $options = []; $terms = $this->entityTypeManager->getStorage('taxonomy_term')->loadTree('islandora_media_use', 0, NULL, TRUE); foreach ($terms as $term) { @@ -182,13 +198,6 @@ class AddMediaForm extends FormBase { '#options' => $options, '#required' => TRUE, ]; - - $form['submit'] = [ - '#type' => 'submit', - '#value' => $this->t('Submit'), - ]; - - return $form; } /**