protected function EntityMatcher::findEntityIdByUrl in Linkit 8.5
Finds entity id from the given input.
Parameters
string $user_input: The string to url parse.
Return value
array An array with an entity id if the input can be parsed as an internal url and a match is found, otherwise an empty array.
1 call to EntityMatcher::findEntityIdByUrl()
- EntityMatcher::execute in src/
Plugin/ Linkit/ Matcher/ EntityMatcher.php - Executes the matcher.
File
- src/
Plugin/ Linkit/ Matcher/ EntityMatcher.php, line 518
Class
- EntityMatcher
- Provides default linkit matchers for all entity types.
Namespace
Drupal\linkit\Plugin\Linkit\MatcherCode
protected function findEntityIdByUrl($user_input) {
$result = [];
try {
$params = Url::fromUserInput($user_input)
->getRouteParameters();
if (key($params) === $this->targetType) {
$result = [
end($params),
];
}
} catch (Exception $e) {
// Do nothing.
}
return $result;
}