Piwik\ArchiveProcessor\Rules::isSegmentPreProcessed PHP Méthode

isSegmentPreProcessed() public static méthode

public static isSegmentPreProcessed ( array $idSites, Segment $segment ) : boolean
$idSites array
$segment Piwik\Segment
Résultat boolean
    public static function isSegmentPreProcessed(array $idSites, Segment $segment)
    {
        $segmentsToProcess = self::getSegmentsToProcess($idSites);
        if (empty($segmentsToProcess)) {
            return false;
        }
        // If the requested segment is one of the segments to pre-process
        // we ensure that any call to the API will trigger archiving of all reports for this segment
        $segment = $segment->getString();
        // Turns out the getString() above returns the URL decoded segment string
        $segmentsToProcessUrlDecoded = array_map('urldecode', $segmentsToProcess);
        return in_array($segment, $segmentsToProcess) || in_array($segment, $segmentsToProcessUrlDecoded);
    }

Usage Example

Exemple #1
0
 /**
  * Detects whether the Piwik instance is configured to be able to archive this segment. It checks whether the segment
  * will be either archived via browser or cli archiving. It does not check if the segment has been archived. If you
  * want to know whether the segment has been archived, the actual report data needs to be requested.
  *
  * This method does not take any date/period into consideration. Meaning a Piwik instance might be able to archive
  * this segment in general, but not for a certain period if eg the archiving of range dates is disabled.
  *
  * @return bool
  */
 public function willBeArchived()
 {
     if ($this->isEmpty()) {
         return true;
     }
     $idSites = $this->idSites;
     if (!is_array($idSites)) {
         $idSites = array($this->idSites);
     }
     return Rules::isRequestAuthorizedToArchive() || Rules::isBrowserArchivingAvailableForSegments() || Rules::isSegmentPreProcessed($idSites, $this);
 }