1 | <?php |
||
37 | class FacebookBatchRequest extends FacebookRequest implements IteratorAggregate, ArrayAccess |
||
38 | { |
||
39 | /** |
||
40 | * @var array An array of FacebookRequest entities to send. |
||
41 | */ |
||
42 | protected $requests; |
||
43 | |||
44 | /** |
||
45 | * @var array An array of files to upload. |
||
46 | */ |
||
47 | protected $attachedFiles; |
||
48 | |||
49 | /** |
||
50 | * Creates a new Request entity. |
||
51 | * |
||
52 | * @param FacebookApp|null $app |
||
53 | * @param array $requests |
||
54 | * @param AccessToken|string|null $accessToken |
||
55 | * @param string|null $graphVersion |
||
56 | */ |
||
57 | public function __construct(FacebookApp $app = null, array $requests = [], $accessToken = null, $graphVersion = null) |
||
63 | |||
64 | /** |
||
65 | * A a new request to the array. |
||
66 | * |
||
67 | * @param FacebookRequest|array $request |
||
68 | * @param string|null $name |
||
69 | * |
||
70 | * @return FacebookBatchRequest |
||
71 | * |
||
72 | * @throws \InvalidArgumentException |
||
73 | */ |
||
74 | public function add($request, $name = null) |
||
103 | |||
104 | /** |
||
105 | * Ensures that the FacebookApp and access token fall back when missing. |
||
106 | * |
||
107 | * @param FacebookRequest $request |
||
108 | * |
||
109 | * @throws FacebookSDKException |
||
110 | */ |
||
111 | public function addFallbackDefaults(FacebookRequest $request) |
||
129 | |||
130 | /** |
||
131 | * Extracts the files from a request. |
||
132 | * |
||
133 | * @param FacebookRequest $request |
||
134 | * |
||
135 | * @return string|null |
||
136 | * |
||
137 | * @throws FacebookSDKException |
||
138 | */ |
||
139 | public function extractFileAttachments(FacebookRequest $request) |
||
158 | |||
159 | /** |
||
160 | * Return the FacebookRequest entities. |
||
161 | * |
||
162 | * @return array |
||
163 | */ |
||
164 | public function getRequests() |
||
168 | |||
169 | /** |
||
170 | * Prepares the requests to be sent as a batch request. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function prepareRequestsForBatch() |
||
184 | |||
185 | /** |
||
186 | * Converts the requests into a JSON(P) string. |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | public function convertRequestsToJson() |
||
200 | |||
201 | /** |
||
202 | * Validate the request count before sending them as a batch. |
||
203 | * |
||
204 | * @throws FacebookSDKException |
||
205 | */ |
||
206 | public function validateBatchRequestCount() |
||
216 | |||
217 | /** |
||
218 | * Converts a Request entity into an array that is batch-friendly. |
||
219 | * |
||
220 | * @param FacebookRequest $request The request entity to convert. |
||
221 | * @param string|null $requestName The name of the request. |
||
222 | * @param string|null $attachedFiles Names of files associated with the request. |
||
223 | * |
||
224 | * @return array |
||
225 | */ |
||
226 | public function requestEntityToBatchArray(FacebookRequest $request, $requestName = null, $attachedFiles = null) |
||
261 | |||
262 | /** |
||
263 | * Get an iterator for the items. |
||
264 | * |
||
265 | * @return ArrayIterator |
||
266 | */ |
||
267 | public function getIterator() |
||
271 | |||
272 | /** |
||
273 | * @inheritdoc |
||
274 | */ |
||
275 | public function offsetSet($offset, $value) |
||
279 | |||
280 | /** |
||
281 | * @inheritdoc |
||
282 | */ |
||
283 | public function offsetExists($offset) |
||
287 | |||
288 | /** |
||
289 | * @inheritdoc |
||
290 | */ |
||
291 | public function offsetUnset($offset) |
||
295 | |||
296 | /** |
||
297 | * @inheritdoc |
||
298 | */ |
||
299 | public function offsetGet($offset) |
||
303 | } |
||
304 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: