Piwik\SettingsPiwik::getKnownSegmentsToArchive PHP Метод

getKnownSegmentsToArchive() публичный статический Метод

Returns every stored segment to pre-process for each site during cron archiving.
public static getKnownSegmentsToArchive ( ) : array
Результат array The list of stored segments that apply to all sites.
    public static function getKnownSegmentsToArchive()
    {
        $cacheId = 'KnownSegmentsToArchive';
        $cache = PiwikCache::getTransientCache();
        if ($cache->contains($cacheId)) {
            return $cache->fetch($cacheId);
        }
        $segments = Config::getInstance()->Segments;
        $segmentsToProcess = isset($segments['Segments']) ? $segments['Segments'] : array();
        /**
         * Triggered during the cron archiving process to collect segments that
         * should be pre-processed for all websites. The archiving process will be launched
         * for each of these segments when archiving data.
         *
         * This event can be used to add segments to be pre-processed. If your plugin depends
         * on data from a specific segment, this event could be used to provide enhanced
         * performance.
         *
         * _Note: If you just want to add a segment that is managed by the user, use the
         * SegmentEditor API._
         *
         * **Example**
         *
         *     Piwik::addAction('Segments.getKnownSegmentsToArchiveAllSites', function (&$segments) {
         *         $segments[] = 'country=jp;city=Tokyo';
         *     });
         *
         * @param array &$segmentsToProcess List of segment definitions, eg,
         *
         *                                      array(
         *                                          'browserCode=ff;resolution=800x600',
         *                                          'country=jp;city=Tokyo'
         *                                      )
         *
         *                                  Add segments to this array in your event handler.
         */
        Piwik::postEvent('Segments.getKnownSegmentsToArchiveAllSites', array(&$segmentsToProcess));
        $segmentsToProcess = array_unique($segmentsToProcess);
        $cache->save($cacheId, $segmentsToProcess);
        return $segmentsToProcess;
    }

Usage Example

Пример #1
0
 /**
  * @param $idSites
  * @return array
  */
 private static function getSegmentsToProcess($idSites)
 {
     $knownSegmentsToArchiveAllSites = SettingsPiwik::getKnownSegmentsToArchive();
     $segmentsToProcess = $knownSegmentsToArchiveAllSites;
     foreach ($idSites as $idSite) {
         $segmentForThisWebsite = SettingsPiwik::getKnownSegmentsToArchiveForSite($idSite);
         $segmentsToProcess = array_merge($segmentsToProcess, $segmentForThisWebsite);
     }
     $segmentsToProcess = array_unique($segmentsToProcess);
     return $segmentsToProcess;
 }
All Usage Examples Of Piwik\SettingsPiwik::getKnownSegmentsToArchive