5 use Drush\Commands\DrushCommands;
6 use Symfony\Component\Console\Output\ConsoleOutput;
7 use Drupal\dkan_harvest\Drush\Helper;
21 $this->createDummyJson();
22 $harvester = $this->getHarvester(
"dummy");
23 $result = $harvester->harvest();
24 $this->renderResult($result);
33 public function remove() {
34 $harvester = $this->getHarvester(
"dummy");
35 $result = $harvester->revert();
39 $output =
new ConsoleOutput();
40 $output->write(
"{$count} items reverted for the 'dummy' harvest plan.");
46 private function getHarvestPlan() {
47 $module_path = DRUPAL_ROOT .
"/" . drupal_get_path(
'module',
'dkan_dummy_content');
49 $plan_path = $module_path .
"/harvest_plan.json";
50 $json = file_get_contents($plan_path);
51 $plan = json_decode($json);
53 $plan->extract->uri =
"file://" . $module_path . $plan->extract->uri;
61 private function createDummyJson() {
62 $dummy_template = DRUPAL_ROOT .
"/" . drupal_get_path(
'module',
'dkan_dummy_content') .
"/dummy.template.json";
63 $content = file_get_contents($dummy_template);
64 $new = $this->detokenize($content);
65 file_put_contents(DRUPAL_ROOT .
"/" . drupal_get_path(
'module',
'dkan_dummy_content') .
"/dummy.json", $new);
71 private function detokenize($content) {
72 $absolute_module_path = DRUPAL_ROOT .
"/" . drupal_get_path(
'module',
'dkan_dummy_content') .
"/files";
73 return str_replace(
"<!*path*!>", $absolute_module_path, $content);