Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hierarchy_manager-3343978
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
hierarchy_manager-3343978
Commits
b2771c9f
Commit
b2771c9f
authored
3 years ago
by
artis.bajars
Browse files
Options
Downloads
Patches
Plain Diff
Load term translations from context
parent
ca33ec27
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Controller/HmTaxonomyController.php
+12
-1
12 additions, 1 deletion
src/Controller/HmTaxonomyController.php
with
12 additions
and
1 deletion
src/Controller/HmTaxonomyController.php
+
12
−
1
View file @
b2771c9f
...
@@ -4,6 +4,7 @@ namespace Drupal\hierarchy_manager\Controller;
...
@@ -4,6 +4,7 @@ namespace Drupal\hierarchy_manager\Controller;
use
Drupal\Core\Access\CsrfTokenGenerator
;
use
Drupal\Core\Access\CsrfTokenGenerator
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Entity\EntityRepositoryInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\taxonomy\Entity\Term
;
use
Drupal\taxonomy\Entity\Term
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
@@ -37,13 +38,21 @@ class HmTaxonomyController extends ControllerBase {
...
@@ -37,13 +38,21 @@ class HmTaxonomyController extends ControllerBase {
*/
*/
protected
$hmPluginTypeManager
;
protected
$hmPluginTypeManager
;
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected
$entityRepository
;
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
__construct
(
CsrfTokenGenerator
$csrfToken
,
EntityTypeManagerInterface
$entity_type_manager
,
$plugin_type_manager
)
{
public
function
__construct
(
CsrfTokenGenerator
$csrfToken
,
EntityTypeManagerInterface
$entity_type_manager
,
EntityRepositoryInterface
$entity_repository
,
$plugin_type_manager
)
{
$this
->
csrfToken
=
$csrfToken
;
$this
->
csrfToken
=
$csrfToken
;
$this
->
entityTypeManager
=
$entity_type_manager
;
$this
->
entityTypeManager
=
$entity_type_manager
;
$this
->
entityRepository
=
$entity_repository
;
$this
->
storageController
=
$entity_type_manager
->
getStorage
(
'taxonomy_term'
);
$this
->
storageController
=
$entity_type_manager
->
getStorage
(
'taxonomy_term'
);
$this
->
hmPluginTypeManager
=
$plugin_type_manager
;
$this
->
hmPluginTypeManager
=
$plugin_type_manager
;
}
}
...
@@ -55,6 +64,7 @@ class HmTaxonomyController extends ControllerBase {
...
@@ -55,6 +64,7 @@ class HmTaxonomyController extends ControllerBase {
return
new
static
(
return
new
static
(
$container
->
get
(
'csrf_token'
),
$container
->
get
(
'csrf_token'
),
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity.repository'
),
$container
->
get
(
'hm.plugin_type_manager'
)
$container
->
get
(
'hm.plugin_type_manager'
)
);
);
}
}
...
@@ -95,6 +105,7 @@ class HmTaxonomyController extends ControllerBase {
...
@@ -95,6 +105,7 @@ class HmTaxonomyController extends ControllerBase {
foreach
(
$tree
as
$term
)
{
foreach
(
$tree
as
$term
)
{
if
(
$term
instanceof
Term
)
{
if
(
$term
instanceof
Term
)
{
$term
=
$this
->
entityRepository
->
getTranslationFromContext
(
$term
);
// User can only access the terms that they can update.
// User can only access the terms that they can update.
if
(
$access_control_handler
->
access
(
$term
,
'update'
))
{
if
(
$access_control_handler
->
access
(
$term
,
'update'
))
{
if
(
empty
(
$destination
))
{
if
(
empty
(
$destination
))
{
...
...
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