Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443205
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443205
Commits
27a651a6
Commit
27a651a6
authored
10 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2225539
by znerol: Use request stack in admin context service.
parent
a68f86ed
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/core.services.yml
+1
-2
1 addition, 2 deletions
core/core.services.yml
core/lib/Drupal/Core/Routing/AdminContext.php
+23
-10
23 additions, 10 deletions
core/lib/Drupal/Core/Routing/AdminContext.php
with
24 additions
and
12 deletions
core/core.services.yml
+
1
−
2
View file @
27a651a6
...
...
@@ -287,8 +287,7 @@ services:
-
[
fromRequest
,
[
'
@request'
]]
router.admin_context
:
class
:
Drupal\Core\Routing\AdminContext
calls
:
-
[
setRequest
,
[
'
@?request='
]]
arguments
:
[
'
@request_stack'
]
router.route_provider
:
class
:
Drupal\Core\Routing\RouteProvider
arguments
:
[
'
@database'
,
'
@router.builder'
,
'
@state'
]
...
...
This diff is collapsed.
Click to expand it.
core/lib/Drupal/Core/Routing/AdminContext.php
+
23
−
10
View file @
27a651a6
...
...
@@ -8,7 +8,7 @@
namespace
Drupal\Core\Routing
;
use
Symfony\Cmf\Component\Routing\RouteObjectInterface
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Request
Stack
;
use
Symfony\Component\Routing\Route
;
/**
...
...
@@ -17,20 +17,20 @@
class
AdminContext
{
/**
* The r
oute object.
* The r
equest stack
*
* @var \Symfony\Component\
Routing\Route
* @var \Symfony\Component\
HttpFoundation\RequestStack
*/
protected
$r
oute
;
protected
$r
equestStack
;
/**
*
Sets the request object to us
e.
*
Construct a new admin context helper instanc
e.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request
objec
t.
* @param \Symfony\Component\HttpFoundation\Request
Stack
$request
_stack
* The request
stack used to determine the current reques
t.
*/
public
function
setReques
t
(
Request
$request
)
{
$this
->
r
oute
=
$request
->
attributes
->
get
(
RouteObjectInterface
::
ROUTE_OBJECT
)
;
public
function
__construc
t
(
Request
Stack
$request
_stack
)
{
$this
->
r
equestStack
=
$request_stack
;
}
/**
...
...
@@ -45,7 +45,7 @@ public function setRequest(Request $request) {
*/
public
function
isAdminRoute
(
Route
$route
=
NULL
)
{
if
(
!
$route
)
{
$route
=
$this
->
route
;
$route
=
$this
->
getRouteFromRequest
()
;
if
(
!
$route
)
{
return
FALSE
;
}
...
...
@@ -53,4 +53,17 @@ public function isAdminRoute(Route $route = NULL) {
return
(
bool
)
$route
->
getOption
(
'_admin_route'
);
}
/**
* Extract the route object from the request if one is available.
*
* @return \Symfony\Component\Routing\Route
* The route object extracted from the current request.
*/
protected
function
getRouteFromRequest
()
{
$request
=
$this
->
requestStack
->
getCurrentRequest
();
if
(
$request
)
{
return
$request
->
attributes
->
get
(
RouteObjectInterface
::
ROUTE_OBJECT
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment