class EntityReferenceRevisionsCommands in Entity Reference Revisions 8
A Drush commandfile.
Hierarchy
- class \Drupal\entity_reference_revisions\Commands\EntityReferenceRevisionsCommands extends \Drush\Commands\DrushCommands
Expanded class hierarchy of EntityReferenceRevisionsCommands
1 string reference to 'EntityReferenceRevisionsCommands'
1 service uses EntityReferenceRevisionsCommands
File
- src/
Commands/ EntityReferenceRevisionsCommands.php, line 13
Namespace
Drupal\entity_reference_revisions\CommandsView source
class EntityReferenceRevisionsCommands extends DrushCommands {
/**
* The purger service.
*
* @var \Drupal\entity_reference_revisions\EntityReferenceRevisionsOrphanPurger
*/
protected $purger;
/**
* Constructs a ERRCommands object.
*
* @param \Drupal\entity_reference_revisions\EntityReferenceRevisionsOrphanPurger $purger
*/
public function __construct(EntityReferenceRevisionsOrphanPurger $purger) {
$this->purger = $purger;
}
/**
* Orphan composite revision deletion.
*
* @param $types
* A comma delimited list of entity types to check for orphans. Omit to
* choose from a list.
* @usage drush err:purge paragraph
* Purge orphaned paragraphs.
*
* @command err:purge
* @aliases errp
*/
public function purge($types) {
$this->purger
->setBatch(StringUtils::csvToArray($types));
drush_backend_batch_process();
}
/**
* @hook interact err:purge
*/
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);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityReferenceRevisionsCommands:: |
protected | property | The purger service. | |
EntityReferenceRevisionsCommands:: |
public | function | @hook interact err:purge | |
EntityReferenceRevisionsCommands:: |
public | function | Orphan composite revision deletion. | |
EntityReferenceRevisionsCommands:: |
public | function | Constructs a ERRCommands object. |