Loading src/Entity/Notification.php +12 −0 Original line number Diff line number Diff line Loading @@ -5,8 +5,10 @@ namespace Drupal\danse\Entity; use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\EntityChangedTrait; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Site\Settings; /** * Defines the DANSE notification entity class. Loading Loading @@ -35,6 +37,16 @@ class Notification extends ContentEntityBase implements NotificationInterface { use EntityChangedTrait; /** * {@inheritdoc} */ public function postCreate(EntityStorageInterface $storage): void { parent::postCreate($storage); if (!Settings::get('danse_notification_delivery', TRUE)) { $this->set('delivered', TRUE); } } /** * {@inheritdoc} */ Loading src/PluginBase.php +10 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Site\Settings; use Drupal\danse\Entity\Event; use Drupal\danse\Entity\EventInterface; use Drupal\danse\Entity\Notification; Loading Loading @@ -161,8 +162,13 @@ abstract class PluginBase extends CorePluginBase implements PluginInterface, Con if ($event->isPush()) { foreach ($this->recipientSelectionPlugins as $recipientSelectionPlugin) { if ($recipientSelectionPlugin instanceof DirectPushInterface) { $result = $recipientSelectionPlugin->push($payload); $channelPluginId = $recipientSelectionPlugin->directPushChannelId(); if (Settings::get('danse_notification_delivery', TRUE)) { $result = $recipientSelectionPlugin->push($payload); } else { $result = ChannelPluginInterface::RESULT_STATUS_SUCCESS; } $success = $result === ChannelPluginInterface::RESULT_STATUS_SUCCESS; foreach ($this->createNotification($event, 'push', 1) as $notification) { if ($success) { Loading @@ -177,8 +183,9 @@ abstract class PluginBase extends CorePluginBase implements PluginInterface, Con ]); try { $action->save(); } catch (EntityStorageException $e) { // TODO: Log this exception. } catch (EntityStorageException $e) { // @todo Log this exception. } } } Loading Loading
src/Entity/Notification.php +12 −0 Original line number Diff line number Diff line Loading @@ -5,8 +5,10 @@ namespace Drupal\danse\Entity; use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\EntityChangedTrait; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Site\Settings; /** * Defines the DANSE notification entity class. Loading Loading @@ -35,6 +37,16 @@ class Notification extends ContentEntityBase implements NotificationInterface { use EntityChangedTrait; /** * {@inheritdoc} */ public function postCreate(EntityStorageInterface $storage): void { parent::postCreate($storage); if (!Settings::get('danse_notification_delivery', TRUE)) { $this->set('delivered', TRUE); } } /** * {@inheritdoc} */ Loading
src/PluginBase.php +10 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Site\Settings; use Drupal\danse\Entity\Event; use Drupal\danse\Entity\EventInterface; use Drupal\danse\Entity\Notification; Loading Loading @@ -161,8 +162,13 @@ abstract class PluginBase extends CorePluginBase implements PluginInterface, Con if ($event->isPush()) { foreach ($this->recipientSelectionPlugins as $recipientSelectionPlugin) { if ($recipientSelectionPlugin instanceof DirectPushInterface) { $result = $recipientSelectionPlugin->push($payload); $channelPluginId = $recipientSelectionPlugin->directPushChannelId(); if (Settings::get('danse_notification_delivery', TRUE)) { $result = $recipientSelectionPlugin->push($payload); } else { $result = ChannelPluginInterface::RESULT_STATUS_SUCCESS; } $success = $result === ChannelPluginInterface::RESULT_STATUS_SUCCESS; foreach ($this->createNotification($event, 'push', 1) as $notification) { if ($success) { Loading @@ -177,8 +183,9 @@ abstract class PluginBase extends CorePluginBase implements PluginInterface, Con ]); try { $action->save(); } catch (EntityStorageException $e) { // TODO: Log this exception. } catch (EntityStorageException $e) { // @todo Log this exception. } } } Loading