Skip to content

Commit

Permalink
Initial work on #14.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Dec 10, 2018
1 parent 0760e17 commit d8eb3d1
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parameters:
# To not register any fetchresourcelist plugins, use app.plugins.fetchresourcelist []
app.plugins.fetchresourcelist: ['app:riprap:plugin:fetchresourcelist:from:file']
app.plugins.fetchresourcelist.from.file.paths: ['resources/riprap_resource_ids.txt']
app.plugins.fetchresourcelist.from.drupal.baseurl: ['http://localhost:8000']

# To not register any fetchdigest plugins, use app.plugins.fetchdigest [].
# Currently we only allow one fetchdigest plugin per fixity event (i.e., this
Expand Down
61 changes: 61 additions & 0 deletions src/Command/PluginFetchResourceListFromDrupal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
// src/Command/PluginFetchResourceListFromDrupal.php
namespace App\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

use Psr\Log\LoggerInterface;

use App\Entity\Event;
use App\Service\FixityEventDetailManager;

class PluginFetchResourceListFromDrupal extends ContainerAwareCommand
{
private $params;

public function __construct(
ParameterBagInterface $params = null,
LoggerInterface $logger = null,
FixityEventDetailManager $event_detail = null
) {
$this->params = $params;
$this->input_files = $this->params->get('app.plugins.fetchresourcelist.from.drupal.baseurl');

$this->logger = $logger;
$this->event_detail = $event_detail;

parent::__construct();
}

protected function configure()
{
$this
->setName('app:riprap:plugin:fetchresourcelist:from:drupal')
->setDescription("A Riprap plugin for reading a list of resource URLs from Drupal's JSON:API. To use this plugin, that contrib module (https://www.drupal.org/project/jsonapi) needs to be installed on the source Drupal instance.");
}

protected function execute(InputInterface $input, OutputInterface $output)
{
// @todo: See https://github.com/mjordan/riprap/issues/14.

/*
foreach ($this->input_files as $input_file) {
$resource_ids = file($input_file, FILE_IGNORE_NEW_LINES);
foreach ($resource_ids as $resource_id) {
// This is a string containing one resource ID (URL) per line;
$output->writeln($resource_id);
}
}
*/


// $this->logger is null while testing.
if ($this->logger) {
$this->logger->info("PluginPersistToDatabase executed");
}
}
}

0 comments on commit d8eb3d1

Please sign in to comment.