class Batch in Organic groups 8
Performs a batch deletion of orphans.
Plugin annotation
@OgDeleteOrphans(
id = "batch",
label = @Translation("Batch", context = "OgDeleteOrphans"),
description = @Translation("The deletion is done in a batch operation. Good for large websites with a lot of content."),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\og\OgDeleteOrphansBase implements ContainerFactoryPluginInterface, OgDeleteOrphansInterface uses StringTranslationTrait
- class \Drupal\og\Plugin\OgDeleteOrphans\Batch
- class \Drupal\og\OgDeleteOrphansBase implements ContainerFactoryPluginInterface, OgDeleteOrphansInterface uses StringTranslationTrait
Expanded class hierarchy of Batch
File
- src/
Plugin/ OgDeleteOrphans/ Batch.php, line 19
Namespace
Drupal\og\Plugin\OgDeleteOrphansView source
class Batch extends OgDeleteOrphansBase {
/**
* {@inheritdoc}
*/
public function process() {
$queue = $this
->getQueue();
$item = $queue
->claimItem(0);
$data = $item->data;
$this
->deleteOrphan($data['type'], $data['id']);
$queue
->deleteItem($item);
}
/**
* {@inheritdoc}
*/
public function configurationForm(array $form, FormStateInterface $form_state) {
$count = $this
->getQueue()
->numberOfItems();
return [
'#type' => 'fieldset',
'#title' => $this
->t('Batch options'),
'info' => [
'#markup' => '<p>' . $this
->t('There are :count orphans waiting to be deleted.', [
':count' => $count,
]) . '</p>',
],
'submit' => [
'#type' => 'submit',
'#value' => $this
->t('Start batch deletion'),
'#submit' => [
'\\Drupal\\og\\Plugin\\OgDeleteOrphans\\Batch::batchSubmit',
],
'#disabled' => !(bool) $count,
],
];
}
/**
* Submit handler for ::configurationForm().
*/
public static function batchSubmit($form, FormStateInterface $form_state) {
$batch = [];
$steps = \Drupal::queue('og_orphaned_group_content')
->numberOfItems();
for ($i = 0; $i < $steps; $i++) {
$batch['operations'][] = [
'\\Drupal\\og\\Plugin\\OgDeleteOrphans\\Batch::step',
[],
];
}
batch_set($batch);
}
/**
* Batch step definition callback to process one queue item.
*/
public static function step($context) {
if (!empty($context['interrupted'])) {
return;
}
\Drupal::getContainer()
->get('plugin.manager.og.delete_orphans')
->createInstance('batch', [])
->process();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Batch:: |
public static | function | Submit handler for ::configurationForm(). | |
Batch:: |
public | function |
Returns the configuration form elements specific to this plugin. Overrides OgDeleteOrphansBase:: |
|
Batch:: |
public | function |
Starts the deletion process. Overrides OgDeleteOrphansInterface:: |
|
Batch:: |
public static | function | Batch step definition callback to process one queue item. | |
OgDeleteOrphansBase:: |
protected | property | The entity type manager. | |
OgDeleteOrphansBase:: |
protected | property | The OG group audience helper. | |
OgDeleteOrphansBase:: |
protected | property | The OG membership manager. | |
OgDeleteOrphansBase:: |
protected | property | The queue factory. | |
OgDeleteOrphansBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
OgDeleteOrphansBase:: |
protected | function | Deletes an orphaned group content entity if it is fully orphaned. | |
OgDeleteOrphansBase:: |
protected | function | Returns the queue of orphans to delete. | 1 |
OgDeleteOrphansBase:: |
protected | function | Queries the registered group entity for orphaned members to delete. | |
OgDeleteOrphansBase:: |
public | function |
Registers a soon to be deleted group entity, for processing. Overrides OgDeleteOrphansInterface:: |
1 |
OgDeleteOrphansBase:: |
public | function |
Constructs an OgDeleteOrphansBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |