headless_cms-1.0.3/modules/headless_cms_notify/src/Event/BeforeHeadlessNotifyEvent.php
modules/headless_cms_notify/src/Event/BeforeHeadlessNotifyEvent.php
<?php
declare(strict_types=1);
namespace Drupal\headless_cms_notify\Event;
use Drupal\Component\EventDispatcher\Event;
use Drupal\headless_cms_notify\NotifyMessage\HeadlessNotifyMessageInterface;
/**
* Event that is fired before a notification is sent.
*/
class BeforeHeadlessNotifyEvent extends Event {
public const EVENT_NAME = 'headless_cms_notify.before_notify';
/**
* Whether to abort sending the notification.
*/
protected bool $aborted = FALSE;
public function __construct(
protected readonly HeadlessNotifyMessageInterface $message,
) {}
/**
* Gets the notification message.
*/
public function getMessage(): HeadlessNotifyMessageInterface {
return $this->message;
}
/**
* Aborts sending the notification.
*/
public function abort(): void {
$this->aborted = TRUE;
}
/**
* Whether sending the notification was aborted.
*/
public function isAborted(): bool {
return $this->aborted;
}
}
