profiles = $profiles; } public function register(): void { $this->route('/profiles', 'GET', fn () => $this->profiles->all()); $this->route('/profiles', 'POST', fn (\WP_REST_Request $r) => new \WP_REST_Response( $this->profiles->create((string) $r->get_param('name'), (string) $r->get_param('type'), $r->get_param('settings')), 201 )); $this->route('/profiles/(?P[0-9a-f-]{36})', 'DELETE', function (\WP_REST_Request $r) { $this->profiles->delete($r['id']); return ['deleted' => true]; }); } }