Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Notification Channel Extender #2432

Merged
merged 15 commits into from
Nov 5, 2020
Prev Previous commit
Next Next commit
Rename method to registerType
  • Loading branch information
SychO9 committed Nov 1, 2020
commit e6b540cbd0cb0fd03fd220ab5784b2b683beed80
2 changes: 1 addition & 1 deletion src/Notification/Driver/AlertNotificationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function send(BlueprintInterface $blueprint, array $users): void
/**
* {@inheritdoc}
*/
public function addUserPreference(string $blueprintClass, bool $default): void
public function registerType(string $blueprintClass, bool $default): void
{
User::addPreference(
User::getNotificationPreferenceKey($blueprintClass::getType(), 'alert'),
Expand Down
2 changes: 1 addition & 1 deletion src/Notification/Driver/EmailNotificationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function mailNotifications(MailableInterface $blueprint, array $recipi
/**
* {@inheritdoc}
*/
public function addUserPreference(string $blueprintClass, bool $default): void
public function registerType(string $blueprintClass, bool $default): void
{
if ((new ReflectionClass($blueprintClass))->implementsInterface(MailableInterface::class)) {
askvortsov1 marked this conversation as resolved.
Show resolved Hide resolved
User::addPreference(
Expand Down
2 changes: 1 addition & 1 deletion src/Notification/NotificationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function addType(string $blueprint, array $driversEnabledByDefault)
);

foreach (Notification::getNotificationDrivers() as $driverName => $driver) {
$driver->addUserPreference(
$driver->registerType(
$blueprint,
in_array($driverName, $driversEnabledByDefault)
SychO9 marked this conversation as resolved.
Show resolved Hide resolved
);
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/extenders/NotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
use Flarum\Notification\Blueprint\BlueprintInterface;
use Flarum\Notification\Driver\NotificationDriverInterface;
use Flarum\Notification\Notification;
use Flarum\Notification\NotificationSyncer;
use Flarum\Tests\integration\TestCase;

class NotificationTest extends \Flarum\Tests\integration\TestCase
class NotificationTest extends TestCase
{
/**
* @test
Expand Down Expand Up @@ -98,7 +100,7 @@ public function send(BlueprintInterface $blueprint, array $users): void
// ...
}

public function addUserPreference(string $blueprintClass, bool $default): void
public function registerType(string $blueprintClass, bool $default): void
{
// ...
}
Expand Down