Get the criteria for archive module.

@param array  $archives
@param int    $begin
@param int    $end
@param Module $module

@return NewsCriteria|null
176138
public function getCriteriaForArchiveModule(array $archives, $begin, $end, Module $module)
    {
        $criteria = new NewsCriteria($this->framework);

        try {
            $criteria->setBasicCriteria($archives, $module->news_order);

            // Set the time frame
            $criteria->setTimeFrame($begin, $end);

            // Set the regular list criteria
            $this->setRegularListCriteria($criteria, $module);
        } catch (NoNewsException $e) {
            return null;
        }

        return $criteria;
    }
180776
private function getCriteria(array $archives, $featured, ModuleNewsList $module)
    {
        try {
            $criteria = $this->searchBuilder->getCriteriaForListModule($archives, $featured, $module);
        } catch (CategoryNotFoundException $e) {
            throw new PageNotFoundException($e->getMessage());
        }

        return $criteria;
    }
301458
public function getTop($beginA, $endA, $beginB, $endB, $limit)
    {
        $playerListA = $this->playerRepository->getTop($beginA, $endA, $limit);
        $playerListB = $this->playerRepository->getTop($beginB, $endB, $limit);

        // Get old rank
        $oldRank = array();
        foreach ($playerListB as $key => $row) {
            $oldRank[$row['idPlayer']] = $key + 1;
        }

        $nbPostFromList = 0;
        for ($i=0, $nb=count($playerListA) - 1; $i <= $nb; ++$i) {
            $idPlayer = $playerListA[$i]['idPlayer'];
            if (isset($oldRank[$idPlayer])) {
                $playerListA[$i]['oldRank'] = $oldRank[$idPlayer];
            } else {
                $playerListA[$i]['oldRank'] = null;
            }

            $nbPostFromList += $playerListA[$i]['nb'];
        }

        $nbPlayer = $this->playerRepository->getTotalNbPlayer($beginA, $endA);
        $nbTotalPost = $this->playerRepository->getTotalNbPostDay($beginA, $endA);

        $playerList = \VideoGamesRecords\CoreBundle\Tools\Ranking::addRank(
            $playerListA,
            'rank',
            ['nb'],
            true
        );

        return array(
            'playerList' => $playerList,
            'nbPostFromList' => $nbPostFromList,
            'nbPlayer' => $nbPlayer,
            'nbTotalPost' => $nbTotalPost,
        );
    }
1366623
protected function findCheckCriteria($filepath, $criteria)
	{
		$match = true;
		$filename = basename($filepath);
		if ($match && isset($criteria['regexs'])) {
			if (!is_array($criteria['regexs'])) {
				$criteria['regexs'] = array($criteria['regexs']);
			}
			$match = false;
			foreach ($criteria['regexs'] as $regex) {
				if (preg_match($regex, $filename)) {
					$match = true;
					break;
				}
			}
		}
		if ($match && isset($criteria['mod_since'])) {
			$match = $criteria['mod_since'] < @filemtime($filepath);
		}
		if ($match && isset($criteria['mod_before'])) {
			$match = $criteria['mod_before'] > @filemtime($filepath);
		}
		if ($match && isset($criteria['contains'])) {
			$match = false;
			if (preg_match('/\.(.*?)$/', $filename, $matches)) {
				$extension = strtolower($matches[1]);
				if (in_array($extension, $criteria['search_extensions'])) {
					if ($contents = file_get_contents($filepath)) {
						$match = preg_match($criteria['contains'], $contents);
						unset($contents);
					}
				}
			}
		}
		return $match;
	}
1163055
public function getSchemaForEndpoint(string $endpoint): Schema
    {
        $this->verifySettings($endpoint);
        $endpointConfiguration = $this->endpointsConfiguration[$endpoint];

        if (isset($endpointConfiguration['querySchema'])) {
            $schemaConfig = SchemaConfig::create()
                ->setQuery($this->typeResolver->get($endpointConfiguration['querySchema']));
            if (isset($endpointConfiguration['mutationSchema'])) {
                $schemaConfig->setMutation($this->typeResolver->get($endpointConfiguration['mutationSchema']));
            }
            if (isset($endpointConfiguration['subscriptionSchema'])) {
                $schemaConfig->setSubscription($this->typeResolver->get($endpointConfiguration['subscriptionSchema']));
            }
            return new Schema($schemaConfig);
        }

        $cacheKey = urlencode($endpoint);
        if ($this->schemaCache->has($cacheKey)) {
            $documentNode = $this->schemaCache->get($cacheKey);
        } else {
            $schemaPathAndFilename = $endpointConfiguration['schema'];
            $content = Files::getFileContents($schemaPathAndFilename);
            $documentNode = Parser::parse($content);
            $this->schemaCache->set($cacheKey, $documentNode);
        }

        $resolverConfiguration = $endpointConfiguration['resolvers'] ?? [];
        $resolverPathPattern = $endpointConfiguration['resolverPathPattern'] ?? null;
        /** @var ResolverInterface[] $resolvers */
        $resolvers = [];
        return BuildSchema::build($documentNode, function ($config) use (&$resolvers, $resolverConfiguration, $resolverPathPattern) {
            $name = $config['name'];

            if (!isset($resolvers[$name])) {
                if (isset($resolverConfiguration[$name])) {
                    $resolvers[$name] = $this->objectManager->get($resolverConfiguration[$name]);
                } elseif ($resolverPathPattern !== null) {
                    $possibleResolverClassName = str_replace('{Type}', $name, $resolverPathPattern);
                    if ($this->objectManager->isRegistered($possibleResolverClassName)) {
                        $resolvers[$name] = $this->objectManager->get($possibleResolverClassName);
                    }
                }
            }
            if (isset($resolvers[$name])) {
                return $resolvers[$name]->decorateTypeConfig($config);
            }
            return $config;
        });
    }
148168
protected function getVisitsFilteredByDateRange(Carbon $start, Carbon $end)
    {
        return $this->getCachedVisits()->filter(function (VisitorActivity $visit) use ($start, $end) {
            return $visit->created_at->between($start, $end);
        });
    }
196949
protected function validateMetadataExtendSection(\OxidEsales\Eshop\Core\Module\Module $module)
    {
        $validator = $this->getModuleMetadataValidator();
        $validator->checkModuleExtensionsForIncorrectNamespaceClasses($module);
    }
859930
function archive($id)
    {
        $this->requestDecorator->setId($id  . '/archived');
        $result = $this->client->put($this->requestDecorator->makeResource(), $this->requestDecorator->makePayload(), $this->requestDecorator->makeHeaders());
        $this->refresh();
        return $result;
    }
1295656
public function createArchive($options = array(), $nameArchive = null, $mode = 'create')
    {
        $options = array_merge($options, ['target_public_id' => $nameArchive, 'mode' => $mode]);
        return $this->getUploader()->create_archive($options);
    }
445527
protected function fetchNewsItems($begin, $end, $limit = null, $offset = null)
    {
        if (($criteria = $this->getSearchCriteria($begin, $end)) === null) {
            return null;
        }

        $criteria->setLimit($limit);
        $criteria->setOffset($offset);

        return NewsModel::findBy($criteria->getColumns(), $criteria->getValues(), $criteria->getOptions());
	}
972945
@Override
    public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter,
        final ArchiveFormat archiveFormat) {
        Validate.notNull(type, "Type must be specified");
        Validate.notNull(filter, "Filter must be specified");
        Validate.notNull(archiveFormat, "ArchiveFormat must be specified");

        Collection<X> archives = new ArrayList<X>();

        Map<ArchivePath, Node> matches = getContent(filter);
        for (ArchivePath path : matches.keySet()) {
            archives.add(getAsType(type, path, archiveFormat));
        }
        return archives;
    }
792367
public static function getDecadesAgo($ago, $endDateTime = null)
    {
        return static::getDateTimeRange(
            Carbon::now()->subYears($ago * 10)->startOfDecade(),
            $endDateTime ?: Carbon::now()->subYears($ago * 10)->endOfDecade()
        );
    }
492129
def get_archives(self, title_id, language_code):
        
        logger.info('Getting archives for title %d and language %d', title_id, language_code)
        archives = []
        page = 1
        while True:
            # get the archive page
            url = self.server_url + 'util/carrega_legendas_busca_filme/{title}/{language}/-/{page}'.format(
                title=title_id, language=language_code, page=page)
            r = self.session.get(url)
            r.raise_for_status()

            # parse the results
            soup = ParserBeautifulSoup(r.content, ['lxml', 'html.parser'])
            for archive_soup in soup.select('div.list_element > article > div'):
                # create archive
                archive = LegendasTVArchive(archive_soup.a['href'].split('/')[2], archive_soup.a.text,
                                            'pack' in archive_soup['class'], 'destaque' in archive_soup['class'],
                                            self.server_url + archive_soup.a['href'][1:])

                # extract text containing downloads, rating and timestamp
                data_text = archive_soup.find('p', class_='data').text

                # match downloads
                archive.downloads = int(downloads_re.search(data_text).group('downloads'))

                # match rating
                match = rating_re.search(data_text)
                if match:
                    archive.rating = int(match.group('rating'))

                # match timestamp and validate it
                time_data = {k: int(v) for k, v in timestamp_re.search(data_text).groupdict().items()}
                archive.timestamp = pytz.timezone('America/Sao_Paulo').localize(datetime(**time_data))
                if archive.timestamp > datetime.utcnow().replace(tzinfo=pytz.utc):
                    raise ProviderError('Archive timestamp is in the future')

                # add archive
                archives.append(archive)

            # stop on last page
            if soup.find('a', attrs={'class': 'load_more'}, string='carregar mais') is None:
                break

            # increment page count
            page += 1

        logger.debug('Found %d archives', len(archives))

        return archives
884513
public function getCriteriaForListModule(array $archives, $featured, Module $module)
    {
        $criteria = new NewsCriteria($this->framework);

        try {
            $criteria->setBasicCriteria($archives, $module->news_order);

            // Set the featured filter
            if (null !== $featured) {
                $criteria->setFeatured($featured);
            }

            // Set the criteria for related categories
            if ($module->news_relatedCategories) {
                $this->setRelatedListCriteria($criteria, $module);
            } else {
                // Set the regular list criteria
                $this->setRegularListCriteria($criteria, $module);
            }
        } catch (NoNewsException $e) {
            return null;
        }

        return $criteria;
    }
689672
public function getAdverts($start, $end, $section=null)
    {
    
        if($count == 0){
            $count2 = 0;

            $qb2 = $this->getQueryBuilder() 
            ->join('a.located', 'l')
            ->where('l.name = :section')
            ->andWhere('a.from <= :start')
            ->andWhere('a.to >= :end')
            ->andWhere('a.active = :active')
            ->setParameters(array(
                'section' => $section, 
                'start' => $start, 
                'end' => $end,
                'active' => true,
                ));

            $query = $qb2->getQuery();
        }
        
        //->orderBy('s.day', 'ASC')
        $adverts = array();
        if(is_object($query)){
            $adverts = $query->getResult();
        }
        
        $arr = new \Doctrine\Common\Collections\ArrayCollection();
        foreach ($adverts as $ad) {
            $arr->add($ad);
        }
        
        return $arr;
    }
441616
protected static function range($query, $attribute, $start = null, $end = null)
    {
        if (!empty($start)) {
            $query = $query->andWhere(['>=', $attribute, $start]);
        }
        if (!empty($end)) {
            $query = $query->andWhere(['<', $attribute, $end]);
        }
        return $query;
    }
864254
final public function renderArchive(Request $request, array $criteria = [], array $parameters = [])
    {
        $pager = $this->postManager->getPager(
            $criteria,
            $request->get('page', 1)
        );

        $parameters = array_merge([
            'pager' => $pager,
            'blog' => $this->blog,
            'tag' => false,
            'collection' => false,
            'route' => $request->get('_route'),
            'route_parameters' => $request->get('_route_params'),
        ], $parameters);

        $response = $this->render(
            sprintf('@SonataNews/Post/archive.%s.twig', $request->getRequestFormat()),
            $parameters
        );

        if ('rss' === $request->getRequestFormat()) {
            $response->headers->set('Content-Type', 'application/rss+xml');
        }

        return $response;
    }