-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDST-58: Added drush command for OAI rebuild
- Loading branch information
1 parent
65ed57e
commit 9c3d3d6
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Drupal\islandora_drush_utils\Commands; | ||
|
||
use Drupal\Core\Queue\QueueFactory; | ||
use Drush\Commands\DrushCommands; | ||
|
||
/** | ||
* RebuildOaiEntries commands. | ||
* | ||
* These commands rebuild the OAI entries and consume them. | ||
*/ | ||
class RebuildOaiEntries extends DrushCommands { | ||
|
||
/** | ||
* The queue service. | ||
* | ||
* @var \Drupal\Core\Queue\QueueFactory | ||
*/ | ||
protected $queue; | ||
|
||
/** | ||
* Set variables to used across commands. | ||
* | ||
* @param \Drupal\Core\Queue\QueueFactory $queue | ||
* The queue service. | ||
*/ | ||
public function __construct(QueueFactory $queue) { | ||
$this->queue = $queue; | ||
} | ||
|
||
/** | ||
* Rebuild OAI entries. | ||
* | ||
* @command islandora_drush_utils:rebuild-oai | ||
* @aliases idr:roai | ||
*/ | ||
public function rebuild() { | ||
rest_oai_pmh_cache_views(); | ||
|
||
$operations = []; | ||
$queue = $this->queue->get('rest_oai_pmh_views_cache_cron'); | ||
while ($item = $queue->claimItem()) { | ||
$operations[] = [ | ||
'rest_oai_pmh_process_queue', | ||
[$item], | ||
]; | ||
} | ||
$batch = [ | ||
'operations' => $operations, | ||
'finished' => 'rest_oai_pmh_batch_finished', | ||
'title' => 'Processing OAI rebuild', | ||
'init_message' => 'OAI rebuild is starting.', | ||
'progress_message' => 'Processed @current out of @total.', | ||
'error_message' => 'OAI rebuild has encountered an error.', | ||
]; | ||
|
||
batch_set($batch); | ||
drush_backend_batch_process(); | ||
} | ||
|
||
} |