ResultSetPluginBase.php in Webform Scheduled Tasks 8.2
File
src/Plugin/WebformScheduledTasks/ResultSetPluginBase.php
View source
<?php
namespace Drupal\webform_scheduled_tasks\Plugin\WebformScheduledTasks;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\webform_scheduled_tasks\Entity\WebformScheduledTaskInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ResultSetPluginBase extends PluginBase implements ResultSetPluginInterface, ContainerFactoryPluginInterface {
protected $submissionQuery;
protected $scheduledTask;
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager')
->getStorage('webform_submission')
->getQuery());
}
public function __construct(array $configuration, $plugin_id, $plugin_definition, QueryInterface $submissionQuery) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
$this->submissionQuery = $submissionQuery;
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
public function defaultConfiguration() {
return [];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
if ($summary = $this
->getSummary()) {
$form['summary'] = [
'#markup' => $summary,
];
}
return $form;
}
protected function getSummary() {
return NULL;
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this
->setConfiguration($form_state
->getValues());
}
public function label() {
return $this
->getPluginDefinition()['label'];
}
public function onSuccess() {
}
public function onFailure() {
}
protected function initializeQueryDefaults() {
$this->submissionQuery
->accessCheck(FALSE);
$this->submissionQuery
->condition('webform_id', $this
->getScheduledTask()
->getWebform()
->id());
$this->submissionQuery
->condition('in_draft', FALSE);
$this->submissionQuery
->sort('sid');
}
public function setScheduledTask(WebformScheduledTaskInterface $scheduledTask) {
$this->scheduledTask = $scheduledTask;
return $this;
}
public function getScheduledTask() {
return $this->scheduledTask;
}
public function calculateDependencies() {
return [];
}
}