class WebformIteratorAggregate in Webform Scheduled Tasks 8.2
The WebformIteratorAggregate class.
Hierarchy
- class \Drupal\webform_scheduled_tasks\Iterator\WebformIteratorAggregate implements \Drupal\webform_scheduled_tasks\Iterator\IteratorAggregate, \Drupal\webform_scheduled_tasks\Iterator\Countable
Expanded class hierarchy of WebformIteratorAggregate
3 files declare their use of WebformIteratorAggregate
- AllSubmissions.php in src/
Plugin/ WebformScheduledTasks/ ResultSet/ AllSubmissions.php - SubmissionsCompletedSinceLastSuccess.php in src/
Plugin/ WebformScheduledTasks/ ResultSet/ SubmissionsCompletedSinceLastSuccess.php - WebformIteratorAggregateTest.php in tests/
src/ Unit/ WebformIteratorAggregateTest.php
File
- src/
Iterator/ WebformIteratorAggregate.php, line 11
Namespace
Drupal\webform_scheduled_tasks\IteratorView source
class WebformIteratorAggregate implements \IteratorAggregate, \Countable {
/**
* An array of webform submission IDs.
*
* @var array
*/
protected $submissionIds;
/**
* The chunk size.
*
* @var int
*/
protected $chunkSize;
/**
* The webform submission storage.
*
* @var \Drupal\Core\Entity\ContentEntityStorageInterface
*/
protected $submissionStorage;
/**
* WebformIteratorAggregate constructor.
*/
public function __construct($submissionIds, $chunkSize, ContentEntityStorageInterface $submissionStorage) {
$this->submissionIds = $submissionIds;
$this->chunkSize = $chunkSize;
$this->submissionStorage = $submissionStorage;
}
/**
* {@inheritdoc}
*/
public function count() {
return count($this->submissionIds);
}
/**
* {@inheritdoc}
*/
public function getIterator() {
foreach (array_chunk($this->submissionIds, $this->chunkSize) as $ids_chunk) {
foreach ($this->submissionStorage
->loadMultiple($ids_chunk) as $entity) {
(yield $entity);
}
}
}
/**
* Create an iterator aggregate from an entity query.
*
* @param \Drupal\Core\Entity\Query\QueryInterface $query
* An un-executed entity query for webform submissions.
*
* @return static
*/
public static function createFromQuery(QueryInterface $query) {
return new static($query
->execute(), 50, \Drupal::service('entity_type.manager')
->getStorage('webform_submission'));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformIteratorAggregate:: |
protected | property | The chunk size. | |
WebformIteratorAggregate:: |
protected | property | An array of webform submission IDs. | |
WebformIteratorAggregate:: |
protected | property | The webform submission storage. | |
WebformIteratorAggregate:: |
public | function | ||
WebformIteratorAggregate:: |
public static | function | Create an iterator aggregate from an entity query. | |
WebformIteratorAggregate:: |
public | function | ||
WebformIteratorAggregate:: |
public | function | WebformIteratorAggregate constructor. |