public static function EntityAutocomplete::extractEntityIdFromAutocompleteInput
public static EntityAutocomplete::extractEntityIdFromAutocompleteInput($input)
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.
File
- core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php, line 348
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("/.+\s\((\d+)\)/", $input, $matches)) { $match = $matches[1]; } // Match the ID when it's a string (e.g. for config entity types). elseif (preg_match("/.+\s\(([\w.]+)\)/", $input, $matches)) { $match = $matches[1]; } return $match; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Element!EntityAutocomplete.php/function/EntityAutocomplete::extractEntityIdFromAutocompleteInput/8.1.x