From 49612fd98b736a1f1b4591aac73f435f8b105633 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Sun, 24 May 2020 15:49:10 -0400 Subject: [PATCH] Use farm_term_parse_names instead of introducing new farm_season_parse_names() function. --- .../farm_crop.farm_quick.planting.inc | 2 +- modules/farm/farm_season/farm_season.module | 41 ------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/modules/farm/farm_crop/farm_crop.farm_quick.planting.inc b/modules/farm/farm_crop/farm_crop.farm_quick.planting.inc index abe72f8dc..e13bb57bc 100644 --- a/modules/farm/farm_crop/farm_crop.farm_quick.planting.inc +++ b/modules/farm/farm_crop/farm_crop.farm_quick.planting.inc @@ -330,7 +330,7 @@ function farm_crop_planting_quick_form_submit($form, &$form_state) { variable_set('farm_crop_planting_season', $season); // Load/create the season term. - $seasons = farm_season_parse_names($season, TRUE); + $seasons = farm_term_parse_names($season, 'farm_season', TRUE); // Get the crop(s) and load/create terms for each. $crops = array(); diff --git a/modules/farm/farm_season/farm_season.module b/modules/farm/farm_season/farm_season.module index c36692251..4c4253676 100644 --- a/modules/farm/farm_season/farm_season.module +++ b/modules/farm/farm_season/farm_season.module @@ -19,44 +19,3 @@ function farm_season_farm_ui_entities() { ), ); } - -/** - * Parse a string of season names and return an array of loaded season entities. If - * season names do not exist, they can optionally be created. - * - * @param string $names - * A comma-separated list of season names. - * @param bool $create - * Whether or not to create seasons that don't exist. Defaults to FALSE. - * - * @return array - * Returns an array of season objects. If the season names exist, they will be - * loaded from the database. Otherwise, they will be created. - */ -function farm_season_parse_names($names, $create = FALSE) { - - // Start with an empty array. - $seasons = array(); - - // Explode the value into an array and only take the first value. - // (Same behavior as taxonomy autocomplete widget.) - $values = drupal_explode_tags($names); - - // If the value is empty, bail. - if (empty($values)) { - return $seasons; - } - - // Iterate through the values and build an array of seasons. - foreach ($values as $value) { - - // Create/load the season term. - $season = farm_term($value, 'farm_season', $create); - - // Add to the array of seasons. - $seasons[] = $season; - } - - // Return the array of seasons. - return $seasons; -}