-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(2.0): try to refactor the remainder of the backend
- Loading branch information
1 parent
18f1d53
commit b72a314
Showing
2 changed files
with
39 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace FoF\FrontPage\Api; | ||
|
||
use Flarum\Api\Context; | ||
use Flarum\Api\Endpoint\Update; | ||
use Flarum\Api\Schema\Boolean; | ||
use Flarum\Api\Schema\Date; | ||
use Flarum\Discussion\Discussion; | ||
|
||
class DiscussionResourceFields | ||
{ | ||
public function __invoke(): array | ||
{ | ||
return [ | ||
Boolean::make('frontpage') | ||
->writable(function (Discussion $discussion, Context $context) { | ||
return $context->endpoint instanceof Update | ||
&& $context->getActor()->can('front', $discussion); | ||
}), | ||
|
||
Date::make('frontdate') | ||
->get(fn (Discussion $discussion) => $discussion->frontdate), | ||
|
||
Boolean::make('front') | ||
->get(fn (Discussion $discussion, Context $context) => $context->getActor()->can('front', $discussion)), | ||
]; | ||
} | ||
} |