Account created on 28 November 2012, about 12 years ago
#

Merge Requests

Recent comments

🇷🇺Russia k.prozorov

I have prepared a script that adds this feature.

🇷🇺Russia k.prozorov

I have prepared a new merge request for the 2.0.x version of the module.
In action NewEntity made the language selection as select field (drop-down)
Also, in 3 places (Translate, NewEntity, EntityLoader), I added the option to select the "Defined by token" option, when selected, the language code will be obtained from the token eca_langcode.
I tested all changes on a clean install of drupal 10.2.3 and they work as expected.

🇷🇺Russia k.prozorov

k.prozorov changed the visibility of the branch 3421088-allow-tokens-in to hidden.

🇷🇺Russia k.prozorov

At the moment, the langcode config is textarea in buildConfigurationForm (modules/content/src/Plugin/Action/NewEntity.php)

$form['langcode'] = [
  '#type' => 'textfield',
  '#title' => $this->t('Language code'),
  '#default_value' => $this->configuration['langcode'],
  '#description' => $this->t('The language code of the new entity.'),
  '#weight' => -40,
];

And it will be convenient if you can use tokens there.
I have prepared a merge request based on my patch.

Best regards.

🇷🇺Russia k.prozorov

I have prepared a patch that adds the ability to pass subscription IDs to the method
Usage example:

$subscriptions = [1, 2, 3]; // there can be any logic for obtaining subscription IDs.
\Drupal::service('web_push.manager')->sendNotification(
  'Notification Title',
  'Notification Body',
  'noticiation-redirect-url',
  'notification-icon-url',
  \Drupal\web_push\Service\WebPushSender::URGENCY_HIGH
  '',
  $subscriptions
);
🇷🇺Russia k.prozorov

, since drupal 9 is still popular, we need a version for drupal 9 as well

🇷🇺Russia k.prozorov

It's going to be awesome!

I made a temporary solution.

In the file, I added a route like this:

entity.eck.translations_pack_add:
  path: '/admin/content/{eck_entity_type}/add/{eck_entity_bundle}/pack'
  defaults:
    _title: 'Packed add form'
    _controller: '\Drupal\translations_pack\Controller\TranslationsPackController::build_add_eck'
  requirements:
    _permission: 'create MY_ECK_ENTITY_TYPE entities'
  options:
    _admin_route: true
    parameters:
      eck_entity_type:
        type: entity:eck_entity_type
        with_config_overrides: TRUE

I have specified routing permissions for my ECK entity type.

And added a method by analogy as it is done for node in the file :

public function build_add_eck($eck_entity_type, $eck_entity_bundle, Request $request, RouteMatchInterface $route_match) {
    /* @var \Drupal\eck\Entity\EckEntityType $eck_entity_type */
    $values = ['type' => $eck_entity_bundle];
    $entity = $this->entityTypeManager()->getStorage($eck_entity_type->id())->create($values);
    $language = $this->languageManager()
      ->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
    $entity->set('langcode', $language->getId());
    $route_match = new MockRouteMatch($entity);
    return $this->build_pack($eck_entity_type->id(), $request, $route_match);
  }

In this variant, I have the ability to create ECK entities immediately with translation tabs (It's probably better to specify this as a parameter from route).

I also noticed an error in the browser console (it pointed to ajax.js) and I fixed this error by adding - core/drupal.ajax to the section in the file.

🇷🇺Russia k.prozorov

Can you tell me when approximately this can be done?
Best regards.

🇷🇺Russia k.prozorov

Thanks for the answer!
The module works perfectly with nodes.
I want to use this module in combination with the module Entity Construction Kit (ECK)
Yes I have enabled the "Translations pack" checkbox on the admin/config/regional/content-language path for my ECK entity.
For the ECK entity editing form (for example by url /{eck_entity_type}/{entity_id}/edit) I can add /pack to the url (the url is /{eck_entity_type}/{entity_id}/edit/pack), then I will see tabs for switching languages.
But this functionality is not available for the ECK entity creation form (for example, at the url /admin/content/{eck_entity_type}/add/{eck_entity_bundle})
In the file, there is a route only for nodes.

Tell me how can I use the module to create ECK entities with the ability to switch language tabs?

🇷🇺Russia k.prozorov

I think you just need to fix the module description where it says how to add the library in the extra block, as shown below:

"drupal-libraries": {
  "jquery-datetimepicker": "https://github.com/xdan/datetimepicker/archive/2.5.20.zip"
},

In this case, the library will be downloaded to the correct directory.

🇷🇺Russia k.prozorov

Hello.
I'm running into the same problem.
To reproduce the problem, you need to follow the steps:
- install pure drupal 9.5.11 (drupal/recommended-project)
- install and enable the entity_translation_unified_form module (version 2.0.0)
- add two additional languages (/admin/config/regional/language), so that there would be 3 languages
- set up translation for the type of material, for example, for articles (/admin/config/regional/content-language) as in the screenshot
- try to upload a picture

In this case, there is an error in the console and in watchdog:

Error: Call to a member function getName() on null in Drupal\content_translation\ContentTranslationHandler->entityFormAlter() (line 353 of /app/web/core/modules/content_translation/src/ContentTranslationHandler.php)

#0 /app/web/core/modules/node/src/NodeTranslationHandler.php(18): Drupal\content_translation\ContentTranslationHandler->entityFormAlter(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\node\Entity\Node))
#1 /app/web/core/modules/content_translation/content_translation.module(399): Drupal\node\NodeTranslationHandler->entityFormAlter(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\node\Entity\Node))
#2 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): content_translation_form_alter(Array, Object(Drupal\Core\Form\FormState), 'node_article_fo...')
#3 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(840): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'node_article_fo...')
#4 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(434): Drupal\Core\Form\FormBuilder->prepareForm('node_article_fo...', Array, Object(Drupal\Core\Form\FormState))
#5 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm('node_article_fo...', Object(Drupal\Core\Form\FormState), Array)
#6 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('node_article_fo...', Array, Object(Drupal\Core\Form\FormState))
#7 /app/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeForm), Object(Drupal\Core\Form\FormState))
#8 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#9 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#10 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#12 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#13 /app/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#15 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#24 {main}

I found a temporary solution that helped, in the file core/modules/content_translation/src/ContentTranslationHandler.php commented out the code (which adds a language switch field):

if ($has_translations && $new_translation) {
  $source_langcode = $metadata->getSource();
  $form['source_langcode'] = [
    '#type' => 'details',
    '#title' => t('Source language: @language', ['@language' => $languages[$source_langcode]->getName()]),
    '#tree' => TRUE,
    '#weight' => -100,
    '#multilingual' => TRUE,
    'source' => [
      '#title' => t('Select source language'),
      '#title_display' => 'invisible',
      '#type' => 'select',
      '#default_value' => $source_langcode,
      '#options' => [],
    ],
    'submit' => [
      '#type' => 'submit',
      '#value' => t('Change'),
      '#submit' => [[$this, 'entityFormSourceChange']],
    ],
  ];
  foreach ($this->languageManager->getLanguages() as $language) {
    if (isset($translations[$language->getId()])) {
      $form['source_langcode']['source']['#options'][$language->getId()] = $language->getName();
    }
  }
}

In my case, the problem was solved, since I don't need a language switch, because the default language is set in the settings (/admin/config/regional/content-language), and I see all the translated fields at once, but this is not a good solution.

🇷🇺Russia k.prozorov

I created a patch that in the addMember method calls the addHistoryRecord method for an existing thread.
I hope that this will be useful to someone.

🇷🇺Russia k.prozorov

I have prepared a patch that fixes this problem.
I removed the function call in the method and replaced it with the $response[] = $message; construct.
I hope this helps.

🇷🇺Russia k.prozorov

Fixed drupal code style in previous patch file

🇷🇺Russia k.prozorov

Here is a patch that adds the "Turn off random ad selection" checkbox to the /admin/ad page, when the checkbox is enabled, the displayed ads are saved to the session, for the next display it is selected from those that have not yet been shown, if all ads have been shown, then everything starts over.

Production build 0.71.5 2024