Retrieve GET request from Block Plugin I'd like a block plugin to display content dependent on a GET request.
Inside my block plugin I have

class BlogPage extends BlockBase {
    public function build() {
        $query = \Drupal::entityQuery('node')
            -&gt;condition('type', 'blog_post')
            -&gt;sort('created', 'DESC')
            -&gt;range(0, $range);
        return $query;
    }
}


I'd like to make $range retrieve info from a GET request. For example I'd like
127.0.0.1/page?range=5 to make $range = 5.
I've tried

$range = Request::get('range');


But that does not work. Is there a way to return the values in a GET request from inside the block plugin?
You need to get the current request object first:

$request = \Drupal::request();
$range = $request-&gt;get('range');


Or 

$range = \Drupal::request()-&gt;get('range');