- Issue created by @hartsak
- Assigned to rohan_singh
- 🇷🇺Russia walkingdexter
Hello, @hartsak!
The message feature was removed for a reason - it's difficult to cover all possible use cases. In my opinion, this feature should be at the custom code level. I'm planning to add an event or hook before the redirect in 2.x, so that any desired behavior can be implemented. Until it's done, I recommend to use 1.x if it suits your requirements. The 2.x version has some nice new features (but they are not finalized yet) and if you need them you can implement a patch that returns the message feature.
- 🇫🇮Finland hartsak
Thank you for the quick reply @WalkingDexter !
I'm probably going to re-think if I really need the message feature in the future. In the meantime, I will continue using the 1.x version and see if I'm able to patch it with the D10 patch from here:
https://www.drupal.org/project/content_translation_redirect/issues/3369274 📌 Automated Drupal 10 compatibility fixes Closed: won't fixGreat work with the module so far and have a nice weekend!
- Status changed to Needs review
over 1 year ago 12:19pm 16 October 2023 - 🇮🇳India rohan_singh India
Hi @WalkingDexter, I have added a patch to add the message after the module redirects to the requested page. Do let me know if I can help in any other way.
-
WalkingDexter →
authored 420668e1 on 2.x
Issue #3393497 by hartsak, WalkingDexter: Possibility to set a message...
-
WalkingDexter →
authored 420668e1 on 2.x
- 🇷🇺Russia walkingdexter
Example:
custom.services.yml
services: custom.event_subscriber: class: Drupal\custom\EventSubscriber\CustomEventSubscriber arguments: ['@messenger'] tags: - { name: event_subscriber }
src/EventSubscriber/CustomEventSubscriber.php
<?php namespace Drupal\custom\EventSubscriber; use Drupal\content_translation_redirect\ContentTranslationRedirectEvents; use Drupal\content_translation_redirect\Event\ContentTranslationRedirectEvent; use Drupal\Core\Messenger\MessengerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Custom event subscriber. */ class CustomEventSubscriber implements EventSubscriberInterface { /** * The messenger. * * @var \Drupal\Core\Messenger\MessengerInterface */ protected $messenger; /** * CustomEventSubscriber constructor. * * @param \Drupal\Core\Messenger\MessengerInterface $messenger * The messenger. */ public function __construct(MessengerInterface $messenger) { $this->messenger = $messenger; } /** * Handles the content translation redirect. * * @param \Drupal\content_translation_redirect\Event\ContentTranslationRedirectEvent $event * The event to process. */ public function onRedirect(ContentTranslationRedirectEvent $event): void { $this->messenger->addStatus('Your message is here'); } /** * {@inheritdoc} */ public static function getSubscribedEvents(): array { $events[ContentTranslationRedirectEvents::REDIRECT][] = ['onRedirect']; return $events; } }
- Issue was unassigned.
- Status changed to Fixed
about 1 year ago 4:30pm 28 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.