Skip to content
Snippets Groups Projects
Unverified Commit 21652ab8 authored by Ihor Kvyatkovskyi's avatar Ihor Kvyatkovskyi Committed by Alexander Varwijk
Browse files

Issue #3129701 by unrealauk: Drupal 9 compatibility fixes

parent 49bb4499
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ name: Activity Send Web Push
type: module
description: Used to send activity notifications by Web Push
core: 8.x
core_version_requirement: ^8 || ^9
package: Social
dependencies:
- activity_send
......@@ -77,7 +77,7 @@ function activity_send_push_activity_insert(ActivityInterface $activity) {
$fid = $icon[0];
/** @var \Drupal\file\Entity\File $file */
$file = File::load($fid);
$path = $file->url();
$path = $file->createFileUrl(FALSE);
$fields['icon'] = file_url_transform_relative($path);
}
......
......@@ -2,6 +2,7 @@ name: 'Social PWA'
description: 'Makes the website "Installable" like an App on smartphones and enhances it with Service Workers for the use of Push Notifications and an Offline User Experience.'
type: module
core: 8.x
core_version_requirement: ^8 || ^9
package: Social
configure: social_pwa.settings
dependencies:
......
......@@ -11,7 +11,7 @@ use Minishlink\WebPush\VAPID;
* Implements hook_install().
*/
function social_pwa_install() {
drupal_set_message(t('The Social PWA module has been enabled.'));
\Drupal::messenger()->addStatus(t('The Social PWA module has been enabled.'));
// Check for existing keys.
$vapid_keys = \Drupal::state()->get('social_pwa.vapid_keys');
......
......@@ -132,7 +132,7 @@ class ManifestSettingsForm extends ConfigFormBase {
'#description' => $this->t('Provide a square (.png) image. This image serves as your icon when the user adds the website to their home screen. <i>Minimum dimensions are 512px by 512px.</i>'),
'#default_value' => $icon ?: [],
'#required' => TRUE,
'#upload_location' => file_default_scheme() . '://images/touch/',
'#upload_location' => \Drupal::config('system.file')->get('default_scheme') . '://images/touch/',
'#upload_validators' => [
'file_validate_extensions' => ['png'],
'file_validate_image_resolution' => ['512x512', '512x512'],
......
......@@ -4,6 +4,7 @@ namespace Drupal\social_pwa\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
use Minishlink\WebPush\WebPush;
......@@ -13,6 +14,8 @@ use Minishlink\WebPush\WebPush;
*/
class PushNotificationForm extends FormBase {
use MessengerTrait;
/**
* {@inheritdoc}
*/
......@@ -28,7 +31,7 @@ class PushNotificationForm extends FormBase {
// Check first if sending push notifications is enabled.
$push_enabled = \Drupal::config('social_pwa.settings')->get('status.all');
if (!$push_enabled) {
drupal_set_message(t('Sending push notifications is disabled.'), 'warning');
$this->messenger()->addWarning($this->t('Sending push notifications is disabled.'));
return $form;
}
......@@ -55,7 +58,7 @@ class PushNotificationForm extends FormBase {
// Check if the $user_list does have values.
if (empty($user_list)) {
drupal_set_message(t('There are currently no users subscribed to receive push notifications.'), 'warning');
$this->messenger()->addWarning($this->t('There are currently no users subscribed to receive push notifications.'));
}
else {
// Start the form for sending push notifications.
......@@ -173,7 +176,7 @@ class PushNotificationForm extends FormBase {
\Drupal::service('user.data')->set('social_pwa', $uid, 'subscription', $user_subscription);
}
}
drupal_set_message($this->t('Message was successfully sent!'));
$this->messenger()->addStatus($this->t('Message was successfully sent!'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment