78 $this->decodedBody =
$response->getDecodedBody();
107 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphAchievement');
119 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphAlbum');
131 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphPage');
143 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphSessionInfo');
155 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphUser');
167 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphEvent');
179 return $this->
makeGraphNode(static::BASE_GRAPH_OBJECT_PREFIX .
'GraphGroup');
197 if ($subclassName && $auto_prefix) {
198 $subclassName = static::BASE_GRAPH_OBJECT_PREFIX . $subclassName;
211 if (!is_array($this->decodedBody)) {
223 if (isset($this->decodedBody[
'data']) && static::isCastableAsGraphEdge($this->decodedBody[
'data'])) {
225 'Unable to convert response from Graph to a GraphNode because the response looks like a GraphEdge. Try using GraphNodeFactory::makeGraphEdge() instead.',
238 if (!(isset($this->decodedBody[
'data']) && static::isCastableAsGraphEdge($this->decodedBody[
'data']))) {
240 'Unable to convert response from Graph to a GraphEdge because the response does not look like a GraphEdge. Try using GraphNodeFactory::makeGraphNode() instead.',
258 $subclassName = $subclassName ?: static::BASE_GRAPH_NODE_CLASS;
259 static::validateSubclass($subclassName);
262 $parentNodeId = isset($data[
'id']) ? $data[
'id'] :
null;
266 foreach ($data
as $k => $v) {
272 $graphObjectMap = $subclassName::getObjectMap();
273 $objectSubClass = isset($graphObjectMap[$k])
274 ? $graphObjectMap[$k]
284 return new $subclassName($items);
301 if (isset($data[
'data'])) {
303 if (static::isCastableAsGraphEdge($data[
'data'])) {
307 $data = $data[
'data'];
326 public function safelyMakeGraphEdge(array $data, $subclassName =
null, $parentKey =
null, $parentNodeId =
null)
328 if (!isset($data[
'data'])) {
333 foreach ($data[
'data']
as $graphNode) {
340 $parentGraphEdgeEndpoint = $parentNodeId && $parentKey ?
'/' . $parentNodeId .
'/' . $parentKey :
null;
341 $className = static::BASE_GRAPH_EDGE_CLASS;
343 return new $className($this->response->getRequest(), $dataList, $metaData, $parentGraphEdgeEndpoint, $subclassName);
355 unset($data[
'data']);
374 return array_keys($data) === range(0, count($data) - 1);
386 if ($subclassName == static::BASE_GRAPH_NODE_CLASS || is_subclass_of($subclassName, static::BASE_GRAPH_NODE_CLASS)) {
390 throw new FacebookSDKException(
'The given subclass "' . $subclassName .
'" is not valid. Cannot cast to an object that is not a GraphNode subclass.', 620);