public static function EntityAutocomplete::extractEntityIdFromAutocompleteInput in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 322 - Contains \Drupal\Core\Entity\Element\EntityAutocomplete.
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 parenthesis when it's a
// number.
if (preg_match("/.+\\((\\d+)\\)/", $input, $matches)) {
$match = $matches[1];
}
elseif (preg_match("/.+\\(([\\w.]+)\\)/", $input, $matches)) {
$match = $matches[1];
}
return $match;
}