mirror of
https://github.com/flarum/framework.git
synced 2024-11-24 23:29:09 +08:00
parent
5a9711fac9
commit
a8c43097d7
|
@ -9,8 +9,8 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Database\Migration;
|
||||
use Flarum\Group\Group;
|
||||
|
||||
return Migration::addPermissions([
|
||||
'discussion.sticky' => Group::MODERATOR_ID
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Flarum\Sticky\Event;
|
||||
|
||||
use Flarum\Core\Discussion;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\User\User;
|
||||
|
||||
class DiscussionWasStickied
|
||||
{
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Flarum\Sticky\Event;
|
||||
|
||||
use Flarum\Core\Discussion;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\User\User;
|
||||
|
||||
class DiscussionWasUnstickied
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
namespace Flarum\Sticky\Listener;
|
||||
|
||||
use Flarum\Api\Controller\ListDiscussionsController;
|
||||
use Flarum\Api\Event\Serializing;
|
||||
use Flarum\Api\Event\WillGetData;
|
||||
use Flarum\Api\Serializer\DiscussionSerializer;
|
||||
use Flarum\Event\ConfigureApiController;
|
||||
use Flarum\Event\PrepareApiAttributes;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class AddApiAttributes
|
||||
|
@ -24,14 +24,14 @@ class AddApiAttributes
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(PrepareApiAttributes::class, [$this, 'prepareApiAttributes']);
|
||||
$events->listen(ConfigureApiController::class, [$this, 'includeStartPost']);
|
||||
$events->listen(Serializing::class, [$this, 'prepareApiAttributes']);
|
||||
$events->listen(WillGetData::class, [$this, 'includeStartPost']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PrepareApiAttributes $event
|
||||
* @param Serializing $event
|
||||
*/
|
||||
public function prepareApiAttributes(PrepareApiAttributes $event)
|
||||
public function prepareApiAttributes(Serializing $event)
|
||||
{
|
||||
if ($event->isSerializer(DiscussionSerializer::class)) {
|
||||
$event->attributes['isSticky'] = (bool) $event->model->is_sticky;
|
||||
|
@ -40,9 +40,9 @@ class AddApiAttributes
|
|||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureApiController $event
|
||||
* @param WillGetData $event
|
||||
*/
|
||||
public function includeStartPost(ConfigureApiController $event)
|
||||
public function includeStartPost(WillGetData $event)
|
||||
{
|
||||
if ($event->isController(ListDiscussionsController::class)) {
|
||||
$event->addInclude('startPost');
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\Sticky\Listener;
|
||||
|
||||
use Flarum\Event\ConfigureWebApp;
|
||||
use Flarum\Frontend\Event\Rendering;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class AddClientAssets
|
||||
|
@ -21,13 +21,13 @@ class AddClientAssets
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureWebApp::class, [$this, 'addAssets']);
|
||||
$events->listen(Rendering::class, [$this, 'addAssets']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureClientView $event
|
||||
* @param Rendering $event
|
||||
*/
|
||||
public function addAssets(ConfigureWebApp $event)
|
||||
public function addAssets(Rendering $event)
|
||||
{
|
||||
if ($event->isForum()) {
|
||||
$event->addAssets([
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
namespace Flarum\Sticky\Listener;
|
||||
|
||||
use Flarum\Core\Discussion;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Event\ConfigurePostTypes;
|
||||
use Flarum\Sticky\Event\DiscussionWasStickied;
|
||||
use Flarum\Sticky\Event\DiscussionWasUnstickied;
|
||||
use Flarum\Sticky\Post\DiscussionStickiedPost;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class CreatePostWhenDiscussionIsStickied
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Flarum\Sticky\Listener;
|
||||
|
||||
use Flarum\Discussion\Event\Searching;
|
||||
use Flarum\Event\ConfigureDiscussionGambits;
|
||||
use Flarum\Event\ConfigureDiscussionSearch;
|
||||
use Flarum\Sticky\Gambit\StickyGambit;
|
||||
use Flarum\Tags\Gambit\TagGambit;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
@ -25,7 +25,7 @@ class PinStickiedDiscussionsToTop
|
|||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureDiscussionGambits::class, [$this, 'addStickyGambit']);
|
||||
$events->listen(ConfigureDiscussionSearch::class, [$this, 'reorderSearch']);
|
||||
$events->listen(Searching::class, [$this, 'reorderSearch']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,9 +37,9 @@ class PinStickiedDiscussionsToTop
|
|||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureDiscussionSearch $event
|
||||
* @param Searching $event
|
||||
*/
|
||||
public function reorderSearch(ConfigureDiscussionSearch $event)
|
||||
public function reorderSearch(Searching $event)
|
||||
{
|
||||
if ($event->criteria->sort === null) {
|
||||
$search = $event->search;
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Flarum\Sticky\Listener;
|
||||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Event\DiscussionWillBeSaved;
|
||||
use Flarum\Discussion\Event\Saving;
|
||||
use Flarum\Sticky\Event\DiscussionWasStickied;
|
||||
use Flarum\Sticky\Event\DiscussionWasUnstickied;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class SaveStickyToDatabase
|
||||
|
@ -26,13 +26,13 @@ class SaveStickyToDatabase
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(DiscussionWillBeSaved::class, [$this, 'whenDiscussionWillBeSaved']);
|
||||
$events->listen(Saving::class, [$this, 'whenSaving']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DiscussionWillBeSaved $event
|
||||
* @param Saving $event
|
||||
*/
|
||||
public function whenDiscussionWillBeSaved(DiscussionWillBeSaved $event)
|
||||
public function whenSaving(Saving $event)
|
||||
{
|
||||
if (isset($event->data['attributes']['isSticky'])) {
|
||||
$isSticky = (bool) $event->data['attributes']['isSticky'];
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Flarum\Sticky\Post;
|
||||
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Core\Post\AbstractEventPost;
|
||||
use Flarum\Core\Post\MergeableInterface;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Post\Post\AbstractEventPost;
|
||||
use Flarum\Post\Post\MergeableInterface;
|
||||
|
||||
class DiscussionStickiedPost extends AbstractEventPost implements MergeableInterface
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user