queueFactory = $queueFactory; } /** * @inheritDoc */ public static function getSubscribedEvents() { return [ HookEventDispatcherInterface::ENTITY_INSERT => 'onEntityUpdate', HookEventDispatcherInterface::ENTITY_UPDATE => 'onEntityUpdate', ]; } public function onEntityUpdate(AbstractEntityEvent $event): void { $entity = $event->getEntity(); if ($entity->getEntityTypeId() != 'node') { return; } /** @var Post $entity */ if ($entity->bundle() != 'post') { return; } $queue = $this->queueFactory->get('opdavies_blog_push_post_to_social_media'); $queue->createQueue(); $queue->createItem([ 'post' => $entity, ]); } }