forked from ppy/osu-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ppy#11742 from Sheppsu/forum-api
Add new API endpoints for forums and topics
- Loading branch information
Showing
8 changed files
with
251 additions
and
12 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
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,34 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
namespace App\Transformers\Forum; | ||
|
||
use App\Models\Forum\Forum; | ||
use App\Transformers\TransformerAbstract; | ||
use League\Fractal\Resource\ResourceInterface; | ||
|
||
class ForumTransformer extends TransformerAbstract | ||
{ | ||
protected array $availableIncludes = [ | ||
'subforums', | ||
]; | ||
|
||
public function transform(Forum $forum): array | ||
{ | ||
return [ | ||
'id' => $forum->getKey(), | ||
'name' => $forum->forum_name, | ||
'description' => $forum->forum_desc, | ||
]; | ||
} | ||
|
||
public function includeSubforums(Forum $forum): ResourceInterface | ||
{ | ||
return $this->collection( | ||
$forum->subforums, | ||
new static() | ||
); | ||
} | ||
} |
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,10 @@ | ||
<div id="forum-object" data-unique="forum-object"></div> | ||
|
||
## Forum | ||
|
||
Field | Type | Notes | ||
------------|---------------------------|------- | ||
id | integer | | ||
name | string | | ||
description | string | | ||
subforums | [Forum](#forum-object)[]? | Maximum 2 layers of subforums from the top-level Forum |
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