From 73271de39acaec784fa2dcfdebb9129148186f46 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 10 Jan 2021 16:17:04 +0000 Subject: [PATCH] Move logic for if a post should be pushed References #328 --- .../PushBlogPostToSocialMedia.php | 20 ------------------ .../QueueWorker/PostPusherQueueWorker.php | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php b/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php index a6657d4..2ef15a3 100644 --- a/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php +++ b/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php @@ -48,24 +48,4 @@ final class PushBlogPostToSocialMedia implements EventSubscriberInterface { ]); } - private function shouldBePushed(Post $post): bool { - if ($post->isExternalPost()) { - return FALSE; - } - - if (!$post->isPublished()) { - return FALSE; - } - - if (!$post->shouldSendToSocialMedia()) { - return FALSE; - } - - if ($post->hasBeenSentToSocialMedia()) { - return FALSE; - } - - return TRUE; - } - } diff --git a/web/modules/custom/blog/src/Plugin/QueueWorker/PostPusherQueueWorker.php b/web/modules/custom/blog/src/Plugin/QueueWorker/PostPusherQueueWorker.php index c3f8998..f85503b 100644 --- a/web/modules/custom/blog/src/Plugin/QueueWorker/PostPusherQueueWorker.php +++ b/web/modules/custom/blog/src/Plugin/QueueWorker/PostPusherQueueWorker.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Drupal\opdavies_blog\Plugin\QueueWorker; use Drupal\Core\Queue\QueueWorkerBase; +use Drupal\opdavies_blog\Entity\Node\Post; /** * @QueueWorker( @@ -18,4 +19,24 @@ final class PostPusherQueueWorker extends QueueWorkerBase { public function processItem($data): void { } + private function shouldBePushed(Post $post): bool { + if ($post->isExternalPost()) { + return FALSE; + } + + if (!$post->isPublished()) { + return FALSE; + } + + if (!$post->shouldSendToSocialMedia()) { + return FALSE; + } + + if ($post->hasBeenSentToSocialMedia()) { + return FALSE; + } + + return TRUE; + } + }