Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
private_message
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
private_message
Commits
aa6c8f13
Commit
aa6c8f13
authored
2 years ago
by
Taras Kravchuk
Committed by
Artem Sylchuk
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3337189
by _tarik_, artem_sylchuk: Inject keyValue storage properly in the AjaxController
parent
f738a230
No related branches found
No related tags found
1 merge request
!49
Issue #3337189: Inject keyValue storage properly in the AjaxController
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Controller/AjaxController.php
+14
-3
14 additions, 3 deletions
src/Controller/AjaxController.php
with
14 additions
and
3 deletions
src/Controller/AjaxController.php
+
14
−
3
View file @
aa6c8f13
...
@@ -7,6 +7,7 @@ use Drupal\Core\Ajax\AjaxResponse;
...
@@ -7,6 +7,7 @@ use Drupal\Core\Ajax\AjaxResponse;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\KeyValueStore\KeyValueStoreInterface
;
use
Drupal\Core\Render\RendererInterface
;
use
Drupal\Core\Render\RendererInterface
;
use
Drupal\Core\Session\AccountProxyInterface
;
use
Drupal\Core\Session\AccountProxyInterface
;
use
Drupal\Core\Site\Settings
;
use
Drupal\Core\Site\Settings
;
...
@@ -80,6 +81,13 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
...
@@ -80,6 +81,13 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
*/
*/
protected
$privateMessageService
;
protected
$privateMessageService
;
/**
* The key/value storage collection.
*
* @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
*/
protected
$keyValueStore
;
/**
/**
* Constructs a AjaxController object.
* Constructs a AjaxController object.
*
*
...
@@ -102,7 +110,8 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
...
@@ -102,7 +110,8 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
EntityTypeManagerInterface
$entityTypeManager
,
EntityTypeManagerInterface
$entityTypeManager
,
ConfigFactoryInterface
$configFactory
,
ConfigFactoryInterface
$configFactory
,
AccountProxyInterface
$currentUser
,
AccountProxyInterface
$currentUser
,
PrivateMessageServiceInterface
$privateMessageService
PrivateMessageServiceInterface
$privateMessageService
,
KeyValueStoreInterface
$keyValueStore
)
{
)
{
$this
->
renderer
=
$renderer
;
$this
->
renderer
=
$renderer
;
$this
->
requestStack
=
$requestStack
;
$this
->
requestStack
=
$requestStack
;
...
@@ -111,6 +120,7 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
...
@@ -111,6 +120,7 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
$this
->
configFactory
=
$configFactory
;
$this
->
configFactory
=
$configFactory
;
$this
->
currentUser
=
$currentUser
;
$this
->
currentUser
=
$currentUser
;
$this
->
privateMessageService
=
$privateMessageService
;
$this
->
privateMessageService
=
$privateMessageService
;
$this
->
keyValueStore
=
$keyValueStore
;
}
}
/**
/**
...
@@ -123,7 +133,8 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
...
@@ -123,7 +133,8 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'config.factory'
),
$container
->
get
(
'config.factory'
),
$container
->
get
(
'current_user'
),
$container
->
get
(
'current_user'
),
$container
->
get
(
'private_message.service'
)
$container
->
get
(
'private_message.service'
),
$container
->
get
(
'keyvalue'
)
->
get
(
'entity_autocomplete'
)
);
);
}
}
...
@@ -184,7 +195,7 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
...
@@ -184,7 +195,7 @@ class AjaxController extends ControllerBase implements AjaxControllerInterface {
// Selection settings are passed in as a hashed key of a serialized array
// Selection settings are passed in as a hashed key of a serialized array
// stored in the key/value store.
// stored in the key/value store.
$selection_settings
=
\Drupal
::
keyValue
(
'entity_autocomplete'
)
->
get
(
$selection_settings_key
,
FALSE
);
$selection_settings
=
$this
->
keyValueStore
->
get
(
$selection_settings_key
,
FALSE
);
if
(
$selection_settings
!==
FALSE
)
{
if
(
$selection_settings
!==
FALSE
)
{
$selection_settings_hash
=
Crypt
::
hmacBase64
(
serialize
(
$selection_settings
)
.
$target_type
.
$selection_handler
,
Settings
::
getHashSalt
());
$selection_settings_hash
=
Crypt
::
hmacBase64
(
serialize
(
$selection_settings
)
.
$target_type
.
$selection_handler
,
Settings
::
getHashSalt
());
if
(
!
hash_equals
(
$selection_settings_hash
,
$selection_settings_key
))
{
if
(
!
hash_equals
(
$selection_settings_hash
,
$selection_settings_key
))
{
...
...
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