Пример #1
0
 public function checkAndProxyEvent(CrawlerRequestEvent $event, $name)
 {
     $uri = $event->getRequest()->getUri();
     if ($this->matcher->matches($uri)) {
         $this->dispatcher->dispatch($name, $event);
     }
 }
Пример #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;
 }
Пример #4
0
 private function getUri(CrawlerRequestEvent $event)
 {
     return $event->getRequest()->getUri();
 }
 public function __construct(RequestInterface $request, ResponseInterface $response)
 {
     parent::__construct($request);
     $this->response = $response;
 }