getAttribute('cloud_actor') ?? CloudAccess::actor(false); if (!($actor['is_admin'] ?? false)) { throw new CloudError('需要管理员权限', 403); } if ($write) { CloudAccess::manage($actor); if (!($actor['is_super_admin'] ?? false)) { throw new CloudError('仅超级管理员可以修改 Fabric', 403); } } return $actor; } private function json($response, array $payload, int $status = 200) { return $response->withJson($payload, $status) ->withHeader('Cache-Control', 'private, no-store'); } public function index($request, $response) { return $this->json($response, CloudAdminFabricService::listing($this->actor($request))); } public function detail($request, $response, $args) { return $this->json($response, CloudAdminFabricService::detail( (string) ($args['fabric_id'] ?? ''), $this->actor($request) )); } public function apply($request, $response) { $actor = $this->actor($request, true); $body = CloudInput::object($request, 131072); return $this->json($response, CloudAdminFabricService::apply($body, $actor), 200); } public function reconcile($request, $response, $args) { $actor = $this->actor($request, true); $body = trim((string) $request->getBody()); if ($body !== '' && $body !== '{}') { throw new CloudError('Fabric reconcile 不接受请求体', 422); } return $this->json($response, CloudAdminFabricService::reconcile( (string) ($args['fabric_id'] ?? ''), $actor )); } }