[ 'label' => t('Send'), 'callback' => 'simplenews_issue_send', ], ]; return $operations; } /** * Return operations to be applied to subscriptions. * * @ingroup issue */ function hook_simplenews_subscription_operations() { $operations = [ 'activate' => [ 'label' => t('Activate'), 'callback' => 'simplenews_subscription_activate', 'callback arguments' => [SubscriberInterface::ACTIVE], ], 'inactivate' => [ 'label' => t('Inactivate'), 'callback' => 'simplenews_subscription_activate', 'callback arguments' => [SubscriberInterface::INACTIVE], ], 'delete' => [ 'label' => t('Delete'), 'callback' => 'simplenews_subscription_delete_multiple', ], ]; return $operations; } /** * Act after a newsletter category has been saved. * * @param \Drupal\simplenews\Entity\Newsletter $newsletter * The newsletter object. * * @ingroup newsletter */ function hook_simplenews_newsletter_update(Newsletter $newsletter) { } /** * Act after a newsletter category has been deleted. * * @param \Drupal\simplenews\Entity\Newsletter $newsletter * The newsletter object. * * @ingroup newsletter */ function hook_simplenews_newsletter_delete(Newsletter $newsletter) { } /** * Act after a newsletter category has been inserted. * * @param \Drupal\simplenews\Entity\Newsletter $newsletter * The newsletter object. * * @ingroup newsletter */ function hook_simplenews_newsletter_insert(Newsletter $newsletter) { } /** * Act after a subscriber is updated. * * @param \Drupal\simplenews\Entity\Subscriber $subscriber * The subscriber object including all subscriptions of this user. * * @ingroup subscriber */ function hook_simplenews_subscriber_update(Subscriber $subscriber) { } /** * Act after a new subscriber has been created. * * @param \Drupal\simplenews\Entity\Subscriber $subscriber * The subscriber object including all subscriptions of this user. * * @ingroup subscriber */ function hook_simplenews_subscriber_insert(Subscriber $subscriber) { } /** * Act after a subscriber has been deleted. * * @param \Drupal\simplenews\Entity\Subscriber $subscriber * The subscriber object including all subscriptions of this user. * * @ingroup subscriber */ function hook_simplenews_subscriber_delete(Subscriber $subscriber) { } /** * Invoked if a subscriber is subscribed to a newsletter. * * @param \Drupal\simplenews\Entity\Subscriber $subscriber * The subscriber object including all subscriptions of this user. * @param string $newsletter_id * The newsletter ID for this specific subscribe action. * * @ingroup subscriber */ function hook_simplenews_subscribe(Subscriber $subscriber, $newsletter_id) { } /** * Invoked if a subscriber is unsubscribed from a newsletter. * * @param \Drupal\simplenews\Entity\Subscriber $subscriber * The subscriber object including all subscriptions of this user. * @param string $subscription * The subscription object for this specific unsubscribe action. * * @ingroup subscriber */ function hook_simplenews_unsubscribe(Subscriber $subscriber, $subscription) { } /** * Expose SimplenewsSource cache implementations. * * @return array * An array keyed by the name of the class that provides the implementation, * the array value consists of another array with the keys label and * description. * * @ingroup source */ function hook_simplenews_source_cache_info() { return [ 'SimplenewsSourceCacheNone' => [ 'label' => t('No caching'), 'description' => t('This allows to theme each newsletter separately.'), ], 'SimplenewsSourceCacheBuild' => [ 'label' => t('Cached content source'), 'description' => t('This caches the rendered content to be sent for multiple recipients. It is not possible to use subscriber specific theming but tokens can be used for personalization.'), ], ]; } /** * Invoked after sending of every mail to allow altering of the result. * * A common use of this hook is categorise errors and distinguish a global * failure from an error that is specific to a single recipient. * * @param int $result * One of the SpoolStorageInterface::STATUS_* constants. * @param array $message * The message returned by \Drupal\Core\Mail\MailManagerInterface::mail(). */ function hook_simplenews_mail_result_alter(&$result, array $message) { if (specific_error()) { $result = SpoolStorageInterface::STATUS_FAILED; } if (global_error()) { throw new AbortSendingException('Mail transport error'); } }