mirror of
https://github.com/flarum/core.git
synced 2025-10-22 20:26:15 +02:00
Add BC layer for notification blueprints
This gives extension authors time to add the new `getAttributes()` method to their `BlueprintInterface` implementations. The layer itself is easy to remove in beta.14.
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
<?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\Notification\Blueprint;
|
||||
|
||||
abstract class AbstractBlueprint implements BlueprintInterface
|
||||
{
|
||||
public function getAttributes(): array
|
||||
{
|
||||
return [
|
||||
'type' => static::getType(),
|
||||
'from_user_id' => ($fromUser = $this->getFromUser()) ? $fromUser->id : null,
|
||||
'subject_id' => ($subject = $this->getSubject()) ? $subject->getKey() : null,
|
||||
'data' => ($data = $this->getData()) ? json_encode($data) : null
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ interface BlueprintInterface
|
||||
/**
|
||||
* Get the user that sent the notification.
|
||||
*
|
||||
* @deprecated Will be removed for beta.14
|
||||
* @return User|null
|
||||
*/
|
||||
public function getFromUser();
|
||||
@@ -29,6 +30,7 @@ interface BlueprintInterface
|
||||
/**
|
||||
* Get the model that is the subject of this activity.
|
||||
*
|
||||
* @deprecated Will be removed for beta.14
|
||||
* @return AbstractModel|null
|
||||
*/
|
||||
public function getSubject();
|
||||
@@ -36,10 +38,19 @@ interface BlueprintInterface
|
||||
/**
|
||||
* Get the data to be stored in the notification.
|
||||
*
|
||||
* @deprecated Will be removed for beta.14
|
||||
* @return array|null
|
||||
*/
|
||||
public function getData();
|
||||
|
||||
/**
|
||||
* Get the attributes that uniquely identify a notification, plus metadata.
|
||||
* TODO: Uncomment this for beta.14.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
//public function getAttributes(): array;
|
||||
|
||||
/**
|
||||
* Get the serialized type of this activity.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user