diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TaxonomyRouteController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TaxonomyRouteController.php index 5ca4134..396dbfb 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TaxonomyRouteController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TaxonomyRouteController.php @@ -7,8 +7,6 @@ namespace Drupal\taxonomy; -use Drupal\taxonomy\Term; -use Drupal\taxonomy\Vocabulary; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; @@ -22,13 +20,13 @@ class TaxonomyRouteController { * * This callback outputs term name suggestions in response to Ajax requests * made by the taxonomy autocomplete widget for taxonomy term reference - * fields. The output is a JSON object of plain-text term suggestions, keyed by - * the user-entered value with the completed term name appended. Term names - * containing commas are wrapped in quotes. + * fields. The output is a JSON object of plain-text term suggestions, keyed + * by the user-entered value with the completed term name appended. Term + * names containing commas are wrapped in quotes. * - * For example, suppose the user has entered the string 'red fish, blue' in the - * field, and there are two taxonomy terms, 'blue fish' and 'blue moon'. The - * JSON output would have the following structure: + * For example, suppose the user has entered the string 'red fish, blue' in + * the field, and there are two taxonomy terms, 'blue fish' and 'blue moon'. + * The JSON output would have the following structure: * @code * { * "red fish, blue fish": "blue fish", @@ -36,9 +34,9 @@ class TaxonomyRouteController { * }; * @endcode * - * @param $field_name + * @param string $field_name * The name of the term reference field. - * @param $tags_typed + * @param string $tags_typed * (optional) A comma-separated list of term names entered in the * autocomplete form element. Only the last term is used for autocompletion. * Defaults to '' (an empty string). @@ -47,22 +45,23 @@ class TaxonomyRouteController { * @see taxonomy_field_widget_info() */ public function autocomplete($field_name, $tags_typed = '') { - // If the request has a '/' in the search text, then the menu system will have - // split it into multiple arguments, recover the intended $tags_typed. + // If the request has a '/' in the search text, then the menu system + // will have split it into multiple arguments, recover the intended + // $tags_typed. $args = func_get_args(); // Shift off the $field_name argument. - array_shift($args); + unset($args[0]); $tags_typed = implode('/', $args); // Make sure the field exists and is a taxonomy field. if (!($field = field_info_field($field_name)) || $field['type'] !== 'taxonomy_term_reference') { // Error string. The JavaScript handler will realize this is not JSON and // will display it as debugging information. - print t('Taxonomy field @field_name not found.', array('@field_name' => $field_name)); - exit; + return new Response(t('Taxonomy field @field_name not found.', array('@field_name' => $field_name))); } - // The user enters a comma-separated list of tags. We only autocomplete the last tag. + // The user enters a comma-separated list of tags. We only autocomplete + // the last tag. $tags_typed = drupal_explode_tags($tags_typed); $tag_last = drupal_strtolower(array_pop($tags_typed));