diff --git a/src/Controller/MagewireUpdateRoute.php b/src/Controller/MagewireUpdateRoute.php index a3505921..a3af8833 100644 --- a/src/Controller/MagewireUpdateRoute.php +++ b/src/Controller/MagewireUpdateRoute.php @@ -1,5 +1,4 @@ actionFactory, $this->logger, $this->magewireRouteValidator); } - /** - * Matches and processes Magewire update requests. - * - * Validates the request, boots Magewire in subsequent mode, and parses - * component data. Returns a forward action on failure or the matched - * action on success. - */ public function match(RequestInterface $request): ActionInterface|null { $match = parent::match($request); @@ -68,42 +53,30 @@ public function match(RequestInterface $request): ActionInterface|null return null; } + // Mark the request as a subsequent Magewire request. + $request->setParam(self::PARAM_IS_SUBSEQUENT, true); + /** - * Boot Magewire and initialize the request context. - * - * Magewire has two trigger points for initialization: - * 1. During component updates (the only feasible location after confirming an update request) - * 2. During page load via the view block observer - * - * This call marks the request as "subsequent" to distinguish between initial page loads - * and subsequent update requests, allowing system-wide determination of Magewire's state. + * Magewire has two trigger points for booting itself. One occurs during the updating of components. + * This is the only feasible location, after confirming we are on an update request, + * where we should attempt to boot. [2/2] * * @see \Magewirephp\Magewire\Observer\ViewBlockAbstractToHtmlBefore */ - $this->magewireServiceProvider->boot(RequestMode::SUBSEQUENT); + $this->magewireServiceProvider->boot(); try { $request->setParams($this->parseRequest($request)); } catch (Exception $exception) { - $this->logger->critical($exception->getMessage(), ['exception' => $exception]); - - return null; + return $this->actionFactory->create(Forward::class); } return $match; } + /** - * Parses and validates the component update request payload. - * - * Deserializes component data from the request body, verifies checksums, - * validates component prerequisites (resolver/handle), and converts - * component data to service contract objects. - * * @throws LocalizedException - * @throws FileSystemException - * @throws \Magento\Framework\Exception\RuntimeException - * @throws CorruptComponentPayloadException */ protected function parseRequest(RequestInterface $request): array { @@ -130,17 +103,8 @@ protected function parseRequest(RequestInterface $request): array throw new RuntimeException('Base component prerequisites not satisfied.'); } - $snapshot = $this->snapshotFactory->create([ - 'data' => $component['snapshot']['data'] ?? [], - 'memo' => $component['snapshot']['memo'] ?? [], - 'checksum' => $component['snapshot']['checksum'] ?? '', - ]); - - $input[self::PARAM_COMPONENTS][$key] = $this->componentRequestContextFactory->create([ - 'snapshot' => $snapshot, - 'calls' => $component['calls'] ?? [], - 'updates' => $component['updates'] ?? [], - ]); + // Each component request context must conform to the service contract requirements. + $input[self::PARAM_COMPONENTS][$key] = $this->serviceInputProcessor->convertValue($component, ComponentRequestContext::class); } /** @var Request $request */