Returns the result of an Entity reference autocomplete request.
string $type: The Entity reference autocomplete type (e.g. 'single', 'tags').
string $input: The label of the entity to query by.
mixed The JSON value encoded in its appropriate PHP type.
protected function getAutocompleteResult($type, $input) {
$request = Request::create('entity_reference/autocomplete/' . $type . '/' . $this->fieldName . '/node/article/NULL');
$request->query
->set('q', $input);
$entity_reference_controller = EntityReferenceController::create($this->container);
$result = $entity_reference_controller
->handleAutocomplete($request, $type, $this->fieldName, $this->entityType, $this->bundle, 'NULL')
->getContent();
return drupal_json_decode($result);
}