Skip to content

Commit

Permalink
No need to account for version because of version 4 requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Apr 25, 2023
1 parent 6515b91 commit b077398
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/Api/Representation/CollectingFormRepresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Collecting\Api\Representation;

use Collecting\Form\Element;
use Composer\Semver\Comparator;
use Omeka\Api\Exception\BadRequestException;
use Omeka\Api\Exception\NotFoundException;
use Omeka\Api\Representation\AbstractEntityRepresentation;
Expand Down Expand Up @@ -133,7 +132,6 @@ public function getForm()
$user = $auth->getIdentity(); // returns a User entity or null

$customVocabModule = $modules->getModule('CustomVocab');
$customVocabVersion = $customVocabModule ? $customVocabModule->getDb('version') : null;
$customVocabActive = $customVocabModule && ModuleManager::STATE_ACTIVE === $customVocabModule->getState();

$form = new Form(sprintf('collecting_form_%s', $this->id()));
Expand Down Expand Up @@ -187,18 +185,10 @@ public function getForm()
} catch (NotFoundException $e) {
continue 3; // The custom vocab does not exist
}
// Adjust handling as new CustomVocab features were introduced.
// - Items type introduced in v1.2.0
// - URIs type introduced in v1.4.0
// - Type methods return arrays in v1.7.0
if (!$customVocab->terms()) {
$customVocabTerms = $customVocab->terms();
if (!$customVocabTerms) {
continue 3; // URIs and Items vocab types not implemented
}
if (Comparator::lessThan($customVocabVersion, '1.7.0')) {
$customVocabTerms = array_map('trim', explode(PHP_EOL, $customVocab->terms()));
} else {
$customVocabTerms = $customVocab->terms();
}
$element = new Element\PromptSelect($name);
$element->setEmptyOption('Please choose one...') // @translate
->setValueOptions(array_combine($customVocabTerms, $customVocabTerms));
Expand Down

0 comments on commit b077398

Please sign in to comment.