EntityReferenceRevisionsCommands.php in Entity Reference Revisions 8
File
src/Commands/EntityReferenceRevisionsCommands.php
View source
<?php
namespace Drupal\entity_reference_revisions\Commands;
use Drupal\entity_reference_revisions\EntityReferenceRevisionsOrphanPurger;
use Drush\Commands\DrushCommands;
use Drush\Drush;
use Drush\Utils\StringUtils;
class EntityReferenceRevisionsCommands extends DrushCommands {
protected $purger;
public function __construct(EntityReferenceRevisionsOrphanPurger $purger) {
$this->purger = $purger;
}
public function purge($types) {
$this->purger
->setBatch(StringUtils::csvToArray($types));
drush_backend_batch_process();
}
public function interact($input, $output) {
if (empty($input
->getArgument('types'))) {
$choices = [];
foreach ($this->purger
->getCompositeEntityTypes() as $entity_type) {
$choices[(string) $entity_type
->id()] = (string) $entity_type
->getLabel();
}
$selected = $this
->io()
->choice(dt("Choose the entity type to clear"), $choices);
$input
->setArgument('types', $selected);
}
}
}