Beispiel #1
0
 /**
  * @param ScrapedItemBag $item
  */
 protected function scrapeItem(ScrapedItemBag $item)
 {
     try {
         $this->parser->parse($item);
         $source = $this->handler->handle($item);
         $this->eventDispatcher->dispatch(ScraperEvents::ITEM_SUCCESS, new SuccessItemEvent($this, $item, $source));
     } catch (FilterException $e) {
         $this->eventDispatcher->dispatch(ScraperEvents::ITEM_SKIPPED, new SkippedItemEvent($this, $item, $e->getMessage()));
     } catch (ValidationException $e) {
         $this->eventDispatcher->dispatch(ScraperEvents::ITEM_FAILED, new FailedItemEvent($this, $item, $e->getMessage()));
     } catch (FailedItemException $e) {
         $this->eventDispatcher->dispatch(ScraperEvents::ITEM_FAILED, new FailedItemEvent($this, $item, $e->getMessage()));
     } catch (ModificationException $e) {
         if ($e->getPrevious()) {
             $e = $e->getPrevious();
         }
         $this->eventDispatcher->dispatch(ScraperEvents::ITEM_FAILED, new FailedItemEvent($this, $item, $e->getMessage()));
     }
 }