mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 11:34:36 +08:00
Fix ConfigureNotificationTypes API
This commit is contained in:
parent
cf42765513
commit
60483b2c62
|
@ -10,6 +10,7 @@
|
|||
|
||||
namespace Flarum\Event;
|
||||
|
||||
use Flarum\Core\Notification\BlueprintInterface;
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
|
||||
|
@ -25,17 +26,26 @@ class ConfigureNotificationTypes
|
|||
*/
|
||||
private $serializers;
|
||||
|
||||
/**
|
||||
* @param array $blueprints
|
||||
* @param array $serializers
|
||||
*/
|
||||
public function __construct(array &$blueprints, array &$serializers = [])
|
||||
{
|
||||
$this->blueprints = &$blueprints;
|
||||
$this->serializers = &$serializers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $blueprint
|
||||
* @param string $serializer
|
||||
* @param array $enabledByDefault
|
||||
*/
|
||||
public function add($blueprint, $serializer, $enabledByDefault = [])
|
||||
{
|
||||
if (! (new ReflectionClass($blueprint))->implementsInterface('Flarum\Core\Notification\Blueprint')) {
|
||||
if (! (new ReflectionClass($blueprint))->implementsInterface(BlueprintInterface::class)) {
|
||||
throw new InvalidArgumentException('Notification blueprint ' . $blueprint
|
||||
. ' must implement Flarum\Core\Notification\Blueprint');
|
||||
. ' must implement '.BlueprintInterface::class);
|
||||
}
|
||||
|
||||
$this->blueprints[$blueprint] = $enabledByDefault;
|
||||
|
|
Loading…
Reference in New Issue
Block a user