Ejemplo n.º 1
0
 public function checkAndProxyEvent(CrawlerRequestEvent $event, $name)
 {
     $uri = $event->getRequest()->getUri();
     if ($this->matcher->matches($uri)) {
         $this->dispatcher->dispatch($name, $event);
     }
 }
Ejemplo n.º 2
0
 /**
  * Act on a URL discovery event.
  *
  * @param \LastCall\Crawler\Event\CrawlerUrisDiscoveredEvent $event
  */
 public function onDiscovery(CrawlerUrisDiscoveredEvent $event)
 {
     $factory = $this->requestFactory;
     foreach ($event->getDiscoveredUris() as $uri) {
         if ($this->matcher->matches($uri) && ($request = $factory($uri))) {
             $event->addAdditionalRequest($request);
         }
     }
 }
Ejemplo n.º 3
0
 public function normalize(UriInterface $uri)
 {
     if ($this->matcher) {
         if (!$this->matcher->matches($uri)) {
             return $uri;
         }
     }
     do {
         $str = (string) $uri;
         foreach ($this->handlers as $handler) {
             $uri = $handler($uri);
         }
         $newStr = (string) $uri;
     } while ($str !== $newStr);
     return $uri;
 }