Skip to content
Snippets Groups Projects
Commit b2771c9f authored by artis.bajars's avatar artis.bajars
Browse files

Load term translations from context

parent ca33ec27
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ namespace Drupal\hierarchy_manager\Controller;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\taxonomy\Entity\Term;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -37,13 +38,21 @@ class HmTaxonomyController extends ControllerBase {
*/
protected $hmPluginTypeManager;
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityRepository;
/**
* {@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->entityTypeManager = $entity_type_manager;
$this->entityRepository = $entity_repository;
$this->storageController = $entity_type_manager->getStorage('taxonomy_term');
$this->hmPluginTypeManager = $plugin_type_manager;
}
......@@ -55,6 +64,7 @@ class HmTaxonomyController extends ControllerBase {
return new static(
$container->get('csrf_token'),
$container->get('entity_type.manager'),
$container->get('entity.repository'),
$container->get('hm.plugin_type_manager')
);
}
......@@ -95,6 +105,7 @@ class HmTaxonomyController extends ControllerBase {
foreach ($tree as $term) {
if ($term instanceof Term) {
$term = $this->entityRepository->getTranslationFromContext($term);
// User can only access the terms that they can update.
if ($access_control_handler->access($term, 'update')) {
if (empty($destination)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment