summaryrefslogtreecommitdiff
path: root/lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php')
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php b/lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php
index 5ea765e..8e1464c 100644
--- a/lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php
+++ b/lib/facebook-graph-sdk/src/Facebook/FacebookBatchResponse.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
@@ -102,7 +102,8 @@ class FacebookBatchResponse extends FacebookResponse implements IteratorAggregat
$httpResponseBody = isset($response['body']) ? $response['body'] : null;
$httpResponseCode = isset($response['code']) ? $response['code'] : null;
- $httpResponseHeaders = isset($response['headers']) ? $response['headers'] : [];
+ // @TODO With PHP 5.5 support, this becomes array_column($response['headers'], 'value', 'name')
+ $httpResponseHeaders = isset($response['headers']) ? $this->normalizeBatchHeaders($response['headers']) : [];
$this->responses[$originalRequestName] = new FacebookResponse(
$originalRequest,
@@ -151,4 +152,23 @@ class FacebookBatchResponse extends FacebookResponse implements IteratorAggregat
{
return isset($this->responses[$offset]) ? $this->responses[$offset] : null;
}
+
+ /**
+ * Converts the batch header array into a standard format.
+ * @TODO replace with array_column() when PHP 5.5 is supported.
+ *
+ * @param array $batchHeaders
+ *
+ * @return array
+ */
+ private function normalizeBatchHeaders(array $batchHeaders)
+ {
+ $headers = [];
+
+ foreach ($batchHeaders as $header) {
+ $headers[$header['name']] = $header['value'];
+ }
+
+ return $headers;
+ }
}