comparison core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
54 return parent::getReferenceableEntities($match, $match_operator, $limit); 54 return parent::getReferenceableEntities($match, $match_operator, $limit);
55 } 55 }
56 56
57 $options = []; 57 $options = [];
58 58
59 $bundles = $this->entityManager->getBundleInfo('taxonomy_term'); 59 $bundles = $this->entityTypeBundleInfo->getBundleInfo('taxonomy_term');
60 $bundle_names = $this->getConfiguration()['target_bundles'] ?: array_keys($bundles); 60 $bundle_names = $this->getConfiguration()['target_bundles'] ?: array_keys($bundles);
61 61
62 $has_admin_access = $this->currentUser->hasPermission('administer taxonomy'); 62 $has_admin_access = $this->currentUser->hasPermission('administer taxonomy');
63 $unpublished_terms = []; 63 $unpublished_terms = [];
64 foreach ($bundle_names as $bundle) { 64 foreach ($bundle_names as $bundle) {
65 if ($vocabulary = Vocabulary::load($bundle)) { 65 if ($vocabulary = Vocabulary::load($bundle)) {
66 /** @var \Drupal\taxonomy\TermInterface[] $terms */ 66 /** @var \Drupal\taxonomy\TermInterface[] $terms */
67 if ($terms = $this->entityManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) { 67 if ($terms = $this->entityTypeManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) {
68 foreach ($terms as $term) { 68 foreach ($terms as $term) {
69 if (!$has_admin_access && (!$term->isPublished() || in_array($term->parent->target_id, $unpublished_terms))) { 69 if (!$has_admin_access && (!$term->isPublished() || in_array($term->parent->target_id, $unpublished_terms))) {
70 $unpublished_terms[] = $term->id(); 70 $unpublished_terms[] = $term->id();
71 continue; 71 continue;
72 } 72 }
73 $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityManager->getTranslationFromContext($term)->label()); 73 $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityRepository->getTranslationFromContext($term)->label());
74 } 74 }
75 } 75 }
76 } 76 }
77 } 77 }
78 78