ContentUploadConfirmForm.php in GatherContent 8.3
File
src/Form/ContentUploadConfirmForm.php
View source
<?php
namespace Drupal\gathercontent\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\gathercontent\Entity\Operation;
use Drupal\node\Entity\Node;
class ContentUploadConfirmForm extends ContentConfirmForm {
public function getFormId() {
return 'node_update_from_gc_confirm';
}
public function getQuestion() {
return $this
->formatPlural(count($this->nodeIds), 'Confirm upload selection (@count item)', 'Confirm upload selection (@count items)');
}
public function getCancelUrl() {
return new Url('gathercontent.upload_select_form');
}
public function getDescription() {
return $this
->t('Please review your selection before uploading.');
}
public function getCancelText() {
return $this
->t('Back');
}
public function getConfirmText() {
return $this
->t('Upload');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue('confirm') && !empty($this->nodeIds)) {
$operation = Operation::create([
'type' => 'upload',
]);
$operation
->save();
$nodes = Node::loadMultiple($this->nodeIds);
$operations = [];
foreach ($nodes as $node) {
$operations[] = [
'gathercontent_upload_process',
[
$node,
$operation
->uuid(),
],
];
}
$batch = [
'title' => t('Uploading content ...'),
'operations' => $operations,
'finished' => 'gathercontent_upload_finished',
'init_message' => t('Upload is starting ...'),
'progress_message' => t('Processed @current out of @total.'),
'error_message' => t('An error occurred during processing'),
];
$this->tempStore
->delete('nodes');
batch_set($batch);
}
}
}