public static function EntityAutocomplete::extractEntityIdFromAutocompleteInput in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php \Drupal\Core\Entity\Element\EntityAutocomplete::extractEntityIdFromAutocompleteInput()
- 10 core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php \Drupal\Core\Entity\Element\EntityAutocomplete::extractEntityIdFromAutocompleteInput()
Extracts the entity ID from the autocompletion result.
Parameters
string $input: The input coming from the autocompletion result.
Return value
mixed|null An entity ID or NULL if the input does not contain one.
2 calls to EntityAutocomplete::extractEntityIdFromAutocompleteInput()
- EntityAutocomplete::validateEntityAutocomplete in core/
lib/ Drupal/ Core/ Entity/ Element/ EntityAutocomplete.php - Form element validation handler for entity_autocomplete elements.
- LinkWidget::getUserEnteredStringAsUri in core/
modules/ link/ src/ Plugin/ Field/ FieldWidget/ LinkWidget.php - Gets the user-entered string as a URI.
File
- core/
lib/ Drupal/ Core/ Entity/ Element/ EntityAutocomplete.php, line 399
Class
- EntityAutocomplete
- Provides an entity autocomplete form element.
Namespace
Drupal\Core\Entity\ElementCode
public static function extractEntityIdFromAutocompleteInput($input) {
$match = NULL;
// Take "label (entity id)', match the ID from inside the parentheses.
// @todo Add support for entities containing parentheses in their ID.
// @see https://www.drupal.org/node/2520416
if (preg_match("/.+\\s\\(([^\\)]+)\\)/", $input, $matches)) {
$match = $matches[1];
}
return $match;
}