Get args from URL in Drupal 8

Submitted by editor on Mon, 12/14/2015 - 16:00
Question

How to get arguments (parameters) from url in Drupal 8 ?
Like $path_args = arg(); on Drupal 7.

Example: 

    $current_url = Url::fromRoute('<current>');
    $path = $current_url->toString();
    //OR of you want to get the url without language prefix
    $path = $current_url->getInternalPath();

    $path_args = explode('/', $path);

Tags

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.