6 use Harvest\ETL\Factory;
8 use Harvest\ResultInterpreter;
9 use Symfony\Component\Console\Helper\Table;
10 use Symfony\Component\Console\Output\ConsoleOutput;
22 private function getHarvester($id) {
24 if (!method_exists($this,
'getHarvestPlan')) {
25 throw new \Exception(
"Drupal\dkan_harvest\Drush\Helper requires the host to implement the getHarvestPlan method.");
28 return new Harvester(
new Factory($this->getHarvestPlan($id),
29 $this->getStorage($id,
"item"),
30 $this->getStorage($id,
"hash")));
36 private function getPlanStorage() {
37 $connection = \Drupal::service(
'database');
38 return new DatabaseTable($connection,
"harvest_plans");
44 private function getStorage($id, $type) {
45 $connection = \Drupal::service(
'database');
46 return new DatabaseTable($connection,
"harvest_{$id}_{$type}");
52 private function renderResult($result) {
53 $interpreter =
new ResultInterpreter($result);
55 $table =
new Table(
new ConsoleOutput());
56 $table->setHeaders([
'processed',
'created',
'updated',
'errors']);
58 $interpreter->countProcessed(),
59 $interpreter->countCreated(),
60 $interpreter->countUpdated(),
61 $interpreter->countFailed(),