/** * {@inheritdoc} */ public function apply(Request $request, ParamConverter $configuration) { if (null === ($rawMessageIdentifier = $request->query->get('message_identifier'))) { throw new BadRequestHttpException('The `message_identifier` parameter is required'); } $messageIdentifier = StringMessageIdentifier::fromString($rawMessageIdentifier); $inspectionRequest = InspectionRequest::fromMessageIdentifier($messageIdentifier); $request->attributes->set($configuration->getName(), $inspectionRequest); }
/** * @param array $normalized * * @return MessageProfile */ public static function fromQueryResult(array $normalized) { if (!array_key_exists('message', $normalized)) { throw new \InvalidArgumentException('Missing the `message` attribute'); } $normalizedMessage = $normalized['message']; $profile = new self(StringMessageIdentifier::fromString($normalizedMessage['identifier']), isset($normalized['sender']) ? Peer::fromNormalized($normalized['sender']) : null, isset($normalized['receiver']) ? Peer::fromNormalized($normalized['receiver']) : null, $normalizedMessage['context']); if (null !== ($timing = self::timingFromQuery($normalized))) { $profile = $profile->withTiming($timing); } if (isset($normalized['parent'])) { $parentIdentifier = StringMessageIdentifier::fromString($normalized['parent']['identifier']); $profile = $profile->withParentIdentifier($parentIdentifier); $profile->parent = $normalized['parent']; } $profile->message = $normalized['message']; return $profile; }