Browse Source

Coding standards, copy/paste detector (embarassing...)

pull/754/head
dannylamb 5 years ago
parent
commit
14a5a5912c
  1. 14
      src/Form/AddChildrenForm.php
  2. 25
      src/Form/AddMediaForm.php

14
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',

25
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;
}
/**

Loading…
Cancel
Save