Skip to content

Commit 1be6d30

Browse files
Jiaming Youmeta-codesync[bot]
authored andcommitted
Added API processRequestFromContext
Summary: Added API processRequestFromContext details in https://docs.google.com/document/d/1JsLrmdiPxD4VFwKp3Kn5Tm7d7gUyYehXaOGU5PH03Xk/edit?tab=t.0#heading=h.jbvrsywtudzt Reviewed By: hongj-src Differential Revision: D91829181 fbshipit-source-id: 3ad27489a18655c2024dc488b3a177e1ac77c5b8
1 parent 01df454 commit 1be6d30

3 files changed

Lines changed: 1073 additions & 1 deletion

File tree

php/capi-param-builder/src/ParamBuilder.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
require_once 'model/Constants.php';
1212
require_once 'model/FbcParamConfig.php';
1313
require_once 'model/CookieSettings.php';
14+
require_once 'model/PlainDataObject.php';
1415
require_once 'piiUtil/PIIUtils.php';
1516
require_once 'util/AppendixProvider.php';
17+
require_once 'util/RequestAdaptor.php';
1618

1719
final class ParamBuilder
1820
{
@@ -69,7 +71,8 @@ public function __construct(
6971
}
7072
}
7173

72-
private function validateAppendix($appendix_value) {
74+
private function validateAppendix($appendix_value)
75+
{
7376
$appendix_length = strlen($appendix_value);
7477

7578
// Backward compatible V1 format: 2-character language token
@@ -291,6 +294,25 @@ public function processRequest(
291294
return $this->cookies_to_set_array;
292295
}
293296

297+
public function processRequestFromContext($context = null)
298+
{
299+
// 1. Normalize input into PlainDataObject
300+
$data = ($context instanceof PlainDataObject)
301+
? $context
302+
: RequestAdaptor::extract($context);
303+
304+
// 2. Delegate to the existing API
305+
// This prevents code duplication by reusing existing logic.
306+
return $this->processRequest(
307+
$data->host,
308+
$data->query_params,
309+
$data->cookies,
310+
$data->referer,
311+
$data->x_forwarded_for,
312+
$data->remote_address
313+
);
314+
}
315+
294316
public function getCookiesToSet()
295317
{
296318
return $this->cookies_to_set_array;

0 commit comments

Comments
 (0)