Retrieve all entries of one feed

@param Request        $request
@param FeedInterface $feed
@param int           $offset_start
@param int           $how_many
@return array
162555
private function listPublicationsEntries(Request $request, FeedInterface $feed, $offset_start = 0, $how_many = 5)
    {
        return array_map(function ($entry) use ($request) {
            return $this->listPublicationEntry($request, $entry);
        }, $feed->getEntries()->slice($offset_start, $how_many));
    }
909197
public function getCollectionAction(Request $request, $start, $count)
    {
        $mediafolder = null;
        $folderUid = $request->get('mediaFolder_uid', null);

        if (null === $folderUid) {
            $mediafolder = $this->getMediaFolderRepository()->getRoot();
        } else {
            $mediafolder = $this->getMediaFolderRepository()->find($folderUid);
        }

        if (null === $mediafolder) {
            throw new NotFoundHttpException('Cannot find a media folder');
        }

        $paginator = null;

        if ($request->query->has('content_uid')) {
            $paginator = $this->getCollectionByContent($request->query->get('content_uid'), $mediafolder);
        } else {
            $paginator = $this->getClassicCollection($request, $mediafolder, $start, $count);
        }

        $iterator = $paginator->getIterator();
        $results = [];
        while ($iterator->valid()) {

            if($this->isGranted('VIEW', $iterator->current()->getMediaFolder())){

                $results[] = $iterator->current();
            }

            $iterator->next();
        }

        $pager = $request->query->has('usePagination') ? $paginator : null;

        return $this->addRangeToContent(
            $this->createJsonResponse($this->mediaToJson($results)),
            $pager,
            $start,
            count($results)
        );
    }
1158055
public function find_feed($url, $http_function = false)
    {
        // using google feed API
        $url = "http://ajax.googleapis.com/ajax/services/feed/lookup?key={$this->google_key}&v=1.0&q=" . urlencode($url);
        // fetch the content
        if ($http_function) {
            $response = $http_function($url);
        } else {
            $response = $this->http($url);
        }

        $result = json_decode($response, true);
        $rss_url = $result['responseData']['url'];

        return $rss_url;
    }
1230614
public function listAction(Request $request)
    {
        $limit = $request->get('limit', 25);
        $start = $request->get('start', 0);
        $sort = $request->get('sort', 'createdAt');
        $dir = $request->get('dir', 'DESC');
        $filter = $request->get('filter', null);

        if ($filter) {
            $filter = json_decode($filter, true);
        }

        if (!is_array($filter)) {
            $filter = [];
        }

        $messageManager = $this->get('phlexible_message.message_manager');

        $priorityList = $messageManager->getPriorityNames();
        $typeList = $messageManager->getTypeNames();

        $priorityFilter = [];
        $typeFilter = [];
        $channelFilter = [];
        $roleFilter = [];

        $criteria = new Criteria();
        foreach ($filter as $key => $value) {
            if ($key === 'subject' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_SUBJECT_LIKE, $value);
            } elseif ($key === 'text' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_BODY_LIKE, $value);
            } elseif (substr($key, 0, 9) === 'priority_') {
                $priorityFilter[] = substr($key, 9);
            } elseif (substr($key, 0, 5) === 'type_') {
                $typeFilter[] = substr($key, 5);
            } elseif (substr($key, 0, 8) === 'channel_') {
                $channelFilter[] = substr($key, 8);
            } elseif (substr($key, 0, 5) === 'role_') {
                $roleFilter[] = substr($key, 9);
            } elseif ($key === 'date_after' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_START_DATE, $value);
            } elseif ($key === 'date_before' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_END_DATE, $value);
            }
        }

        if (count($priorityFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_PRIORITY_IN,
                implode(',', $priorityFilter)
            );
        }

        if (count($typeFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_TYPE_IN,
                implode(',', $typeFilter)
            );
        }

        if (count($channelFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_CHANNEL_IN,
                implode(',', $channelFilter)
            );
        }

        if (count($roleFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_ROLE_IN,
                implode(',', $roleFilter)
            );
        }

        $count = $messageManager->countByCriteria($criteria);
        $messages = $messageManager->findByCriteria($criteria, [$sort => $dir], $limit, $start);

        $data = [];
        foreach ($messages as $message) {
            $data[] = [
                'subject' => $message->getSubject(),
                'body' => nl2br($message->getBody()),
                'priority' => $priorityList[$message->getPriority()],
                'type' => $typeList[$message->getType()],
                'channel' => $message->getChannel(),
                'role' => $message->getRole(),
                'user' => $message->getUser(),
                'createdAt' => $message->getCreatedAt()->format('Y-m-d H:i:s'),
            ];
        }

        return new JsonResponse([
            'totalCount' => $count,
            'messages' => $data,
            'facets' => $messageManager->getFacetsByCriteria($criteria),
        ]);
    }
582528
function it_should_return_feed($post1, $post2) {

        $postData1 = ['foo' => 'bar'];
        $postData2 = ['foo' => 'baz'];

        $this->client->get(Argument::any(), Argument::any())->willReturn([
            'data' => array(
                0 => $postData1,
                1 => $postData2
            ),
            'paging' => array(
                "previous" => "https://graph.facebook.com/page_id/posts?since=1433776347&limit=25&__paging_token=enc_AdBJBmZACKRKhWZCfUEwnRGw8jGfFZCGl2EiYxebr461J81BIsIRwu69lD0DmRZCix9Pj5ULR0SdfOu16UkN5ZAQB9xJl&__previous=1",
                "next" => "https://graph.facebook.com/page_id/posts?until=1433776347&limit=25&__paging_token=enc_AdBJBmZACKRKhWZCfUEwnRGw8jGfFZCGl2EiYxebr461J81BIsIRwu69lD0DmRZCix9Pj5ULR0SdfOu16UkN5ZAQB9xJl"
            )
        ]);

        $this->factory->create($postData1)->willReturn($post1);
        $this->factory->create($postData2)->willReturn($post2);

        $this->get(array(
            'page_id' => '12334533434'
        ))->shouldHaveType('Lns\SocialFeed\Model\ResultSet');
    }
272090
public function split(int $buffer, int $max, int $offsetStart = 0): iterable
    {
        for ($offset = $offsetStart; $offset < $max; $offset += $buffer) {
            yield $offset => $this->offset($offset)->limit($buffer);
        }
    }
151702
public function feedAction(Request $request, Blog $blog)
    {
        $articles = $blog->getPublishedArticles();
        if ($categoryId = $request->query->get('category')) {
            $entityManager = $this->getDoctrine()->getManager();
            /** @var Category $category */
            $category = $entityManager->getRepository('VictoireBlogBundle:BlogCategory')->find($categoryId);
            $categoryIds = [];

            function findIds(BlogCategory $category, &$categoryIds)
            {
                $categoryIds[] = $category->getId();

                foreach ($category->getChildren() as $childCategory) {
                    findIds($childCategory, $categoryIds);
                }
            }

            findIds($category, $categoryIds);

            $articles = $articles->filter(function ($article) use ($categoryIds) {
                /* @var Article $article */
                return $article->getCategory() && in_array($article->getCategory()->getId(), $categoryIds, true);
            });
        }

        return $this->render('VictoireBlogBundle:Blog:feed.rss.twig', [
            'blog'     => $blog,
            'articles' => $articles,
        ]);
    }
952672
protected function _process(HttpResponse $response, $query, $source)
    {
        $feed = Converter::toArray($response->body());
        $clean = array();

        if (!empty($query['root']) && !empty($feed[$query['feed']['root']])) {
            $items = $feed[$query['feed']['root']];
        } else {
            // RSS
            if (isset($feed['channel']) && isset($feed['channel']['item'])) {
                $items = $feed['channel']['item'];
                // RDF
            } else if (isset($feed['item'])) {
                $items = $feed['item'];
                // Atom
            } else if (isset($feed['entry'])) {
                $items = $feed['entry'];
                // XML
            } else {
                $items = $feed;
            }
        }

        if (empty($items) || !is_array($items)) {
            return $clean;
        }

        // Gather elements
        $elements = array(
            'title' => array('title'),
            'guid' => array('guid', 'id'),
            'date' => array('date', 'pubDate', 'published', 'updated'),
            'link' => array('link', 'origLink'),
            'image' => array('image', 'thumbnail'),
            'author' => array('author', 'writer', 'editor', 'user'),
            'source' => array('source'),
            'description' => array('description', 'desc', 'summary', 'content', 'text')
        );

        if (is_array($query['fields'])) {
            $elements = array_merge_recursive($elements, $query['fields']);
        }

        // Loop the feed
        foreach ($items as $item) {
            $data = array();

            foreach ($elements as $element => $keys) {
                if (isset($keys['attributes'])) {
                    $attributes = $keys['attributes'];
                    unset($keys['attributes']);
                } else {
                    $attributes = array('value', 'href', 'src', 'name', 'label');
                }

                if (isset($keys['keys'])) {
                    $keys = $keys['keys'];
                }

                foreach ($keys as $key) {
                    if (isset($item[$key]) && empty($data[$element])) {
                        if ($value = $this->_extract($item[$key], $attributes)) {
                            $data[$element] = $value;
                            break;
                        }
                    }
                }
            }

            if (empty($data['link'])) {
                trigger_error(sprintf('Feed %s does not have a valid link element', $source), E_USER_NOTICE);
                continue;
            }

            if (empty($data['source']) && $source) {
                $data['source'] = (string)$source;
            }

            // Determine how to sort
            $sortBy = $query['feed']['sort'];

            if (isset($data[$sortBy])) {
                $sort = $data[$sortBy];
            } else if (isset($data['date'])) {
                $sort = $data['date'];
            } else {
                $sort = null;
            }

            if ($sortBy === 'date' && $sort) {
                $sort = strtotime($sort);
            } else if (!$sort) {
                $sort = microtime();
            }

            if ($data) {
                $clean[$sort] = $data;
            }
        }

        return $clean;
    }
354515
public function getActivities($offset = 0, $limit = 20, $options = [], $enrich=false, $reactions = null)
    {
        if($options === null){
            $options = [];
        }
        $query_params = ['offset' => $offset, 'limit' => $limit];
        if (array_key_exists('mark_read', $options) && is_array($options['mark_read'])) {
            $options['mark_read'] = implode(',', $options['mark_read']);
        }
        if (array_key_exists('mark_seen', $options) && is_array($options['mark_seen'])) {
            $options['mark_seen'] = implode(',', $options['mark_seen']);
        }
        $query_params = array_merge($query_params, $options);

        if($reactions !== null){
            if(!is_array($reactions)){
                throw new StreamFeedException("reactions argument should be an associative array");
            }
            if(isset($reactions["own"]) && $reactions["own"]){
                $query_params["withOwnReactions"] = true;
                $enrich = true;
            }
            if(isset($reactions["recent"]) && $reactions["recent"]){
                $query_params["withRecentReactions"] = true;
                $enrich = true;
            }
            if(isset($reactions["counts"]) && $reactions["counts"]){
                $query_params["withReactionCounts"] = true;
                $enrich = true;
            }
        }

        $prefix_enrich = $enrich ? 'enrich/' : '';

        return $this->makeHttpRequest("{$prefix_enrich}{$this->base_feed_url}/", 'GET', null, $query_params, 'feed', 'read');
    }
323071
protected function _truncate($feed, $count = null) {
        if (!$feed) {
            return $feed;
        }

        if ($count === null) {
            $count = 20;
        }

        if ($count && count($feed) > $count) {
            $feed = array_slice($feed, 0, $count);
        }

        return array_values($feed);
    }
1136704
final public function startGetCategories(
        $limit = null,
        $offset = null,
        array $uids = array(),
        $responseType = 'xml'
    ) {
        switch ($responseType) {
            default:
            case 'xml':
                $this->buffer->setFile($this->config->getCategoriesXmlPath());
                break;

            case 'json':
                $this->buffer->setFile($this->config->getCategoriesJsonPath());
                break;
        }

        $this->createCategories($limit, $offset, $uids);
        $this->buffer->finish();
    }
1328897
async def get_feed(config, url):
    

    LOGGER.debug("++WAIT: cache get feed %s", url)
    previous = config.cache.get(
        'feed', url, schema_version=SCHEMA_VERSION) if config.cache else None
    LOGGER.debug("++DONE: cache get feed %s", url)

    headers = previous.caching if previous else None

    LOGGER.debug("++WAIT: request get %s", url)
    request = await utils.retry_get(config, url, headers=headers)
    LOGGER.debug("++DONE: request get %s", url)
    if not request or not request.success:
        LOGGER.error("Could not get feed %s: %d",
                     url,
                     request.status if request else -1)
        return None, previous, False

    if request.cached:
        LOGGER.debug("%s: Reusing cached version", url)
        return previous, previous, False

    current = Feed(request)

    if config.cache:
        LOGGER.debug("%s: Saving to cache", url)
        LOGGER.debug("++WAIT: cache set feed %s", url)
        config.cache.set('feed', url, current)
        LOGGER.debug("++DONE: cache set feed %s", url)

    LOGGER.debug("%s: Returning new content", url)
    return current, previous, (not previous
                               or current.digest != previous.digest
                               or current.status != previous.status)
718485
public function getSeatUserList(Request $request)
    {

        return response()->json([
            'results' => DB::table('users')
                ->select('id', 'name as text')
                ->where('name', 'like', '%' . $request->q . '%')
                ->orderBy('name', 'asc')
                ->get(),
        ]);
    }
358670
public function processRequest($request,$rowIndex ='row'){
		$requestResult = array();
		$result = $this->execute($request);
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$index = $rowIndex.$i++;
			$requestResult[$index] = $row;
		}
		return $requestResult;
	}
433761
public function getAllFeeds()
    {
        $rest = $this->callService('GET', self::API_DOWNLOAD_FEEDS);

        return $rest->getModels(models\Download\Feed\DownloadFeed::class);
    }
337962
public function getLists($offset = 0, $limit = 100)
	{
		$lists = [];
		foreach ($this->client->get("lists?offset={$offset}&limit={$limit}") as $list) {
			$lists[] = new Resources\MailingList($this, $list);
		}
		return $lists;
	}
1057708
private static List<FeedItem> getFeedItems(AdWordsServicesInterface adWordsServices,
      AdWordsSession session, Feed feed) throws RemoteException {
    // Get the FeedItemService.
    FeedItemServiceInterface feedItemService =
        adWordsServices.get(session, FeedItemServiceInterface.class);
    String query = String.format(
        "SELECT FeedItemId, AttributeValues WHERE Status = 'ENABLED' AND FeedId = %d",
        feed.getId());

    List<FeedItem> feedItems = new ArrayList<>();
    int offset = 0;
    FeedItemPage feedItemPage;

    do {
      String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
      feedItemPage = feedItemService.query(pageQuery);
      if (feedItemPage.getEntries() != null) {
        feedItems.addAll(Arrays.asList(feedItemPage.getEntries()));
      }
      offset += PAGE_SIZE;
    } while (offset < feedItemPage.getTotalNumEntries());

    return feedItems;
  }