From eb23d93fe0ead09e7ae3947cec4efa3457dd6447 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 7 Oct 2020 22:58:17 +0100 Subject: [PATCH] Return early if should not be sent to social media Return early and don't send the post to social media if the `Post to social media` checkbox is not checked. References #249 --- .../blog/src/EventSubscriber/PushBlogPostToSocialMedia.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php b/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php index 358f84d..5c3a539 100644 --- a/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php +++ b/web/modules/custom/blog/src/EventSubscriber/PushBlogPostToSocialMedia.php @@ -53,6 +53,10 @@ final class PushBlogPostToSocialMedia implements EventSubscriberInterface { return; } + if (!$entity->shouldSendToSocialMedia()) { + return; + } + // If this post has already been sent to social media, do not send it again. if ($entity->hasBeenSentToSocialMedia()) { return;