1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6declare(strict_types=1);
7
8namespace App\Libraries\Opengraph\Forum;
9
10use App\Libraries\Opengraph\OpengraphInterface;
11use App\Models\Forum\Forum;
12
13class ForumOpengraph implements OpengraphInterface
14{
15 public function __construct(private Forum $forum)
16 {
17 }
18
19 // Reminder to update Topic::toOpengraph() as necessary if this value changes.
20 public function description(): string
21 {
22 $stack = [osu_trans('forum.title')];
23 foreach ($this->forum->forum_parents as $forumId => $forumData) {
24 $stack[] = $forumData[0];
25 }
26
27 $stack[] = $this->forum->forum_name;
28
29 return implode(' » ', $stack);
30 }
31
32 public function get(): array
33 {
34
35 return [
36 'description' => $this->description(),
37 'title' => $this->forum->forum_name,
38 'image' => $this->forum->cover?->file()->url(),
39 ];
40 }
41}