From 4b8a9a5189a625bf99fedec7fd31f6e146410a14 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 26 Apr 2018 01:00:12 +0200 Subject: Update FB API library --- .../src/Facebook/GraphNodes/GraphEdge.php | 44 +++++++++------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphEdge.php') diff --git a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphEdge.php b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphEdge.php index 95f3284..f6f4970 100644 --- a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphEdge.php +++ b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphEdge.php @@ -1,6 +1,6 @@ validateForPagination(); // Do we have a paging URL? - if (isset($this->metaData['paging'][$direction])) { - // Graph returns the full URL with all the original params. - // We just want the endpoint though. - $pageUrl = $this->metaData['paging'][$direction]; - - return FacebookUrlManipulator::baseGraphUrlEndpoint($pageUrl); - } - - // Do we have a cursor to work with? - $cursorDirection = $direction === 'next' ? 'after' : 'before'; - $cursor = $this->getCursor($cursorDirection); - if (!$cursor) { - return null; - } - - // If we don't know the ID of the parent node, this ain't gonna work. - if (!$this->parentEdgeEndpoint) { + if (!isset($this->metaData['paging'][$direction])) { return null; } - // We have the parent node ID, paging cursor & original request. - // These were the ingredients chosen to create the perfect little URL. - $pageUrl = $this->parentEdgeEndpoint . '?' . $cursorDirection . '=' . urlencode($cursor); + $pageUrl = $this->metaData['paging'][$direction]; - // Pull in the original params - $originalUrl = $this->request->getUrl(); - $pageUrl = FacebookUrlManipulator::mergeUrlParams($originalUrl, $pageUrl); - - return FacebookUrlManipulator::forceSlashPrefix($pageUrl); + return FacebookUrlManipulator::baseGraphUrlEndpoint($pageUrl); } /** @@ -257,4 +235,18 @@ class GraphEdge extends Collection return null; } + + /** + * @inheritDoc + */ + public function map(\Closure $callback) + { + return new static( + $this->request, + array_map($callback, $this->items, array_keys($this->items)), + $this->metaData, + $this->parentEdgeEndpoint, + $this->subclassName + ); + } } -- cgit v1.2.3