parent
baebc4fd25
commit
73271de39a
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace Drupal\opdavies_blog\Plugin\QueueWorker;
|
namespace Drupal\opdavies_blog\Plugin\QueueWorker;
|
||||||
|
|
||||||
use Drupal\Core\Queue\QueueWorkerBase;
|
use Drupal\Core\Queue\QueueWorkerBase;
|
||||||
|
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @QueueWorker(
|
* @QueueWorker(
|
||||||
|
@ -18,4 +19,24 @@ final class PostPusherQueueWorker extends QueueWorkerBase {
|
||||||
public function processItem($data): void {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue