. // }}} namespace App\Controller; use App\Core\Controller; use App\Core\DB; use function App\Core\I18n\_m; use App\Util\Exception\ClientException; use Symfony\Component\HttpFoundation\Request; class Activity extends Controller { /** * Generic function that handles getting a representation for a note */ private function activity(int $id, callable $handle) { $activity = DB::findOneBy('activity', ['id' => $id], return_null: true); if (\is_null($activity)) { throw new ClientException(_m('No such activity.'), code: 404); } else { return $handle($activity); } } /** * The page where the note and it's info is shown */ public function ActivityShow(Request $request, int $id) { return $this->activity($id, fn ($activity) => ['_template' => '/cards/activity/view.html.twig', 'activity' => $activity]); } }