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 response event.
  *
  * @param \LastCall\Crawler\Event\CrawlerRequestEvent                 $event
  * @param                                                             $eventName
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
  */
 public function onEvent(CrawlerRequestEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     if ($event instanceof CrawlerResponseEvent) {
         // @todo: Detect HTML here.
         $htmlEvent = new CrawlerHtmlResponseEvent($event->getRequest(), $event->getResponse());
         $dispatcher->dispatch($eventName . '.html', $htmlEvent);
         foreach ($htmlEvent->getAdditionalRequests() as $request) {
             $event->addAdditionalRequest($request);
         }
     }
 }
 public function __construct(RequestInterface $request, ResponseInterface $response = null, \Exception $exception)
 {
     parent::__construct($request);
     $this->response = $response;
     $this->exception = $exception;
 }
Ejemplo n.º 4
0
 private function getUri(CrawlerRequestEvent $event)
 {
     return $event->getRequest()->getUri();
 }
Ejemplo n.º 5
0
 public function __construct(RequestInterface $request, ResponseInterface $response)
 {
     parent::__construct($request);
     $this->response = $response;
 }