Account created on 12 September 2014, almost 10 years ago
#

Recent comments

🇭🇺Hungary suchdavid

After exporting configs I could delete the problematic permission from user.role.editor.yml and re-import the config, but this should be done automatically in the hook_ENTITY_TYPE_delete hook.

🇭🇺Hungary suchdavid

Hi, I think the problem is mainly, that a keyvalue is needed to be saved on the backend possibly for security reasons.

$key_value_storage = \Drupal::service('keyvalue')->get('entity_autocomplete');
if (!$key_value_storage->has($selection_settings_key)) {
  $key_value_storage->set($selection_settings_key, $selection_settings);
}

And a the url should be generated this way:

$url = Drupal\core\Url::fromRoute(
  'autocomplete_deluxe.autocomplete',
  $route_parameters,
  ['absolute' => TRUE]
  )->getInternalPath();

With these modifications it worked for me.

🇭🇺Hungary suchdavid

For me the patch wasn't applied correctly on "drupal/pathauto": "1.11.0"
I re-created it for current stable version.

🇭🇺Hungary suchdavid

Continuous updating may be treated with a custom modul, where hook_entity_update realizes the reactivating of job items.

<?php
/**
 * @file
 * Module.
 */

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\tmgmt\Entity\Job;
use Drupal\tmgmt\Entity\JobItem;
use Drupal\tmgmt_transifex\Transifex\TransifexApi;
use Drupal\tmgmt_transifex\Utils\Helpers;

/**
 * Implements hook_entity_update().
 */
function mymodule_transifex_entity_update(EntityInterface $entity) {
  if ($entity instanceof ContentEntityInterface
    && $entity->isTranslatable()
    && !$entity->getEntityType()->get('entity_revision_parent_type_field')) {

    $entity = $entity->getUntranslated();
    $source_langcode = $entity->language()->getId();
    $current_job_items = _mymodule_transifex_load_continuous('content', $entity->getEntityTypeId(), $entity->id(), $source_langcode);

    if ($current_job_items) {
      $job = reset($current_job_items)->getJob();
      $translator = $job->getTranslator();
      $tx = new TransifexApi($translator);

      $translation_manager = \Drupal::service('content_translation.manager');
      $translation = $entity->hasTranslation($job->getTargetLangcode()) ? $entity->getTranslation($job->getTargetLangcode()) : NULL;
      $metadata = isset($translation) ? $translation_manager->getTranslationMetadata($translation) : NULL;
      $metadata->isOutdated();

      foreach ($current_job_items as $job_item) {
        // Reactivate old job if new translation arrives.
        $job_item->resetData();
        $job_item->getData();
        $job_item->active();

        $title = $job_item->label();
        $slug = Helpers::slugForItem($job_item);

        $strings = Helpers::extractStringsFromNode($job_item);
        $payload = Helpers::renderHTMLFromStrings($strings);
        $res = $tx->upsertResource($slug, $title, $job->id(), $payload);

        \Drupal::messenger()->addMessage('Added ' . strval($res->strings_created) . ' strings to resource named: ' . $title, 'status');
        $job_item->active();
      }
    }
  }
}

/**
 * Loads active job entities that have a job item with the identifiers.
 *
 * @param $plugin
 *   The source plugin.
 * @param $item_type
 *   The source item type.
 * @param $item_id
 *   The source item id.
 * @param string $source_language
 *   The source language of the item.
 *
 * @return \Drupal\tmgmt\Entity\JobItem[]
 *   An array of job item entities.
 */
function _mymodule_transifex_load_continuous($plugin, $item_type, $item_id, $source_language) {
  $query = \Drupal::database()->select('tmgmt_job_item', 'tji');
  $query->innerJoin('tmgmt_job', 'tj', 'tj.tjid = tji.tjid');
  $result = $query->condition('tj.source_language', $source_language)
    // Only query for jobs that are currently active.
    ->condition('tj.state',Job::STATE_CONTINUOUS)
    ->condition('tj.translator','transifex')
    ->condition('tji.plugin', $plugin)
    ->condition('tji.item_type', $item_type)
    ->condition('tji.item_id', $item_id)
    ->fields('tji', array('tjiid'))
    ->fields('tj', array('target_language'))
    ->orderBy('tji.changed', 'DESC')
    ->groupBy('tj.target_language')
    ->groupBy('tji.tjiid')
    ->groupBy('tji.changed')
    ->execute();
  if ($items = $result->fetchAllKeyed()) {
    $return = array();
    foreach (JobItem::loadMultiple(array_keys($items)) as $key => $item) {
      $return[$items[$key]] = $item;
    }
    return $return;
  }
  return FALSE;
}
🇭🇺Hungary suchdavid

It seems that using the continuous job integration breaks updating the node edit submit, when "mark translations as outdated" is checked. To prevent this, there is patch for ignoring the outdated field. (But unfortunately this results in not starting a new job for the given translations).
https://www.drupal.org/project/tmgmt/issues/3063378

Production build 0.69.0 2024