From dacaacf43477cc604b25d057db5532022659f665 Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Tue, 5 Oct 2010 20:35:21 +0000 Subject: [PATCH] Simplify vocabulary loading, better safeguard missing vocabulary configuration. --- plugins/FeedsTermProcessor.inc | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/plugins/FeedsTermProcessor.inc b/plugins/FeedsTermProcessor.inc index cd817a53..07e67e2c 100644 --- a/plugins/FeedsTermProcessor.inc +++ b/plugins/FeedsTermProcessor.inc @@ -23,11 +23,6 @@ class FeedsTermProcessor extends FeedsProcessor { * Implements FeedsProcessor::process(). */ public function process(FeedsSource $source, FeedsParserResult $parser_result) { - - if (empty($this->config['vocabulary'])) { - throw new Exception(t('You must define a vocabulary for Taxonomy term processor before importing.')); - } - // Count number of created and updated nodes. $created = $updated = $no_name = 0; @@ -223,24 +218,12 @@ class FeedsTermProcessor extends FeedsProcessor { * Return vocabulary to map to. */ public function vocabulary() { - // Legacy handling for old feeds importers. - if (is_numeric($this->config['vocabulary'])) { - $vocabularies = taxonomy_get_vocabularies(); - return isset($vocabularies[$this->config['vocabulary']]) ? $vocabularies[$this->config['vocabulary']] : NULL; - } - else { + if (isset($this->config['vocabulary'])) { if ($vocabulary = taxonomy_vocabulary_machine_name_load($this->config['vocabulary'])) { return $vocabulary; } - else { - $vocabularies = taxonomy_get_vocabularies(); - foreach ($vocabularies as $vocabulary) { - if ($vocabulary->module == $this->config['vocabulary']) { - return $vocabulary; - } - } - } } + throw new Exception(t('No vocabulary defined for Taxonomy Term processor.')); } /** -- GitLab