mirror of
https://github.com/flarum/core.git
synced 2025-10-13 16:05:05 +02:00
Add Notification Type Extender and Tests (#2424)
This commit is contained in:
38
src/Extend/Notification.php
Normal file
38
src/Extend/Notification.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Extend;
|
||||
|
||||
use Flarum\Extension\Extension;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class Notification implements ExtenderInterface
|
||||
{
|
||||
private $blueprints = [];
|
||||
private $serializers = [];
|
||||
|
||||
public function type(string $blueprint, string $serializer, array $channelsEnabledByDefault = [])
|
||||
{
|
||||
$this->blueprints[$blueprint] = $channelsEnabledByDefault;
|
||||
$this->serializers[$blueprint::getType()] = $serializer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Container $container, Extension $extension = null)
|
||||
{
|
||||
$container->extend('flarum.notification.blueprints', function ($existingBlueprints) {
|
||||
return array_merge($existingBlueprints, $this->blueprints);
|
||||
});
|
||||
|
||||
$container->extend('flarum.api.notification_serializers', function ($existingSerializers) {
|
||||
return array_merge($existingSerializers, $this->serializers);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user