- πΊπΈUnited States SocialNicheGuru
And it needs to be updated to Drupal 10
- πΊπΈUnited States SocialNicheGuru
if you disable the module you need to do a cache clear or you might get:
Class "Drupal\scheduler\Plugin\Field\FieldType\SchedulerRepeaterItem" does not exist in ReflectionClass->__construct() (line 26 of drupal10.2.6/html/modules/contrib/date_recur/src/DateRecurCachedHooks.php)
- ππ°Hong Kong richard cheung
Does this patch support content moderation?
- πΊπΈUnited States danflanagan8 St. Louis, US
This would be a great feature, to be sure. I mostly like the implementation in the patch in #28. I'd probably rather have less in the module file and more in a service, but that's no big deal.
The patch didn't work for me though. I had to add a
$node->save();
near the end ofDrupal\scheduler_repeat\EventSubscriber::unpublish()
. I'm using scheduler 2.x. Scheduler itself saves the unpublished entity before dispatching the unpublish event, so we have to save it ourselves if we want our changes to persist.As for #29:
Does this patch support content moderation?
Short answer is no. Long answer is that scheduler always needs the Scheduler content moderation integration β module to work with workflows. Even with that module enabled, the repeater doesn't quite work. The reason is that the
publish_state
andunpublish_state
get reset on publish and unpublish respectively by thescheduler_content_moderation_integration
module which means they cease to be available for thescheduler_repeater
module.So that's a pain. Getting this to play nice with
scheduler_content_moderation_integration
might require a patch over there. - πΊπΈUnited States danflanagan8 St. Louis, US
Here's a patch with with the change I mentioned in #30.
- πΊπΈUnited States SocialNicheGuru
Does anything have to happen to make sure that this new submodule is compatible with ECA, π¬ Support for ECA Active ?
- πΊπΈUnited States danflanagan8 St. Louis, US
D11 compatibility patch attached.
I also wanted to report back on content moderation. I added an event subscriber to my custom codebase.
<?php namespace Drupal\my_module\EventSubscriber; use Drupal\scheduler\Event\SchedulerEvent; use Drupal\scheduler\Event\SchedulerNodeEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Special sauce for scheduler events. */ class MyModuleSchedulerSubscriber implements EventSubscriberInterface { /** * Sets the (un)publish_state values. * * This makes scheduler_repeat compatible with content moderation in * two ways. First, it (re)sets the pubslish_state and unpublish_state * values, which the scheduler_repeat does not do for us. Second, it * sets the current moderation state to draft; at this point the node * would be in the archived state and it can't go straight from there * to published. * * @param \Drupal\schedulder\Event\SchedulerEvent $event * The scheduler unpublish event. */ public function onUnpublish(SchedulerEvent $event) { $node = $event->getNode(); $needs_save = FALSE; if ($node) { if (isset($node->publish_on->value)) { $node->set('publish_state', 'published'); $node->set('moderation_state', 'draft'); $needs_save = TRUE; } if (isset($node->unpublish_on->value)) { $node->set('unpublish_state', 'archived'); $needs_save = TRUE; } if ($needs_save) { $node->save(); } } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events = []; // We need this to run after scheduler_repeat, thus -10. $events[SchedulerNodeEvents::UNPUBLISH][] = ['onUnpublish', -10]; return $events; } }