Commit 04698589 authored by webchick's avatar webchick

Issue #2236245 by znerol: Use request stack in system manager.

parent b5ac7434
......@@ -11,7 +11,7 @@
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* System Manager Service.
......@@ -39,6 +39,13 @@ class SystemManager {
*/
protected $menuLinkStorage;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* A static cache of menu items.
*
......@@ -61,13 +68,6 @@ class SystemManager {
*/
const REQUIREMENT_ERROR = 2;
/**
* The request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* Constructs a SystemManager object.
*
......@@ -77,21 +77,14 @@ class SystemManager {
* The database connection.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Symfony\Component\HttpFoundation\RequestStack
* The request stack.
*/
public function __construct(ModuleHandlerInterface $module_handler, Connection $database, EntityManagerInterface $entity_manager) {
public function __construct(ModuleHandlerInterface $module_handler, Connection $database, EntityManagerInterface $entity_manager, RequestStack $request_stack) {
$this->moduleHandler = $module_handler;
$this->database = $database;
$this->menuLinkStorage = $entity_manager->getStorage('menu_link');
}
/**
* Sets the current request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*/
public function setRequest(Request $request) {
$this->request = $request;
$this->requestStack = $request_stack;
}
/**
......@@ -178,7 +171,8 @@ public function getMaxSeverity(&$requirements) {
* A render array suitable for drupal_render.
*/
public function getBlockContents() {
$route_name = $this->request->attributes->get(RouteObjectInterface::ROUTE_NAME);
$request = $this->requestStack->getCurrentRequest();
$route_name = $request->attributes->get(RouteObjectInterface::ROUTE_NAME);
$items = $this->menuLinkStorage->loadByProperties(array('route_name' => $route_name));
$item = reset($items);
if ($content = $this->getAdminBlock($item)) {
......
......@@ -5,9 +5,7 @@ services:
- { name: access_check, applies_to: _access_system_cron }
system.manager:
class: Drupal\system\SystemManager
arguments: ['@module_handler', '@database', '@entity.manager']
calls:
- [setRequest, ['@?request=']]
arguments: ['@module_handler', '@database', '@entity.manager', '@request_stack']
system.breadcrumb.default:
class: Drupal\system\PathBasedBreadcrumbBuilder
arguments: ['@request', '@access_manager', '@router', '@path_processor_manager', '@config.factory', '@title_resolver', '@current_user']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment