Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
votingapi_reaction
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
votingapi_reaction
Commits
5a7585cc
Commit
5a7585cc
authored
10 months ago
by
Eelke Blok
Browse files
Options
Downloads
Patches
Plain Diff
Replace directly injected storage
parent
1ea734a3
No related branches found
Branches containing commit
Tags
1.0.3-beta2
Tags containing commit
1 merge request
!4
Replace directly injected storage
Pipeline
#163408
failed
9 months ago
Stage: build
Stage: test
Stage: dast
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/VotingApiReactionManager.php
+11
-24
11 additions, 24 deletions
src/VotingApiReactionManager.php
with
11 additions
and
24 deletions
src/VotingApiReactionManager.php
+
11
−
24
View file @
5a7585cc
...
...
@@ -21,25 +21,11 @@ use Drupal\Core\File\FileUrlGeneratorInterface;
class
VotingApiReactionManager
implements
ContainerInjectionInterface
{
/**
*
Vote stor
age.
*
The entity type man
age
r
.
*
* @var \Drupal\
votingapi\VoteStorag
e
* @var \Drupal\
Core\Entity\EntityTypeManagerInterfac
e
*/
protected
$voteStorage
;
/**
* Vote type storage.
*
* @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage
*/
protected
$voteTypeStorage
;
/**
* File storage.
*
* @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage
*/
protected
$fileStorage
;
protected
EntityTypeManagerInterface
$entityTypeManager
;
/**
* Current user service.
...
...
@@ -110,9 +96,7 @@ class VotingApiReactionManager implements ContainerInjectionInterface {
ExtensionPathResolver
$path_resolver
,
FileUrlGeneratorInterface
$file_url_generator
)
{
$this
->
voteStorage
=
$entityTypeManager
->
getStorage
(
'vote'
);
$this
->
voteTypeStorage
=
$entityTypeManager
->
getStorage
(
'vote_type'
);
$this
->
fileStorage
=
$entityTypeManager
->
getStorage
(
'file'
);
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
currentUser
=
$currentUser
;
$this
->
votingApiResults
=
$votingApiResults
;
$this
->
renderer
=
$renderer
;
...
...
@@ -148,7 +132,8 @@ class VotingApiReactionManager implements ContainerInjectionInterface {
* Last reaction for current user.
*/
public
function
lastReaction
(
Vote
$entity
,
array
$settings
)
{
$query
=
$this
->
voteStorage
->
getQuery
()
$voteStorage
=
$this
->
entityTypeManager
->
getStorage
(
'vote'
);
$query
=
$voteStorage
->
getQuery
()
->
accessCheck
()
->
condition
(
'entity_id'
,
$entity
->
getVotedEntityId
())
->
condition
(
'entity_type'
,
$entity
->
getVotedEntityType
())
...
...
@@ -187,7 +172,7 @@ class VotingApiReactionManager implements ContainerInjectionInterface {
$ids
=
$query
->
execute
();
return
$
this
->
voteStorage
->
load
(
intval
(
array_pop
(
$ids
)));
return
$voteStorage
->
load
(
intval
(
array_pop
(
$ids
)));
}
/**
...
...
@@ -230,7 +215,8 @@ class VotingApiReactionManager implements ContainerInjectionInterface {
* Active reaction vote types.
*/
public
function
allReactions
()
{
return
array_filter
(
$this
->
voteTypeStorage
->
loadMultiple
(),
function
(
VoteType
$entity
)
{
$voteTypeStorage
=
$this
->
entityTypeManager
->
getStorage
(
'vote_type'
);
return
array_filter
(
$voteTypeStorage
->
loadMultiple
(),
function
(
VoteType
$entity
)
{
return
$entity
->
getThirdPartySetting
(
'votingapi_reaction'
,
'reaction'
);
});
}
...
...
@@ -355,6 +341,7 @@ class VotingApiReactionManager implements ContainerInjectionInterface {
* Reaction icon url.
*/
public
function
getIcon
(
VoteType
$entity
,
&
$default
=
TRUE
)
{
$fileStorage
=
$this
->
entityTypeManager
->
getStorage
(
'file'
);
$path
=
implode
(
'/'
,
[
$this
->
pathResolver
->
getPath
(
'module'
,
'votingapi_reaction'
),
'svg'
,
...
...
@@ -366,7 +353,7 @@ class VotingApiReactionManager implements ContainerInjectionInterface {
$url
=
$path
.
'reaction_noicon.svg'
;
// User defined icon.
$icon
=
$entity
->
getThirdPartySetting
(
'votingapi_reaction'
,
'icon'
,
''
);
if
(
$file
=
$this
->
file
Storage
->
load
(
$icon
))
{
if
(
$fileStorage
->
load
(
$icon
))
{
/** @var \Drupal\file\FileInterface $file */
$url
=
$file
->
getFileUri
();
$default
=
FALSE
;
...
...
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