Skip to content

Commit

Permalink
Modules errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mediashare committed Sep 27, 2021
1 parent 5dd739f commit 8c654dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Entity/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ public function __construct(Webspider $webspider) {
$this->config = $webspider->config;
$this->crawler = $webspider->crawler;
$this->modules = $webspider->crawler->modules;
unset($webspider->crawler->modules);
$this->errors = $webspider->errors;
foreach ($this->modules ?? [] as $modules):
foreach ($modules ?? [] as $module):
$this->errors = array_merge($this->errors, $module['errors'] ?? []);
endforeach;
endforeach;
unset($webspider->crawler->modules);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function run(Scraper $scraper) {
$module->header = $scraper->webpage->getHeader();
$results[$module->name][] = $module->run();
if (!empty($module->errors)):
$this->errors[$module->name][] = $module->errors;
$results[$module->name]['errors'] = array_merge($results['errors'] ?? [], $module->errors ?? []);
endif;
$scraper->webpage->getBody()->setContent(""); // Reset body content for memory optimization.
}
Expand Down

0 comments on commit 8c654dd

Please sign in to comment.