예제 #1
0
 /**
  * @param $idSite
  * @param $period
  * @param $date
  * @return Request[]
  */
 private function getUrlsWithSegment($idSite, $period, $date)
 {
     $urlsWithSegment = array();
     $segmentsForSite = $this->getSegmentsForSite($idSite, $period);
     $segments = array();
     foreach ($segmentsForSite as $segment) {
         if ($this->shouldSkipSegmentArchiving($segment)) {
             $this->logger->info("- skipping segment archiving for '{segment}'.", array('segment' => $segment));
             continue;
         }
         $segments[] = $segment;
     }
     $segmentCount = count($segments);
     $processedSegmentCount = 0;
     foreach ($segments as $segment) {
         $dateParamForSegment = $this->segmentArchivingRequestUrlProvider->getUrlParameterDateString($idSite, $period, $date, $segment);
         $urlWithSegment = $this->getVisitsRequestUrl($idSite, $period, $dateParamForSegment, $segment);
         $urlWithSegment = $this->makeRequestUrl($urlWithSegment);
         $request = new Request($urlWithSegment);
         $logger = $this->logger;
         $request->before(function () use($logger, $segment, $segmentCount, &$processedSegmentCount) {
             $processedSegmentCount++;
             $logger->info(sprintf('- pre-processing segment %d/%d %s', $processedSegmentCount, $segmentCount, $segment));
         });
         $urlsWithSegment[] = $request;
     }
     return $urlsWithSegment;
 }
예제 #2
0
 public function test_shouldSupportRequestObjects()
 {
     $wasCalled = false;
     $request = new Request('url');
     $request->before(function () use(&$wasCalled) {
         $wasCalled = true;
     });
     $this->cliMulti->request(array($request));
     $this->assertTrue($wasCalled, 'The request "before" handler was not called');
 }