From 2d06f5e8d43e094c817933ea4078fce250cfb20e Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 7 Oct 2020 22:54:56 +0100 Subject: [PATCH] Add a method to check if send to social media Add a method to check if a post should be sent automatically to social media. References #249 --- web/modules/custom/blog/src/Entity/Node/Post.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/modules/custom/blog/src/Entity/Node/Post.php b/web/modules/custom/blog/src/Entity/Node/Post.php index 74befb5..f6b2eb5 100644 --- a/web/modules/custom/blog/src/Entity/Node/Post.php +++ b/web/modules/custom/blog/src/Entity/Node/Post.php @@ -49,6 +49,10 @@ class Post extends Node implements ContentEntityBundleInterface { $this->set('field_tags', $tags); } + public function shouldSendToSocialMedia(): bool { + return (bool) $this->get('field_send_to_social_media')->getString(); + } + public function toTweet(): string { $parts = [ $this->label(),