Example #1
0
 /**
  * Returns the result of an Entity reference autocomplete request.
  *
  * @param string $input
  *   The label of the entity to query by.
  *
  * @return mixed
  *  The JSON value encoded in its appropriate PHP type.
  */
 protected function getAutocompleteResult($input)
 {
     $request = Request::create('entity_reference_autocomplete/' . $this->entityType . '/default');
     $request->query->set('q', $input);
     $entity_reference_controller = EntityAutocompleteController::create($this->container);
     $result = $entity_reference_controller->handleAutocomplete($request, $this->entityType, 'default')->getContent();
     return Json::decode($result);
 }
 /**
  * Returns the result of an Entity reference autocomplete request.
  *
  * @param string $input
  *   The label of the entity to query by.
  *
  * @return mixed
  *  The JSON value encoded in its appropriate PHP type.
  */
 protected function getAutocompleteResult($input)
 {
     $request = Request::create('entity_reference_autocomplete/' . $this->entityType . '/default');
     $request->query->set('q', $input);
     $selection_settings = [];
     $selection_settings_key = Crypt::hmacBase64(serialize($selection_settings) . $this->entityType . 'default', Settings::getHashSalt());
     \Drupal::keyValue('entity_autocomplete')->set($selection_settings_key, $selection_settings);
     $entity_reference_controller = EntityAutocompleteController::create($this->container);
     $result = $entity_reference_controller->handleAutocomplete($request, $this->entityType, 'default', $selection_settings_key)->getContent();
     return Json::decode($result);
 }