Loading src/Controller/WebPushNotificationController.php +3 −4 Changes for src/Controller/WebPushNotificationController.php: 3 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; Loading @@ -35,7 +34,7 @@ class WebPushNotificationController extends ControllerBase { * * @param \Drupal\Core\Extension\ModuleHandler $moduleHandler * The module handler service. * @param KeysHelper $keysHelper * @param \Drupal\web_push_notification\KeysHelper $keysHelper * The notification keys helper service. */ public function __construct(ModuleHandler $moduleHandler, KeysHelper $keysHelper) { Loading @@ -59,7 +58,7 @@ class WebPushNotificationController extends ControllerBase { * @return \Symfony\Component\HttpFoundation\BinaryFileResponse * The service worker content. */ public function serviceWorker(): BinaryFileResponse { public function serviceWorker() { $module_path = $this->moduleHandler->getModule('web_push_notification')->getPath(); $uri = "{$module_path}/js/service_worker.js"; Loading Loading @@ -87,7 +86,7 @@ class WebPushNotificationController extends ControllerBase { * When required parameter (key, token, endpoint) is missing. * @throws \Drupal\Core\Entity\EntityStorageException */ public function subscribe(Request $request): Response { public function subscribe(Request $request) { // Cannot accept a user confirmation when push keys are empty. if (!$this->keysHelper->isKeysDefined()) { Loading src/Form/BundleConfigForm.php +2 −2 Changes for src/Form/BundleConfigForm.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ class BundleConfigForm extends ConfigFormBase { * @return \Drupal\Core\Field\FieldDefinitionInterface[] * The array of field definitions for the bundle, keyed by field name. */ protected function getBundleFields(string $bundle): array { protected function getBundleFields($bundle) { return $this->entityFieldManager->getFieldDefinitions('node', $bundle); } Loading @@ -156,7 +156,7 @@ class BundleConfigForm extends ConfigFormBase { * @return array * The list of node bundles. */ protected function getBundles(): array { protected function getBundles() { return $this->bundleInfo->getBundleInfo('node'); } Loading src/Form/SettingsForm.php +1 −1 Changes for src/Form/SettingsForm.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ class SettingsForm extends ConfigFormBase { * @param string $privateKey * The private key. */ protected function saveKeys(string $publicKey, string $privateKey) { protected function saveKeys($publicKey, $privateKey) { $this->config('web_push_notification.settings') ->set('public_key', $publicKey) ->set('private_key', $privateKey) Loading src/KeysHelper.php +6 −5 Changes for src/KeysHelper.php: 6 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ class KeysHelper { * HelperService constructor. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config * The config factory. */ public function __construct(ConfigFactoryInterface $config) { $this->config = $config->get(self::SETTINGS); Loading @@ -33,7 +34,7 @@ class KeysHelper { * @return string * The public key. */ public function getPublicKey(): string { public function getPublicKey() { return $this->config->get('public_key'); } Loading @@ -43,7 +44,7 @@ class KeysHelper { * @return string * The private key. */ public function getPrivateKey(): string { public function getPrivateKey() { return $this->config->get('private_key'); } Loading @@ -55,7 +56,7 @@ class KeysHelper { * * @throws \ErrorException */ public function generateKeys(): array { public function generateKeys() { return VAPID::createVapidKeys(); } Loading @@ -64,7 +65,7 @@ class KeysHelper { * * @return bool */ public function isKeysDefined(): bool { public function isKeysDefined() { $public = $this->getPublicKey(); $private = $this->getPublicKey(); return $public && $private; Loading @@ -80,7 +81,7 @@ class KeysHelper { * * @return array */ public function getVapidAuth(): array { public function getVapidAuth() { if (!$this->isKeysDefined()) { throw new AuthKeysException('Public, private keys must be defined.'); } Loading src/NotificationItem.php +2 −2 Changes for src/NotificationItem.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ class NotificationItem { * @param string $body * The notification message (body). */ public function __construct(string $title = '', string $body = '') { public function __construct($title = '', $body = '') { $this->title = $title; $this->body = $body; } Loading @@ -57,7 +57,7 @@ class NotificationItem { * @return string * A JSON encoded payload. */ public function payload(): string { public function payload() { return json_encode([ 'title' => $this->title, 'body' => $this->body, Loading Loading
src/Controller/WebPushNotificationController.php +3 −4 Changes for src/Controller/WebPushNotificationController.php: 3 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; Loading @@ -35,7 +34,7 @@ class WebPushNotificationController extends ControllerBase { * * @param \Drupal\Core\Extension\ModuleHandler $moduleHandler * The module handler service. * @param KeysHelper $keysHelper * @param \Drupal\web_push_notification\KeysHelper $keysHelper * The notification keys helper service. */ public function __construct(ModuleHandler $moduleHandler, KeysHelper $keysHelper) { Loading @@ -59,7 +58,7 @@ class WebPushNotificationController extends ControllerBase { * @return \Symfony\Component\HttpFoundation\BinaryFileResponse * The service worker content. */ public function serviceWorker(): BinaryFileResponse { public function serviceWorker() { $module_path = $this->moduleHandler->getModule('web_push_notification')->getPath(); $uri = "{$module_path}/js/service_worker.js"; Loading Loading @@ -87,7 +86,7 @@ class WebPushNotificationController extends ControllerBase { * When required parameter (key, token, endpoint) is missing. * @throws \Drupal\Core\Entity\EntityStorageException */ public function subscribe(Request $request): Response { public function subscribe(Request $request) { // Cannot accept a user confirmation when push keys are empty. if (!$this->keysHelper->isKeysDefined()) { Loading
src/Form/BundleConfigForm.php +2 −2 Changes for src/Form/BundleConfigForm.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ class BundleConfigForm extends ConfigFormBase { * @return \Drupal\Core\Field\FieldDefinitionInterface[] * The array of field definitions for the bundle, keyed by field name. */ protected function getBundleFields(string $bundle): array { protected function getBundleFields($bundle) { return $this->entityFieldManager->getFieldDefinitions('node', $bundle); } Loading @@ -156,7 +156,7 @@ class BundleConfigForm extends ConfigFormBase { * @return array * The list of node bundles. */ protected function getBundles(): array { protected function getBundles() { return $this->bundleInfo->getBundleInfo('node'); } Loading
src/Form/SettingsForm.php +1 −1 Changes for src/Form/SettingsForm.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ class SettingsForm extends ConfigFormBase { * @param string $privateKey * The private key. */ protected function saveKeys(string $publicKey, string $privateKey) { protected function saveKeys($publicKey, $privateKey) { $this->config('web_push_notification.settings') ->set('public_key', $publicKey) ->set('private_key', $privateKey) Loading
src/KeysHelper.php +6 −5 Changes for src/KeysHelper.php: 6 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ class KeysHelper { * HelperService constructor. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config * The config factory. */ public function __construct(ConfigFactoryInterface $config) { $this->config = $config->get(self::SETTINGS); Loading @@ -33,7 +34,7 @@ class KeysHelper { * @return string * The public key. */ public function getPublicKey(): string { public function getPublicKey() { return $this->config->get('public_key'); } Loading @@ -43,7 +44,7 @@ class KeysHelper { * @return string * The private key. */ public function getPrivateKey(): string { public function getPrivateKey() { return $this->config->get('private_key'); } Loading @@ -55,7 +56,7 @@ class KeysHelper { * * @throws \ErrorException */ public function generateKeys(): array { public function generateKeys() { return VAPID::createVapidKeys(); } Loading @@ -64,7 +65,7 @@ class KeysHelper { * * @return bool */ public function isKeysDefined(): bool { public function isKeysDefined() { $public = $this->getPublicKey(); $private = $this->getPublicKey(); return $public && $private; Loading @@ -80,7 +81,7 @@ class KeysHelper { * * @return array */ public function getVapidAuth(): array { public function getVapidAuth() { if (!$this->isKeysDefined()) { throw new AuthKeysException('Public, private keys must be defined.'); } Loading
src/NotificationItem.php +2 −2 Changes for src/NotificationItem.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ class NotificationItem { * @param string $body * The notification message (body). */ public function __construct(string $title = '', string $body = '') { public function __construct($title = '', $body = '') { $this->title = $title; $this->body = $body; } Loading @@ -57,7 +57,7 @@ class NotificationItem { * @return string * A JSON encoded payload. */ public function payload(): string { public function payload() { return json_encode([ 'title' => $this->title, 'body' => $this->body, Loading