Give the gift of Drupal. All merchandise is 50% off through 2016.
As of Drupal 8, the core request handling logic has been replaced with Symfony2's HttpKernel, HttpFoundation, and related libraries. This primarily applies to module developers, but has far reaching implications for the entire system.
Of particular note:
The PHP superglobals for $_GET, $_POST, and $_SERVER are deprecated and should not be used, ever. Instead, an instance of the Symfony HttpFoundation\Request class is created during bootstrap and stored in the request() function. Module developers should access that object for any and all information about the HTTP request. (Note: The request function will be removed once that object is accessible via the Dependency Injection Container.)
$page = isset($_GET['page']) ? $_GET['page'] : 0;
$page = Drupal::service('request')->query->get('page', 0);
See the Request object documentation for more details.
menu_execute_active_handler() has been removed in favor of HttpKernel. In cases where modules need to simulate a new request, they should now create a new request object and issue a subrequest call against the kernel object.
Actual example from comment_permalink():
// Set $_GET['q'] and $_GET['page'] ourselves so that the node callback // behaves as it would when visiting the page directly. $_GET['q'] = 'node/' . $node->nid; $_GET['page'] = $page; // Return the node view. return menu_execute_active_handler('node/' . $node->nid, FALSE);
$request = Drupal::service('request'); $subrequest = Request::create('/node/' . $node->nid, 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all()); $subrequest->query->set('page', $page); // @todo: Convert the pager to use the request object. $_GET['page'] = $page; return Drupal::service('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);
Additional implications are noted in separate change notices.
As in Drupal 7, you should not use
$_GET['q'], you should use
current_path(). Also see [#1659562].