Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url option to the core:route command #5172

Merged
merged 4 commits into from Jul 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Drupal/Commands/core/DrupalCommands.php
Expand Up @@ -145,15 +145,22 @@ public function requirements($options = ['format' => 'table', 'severity' => -1,
* View details about the <info>update.status</info> route.
* @usage drush route --path=/user/1
* View details about the <info>entity.user.canonical</info> route.
* @usage drush route --url=https://example.com/node/1
* View details about the <info>entity.node.canonical</info> route.
* @option name A route name.
* @option path An internal path.
* @option path An internal path or URL.
* @version 10.5
*/
public function route($options = ['name' => self::REQ, 'path' => self::REQ, 'format' => 'yaml'])
{
$route = $items = null;
$provider = $this->getRouteProvider();
if ($path = $options['path']) {
if (filter_var($path, FILTER_VALIDATE_URL)) {
$path = parse_url($path, PHP_URL_PATH);
// Strip base path.
$path = '/' . substr_replace($path, '', 0, strlen(base_path()));
}
$name = Url::fromUserInput($path)->getRouteName();
$route = $provider->getRouteByName($name);
} elseif ($name = $options['name']) {
Expand Down