111 lines
4.9 KiB
Plaintext
111 lines
4.9 KiB
Plaintext
diff --git a/composer.json b/composer.json
|
|
index cb36df5..42be090 100755
|
|
--- a/composer.json
|
|
+++ b/composer.json
|
|
@@ -22,8 +22,5 @@
|
|
"support": {
|
|
"issues": "https://drupal.org/project/issues/taxonomy_machine_name",
|
|
"source": "https://git.drupalcode.org/project/taxonomy_machine_name"
|
|
- },
|
|
- "require": {
|
|
- "drupal/core": "^8 || ^9"
|
|
}
|
|
}
|
|
diff --git a/src/Plugin/views/filter/TaxonomyIndexMachineName.php b/src/Plugin/views/filter/TaxonomyIndexMachineName.php
|
|
index d1caffd..4c1e885 100644
|
|
--- a/src/Plugin/views/filter/TaxonomyIndexMachineName.php
|
|
+++ b/src/Plugin/views/filter/TaxonomyIndexMachineName.php
|
|
@@ -214,7 +214,7 @@ class TaxonomyIndexMachineName extends ManyToOne {
|
|
if ($this->options['limit']) {
|
|
$query->condition('vid', $vocabulary->id());
|
|
}
|
|
- $terms = Term::loadMultiple($query->execute());
|
|
+ $terms = Term::loadMultiple($query->accessCheck(TRUE)->execute());
|
|
foreach ($terms as $term) {
|
|
$options[$term->get('machine_name')->get(0)->value] = \Drupal::service('entity.repository')->getTranslationFromContext($term)->label();
|
|
}
|
|
diff --git a/taxonomy_machine_name.deploy.php b/taxonomy_machine_name.deploy.php
|
|
index d19d3de..1779688 100644
|
|
--- a/taxonomy_machine_name.deploy.php
|
|
+++ b/taxonomy_machine_name.deploy.php
|
|
@@ -27,7 +27,7 @@ function taxonomy_machine_name_deploy_update_existing_terms(&$sandbox) {
|
|
|
|
// Nothing to do?
|
|
if (!$sandbox['total']) {
|
|
- //$sandbox['message'] = t('No terms updated');
|
|
+ // $sandbox['message'] = t('No terms updated');
|
|
$term_storage->resetCache();
|
|
$sandbox['#finished'] = 1;
|
|
return;
|
|
diff --git a/taxonomy_machine_name.info.yml b/taxonomy_machine_name.info.yml
|
|
index d5e016a..78499d0 100644
|
|
--- a/taxonomy_machine_name.info.yml
|
|
+++ b/taxonomy_machine_name.info.yml
|
|
@@ -2,8 +2,7 @@ name: Taxonomy Machine Name
|
|
description: Provides a new property to store machine name for taxonomy terms.
|
|
type: module
|
|
package: Other
|
|
-core: 8.x
|
|
-core_version_requirement: ^8 || ^9
|
|
+core_version_requirement: ^8 || ^9 || ^10
|
|
|
|
dependencies:
|
|
- drupal:taxonomy
|
|
diff --git a/taxonomy_machine_name.install b/taxonomy_machine_name.install
|
|
index 22e9562..0991720 100644
|
|
--- a/taxonomy_machine_name.install
|
|
+++ b/taxonomy_machine_name.install
|
|
@@ -14,7 +14,7 @@ use Drupal\taxonomy\Entity\Term;
|
|
function taxonomy_machine_name_install() {
|
|
batch_set(
|
|
[
|
|
- 'file' => drupal_get_path('module', 'taxonomy_machine_name') . '/taxonomy_machine_name.install',
|
|
+ 'file' => \Drupal::service('extension.list.module')->getPath('taxonomy_machine_name') . '/taxonomy_machine_name.install',
|
|
'title' => t('Generating missing taxonomy term machine names'),
|
|
'init_message' => t('Starting taxonomy term machine names update'),
|
|
'error_message' => t('Error updating taxonomy term machine names'),
|
|
@@ -52,7 +52,7 @@ function taxonomy_machine_name_update_all_terms(&$context) {
|
|
// Size of the batch to process.
|
|
$batch_size = 10;
|
|
|
|
- $tids = \Drupal::entityQuery('taxonomy_term')->notExists('machine_name')->execute();
|
|
+ $tids = \Drupal::entityQuery('taxonomy_term')->notExists('machine_name')->accessCheck(FALSE)->execute();
|
|
|
|
$sandbox['total'] = count($tids);
|
|
$sandbox['tids'] = array_chunk($tids, $batch_size);
|
|
diff --git a/taxonomy_machine_name.module b/taxonomy_machine_name.module
|
|
index 0f5a8f2..a915583 100644
|
|
--- a/taxonomy_machine_name.module
|
|
+++ b/taxonomy_machine_name.module
|
|
@@ -81,13 +81,15 @@ function taxonomy_machine_name_form_taxonomy_term_form_alter(&$form, FormStateIn
|
|
|
|
/** @var \Drupal\taxonomy\Entity\Term $term */
|
|
$term = $form_state->getFormObject()->getEntity();
|
|
- if ($term->hasField('machine_name')) {
|
|
- if (!empty($term_machine_name = $term->get('machine_name')->first())) {
|
|
- $default_value = $term_machine_name->getValue()['value'];
|
|
+ if (
|
|
+ $term->hasField('machine_name')
|
|
+ && !$term->get('machine_name')->isEmpty()
|
|
+ ) {
|
|
+ if (!empty($term->get('machine_name')->first()->getValue()['value'])) {
|
|
+ $default_value = $term->get('machine_name')->first()->getValue()['value'];
|
|
}
|
|
- elseif (!empty($term_machine_name_value = $term->get('name')->first()->getValue())) {
|
|
- $name = $term_machine_name_value['value'];
|
|
- $default_value = taxonomy_machine_name_clean_name($name);
|
|
+ elseif (isset($term->get('name')->first()->getValue()['value'])) {
|
|
+ $default_value = taxonomy_machine_name_clean_name($term->get('name')->first()->getValue()['value']);
|
|
}
|
|
}
|
|
|
|
@@ -264,7 +266,7 @@ function taxonomy_machine_name_uniquify(&$machine_name, Term $term) {
|
|
* The taxonomy term.
|
|
*/
|
|
function taxonomy_machine_name_update_term(TermInterface $term) {
|
|
- if (empty($term->get('machine_name')->first())) {
|
|
+ if (empty($term->get('machine_name')->first()) && !empty($term->get('name')->first())) {
|
|
$name = $term->get('name')->first()->getValue()['value'];
|
|
$term->machine_name = taxonomy_machine_name_clean_name($name);
|
|
$term->save();
|