protected function GatherContentMigrateSource::getItems in GatherContent 8.5
Get all items for given project and template.
Return value
array All items.
2 calls to GatherContentMigrateSource::getItems()
- GatherContentMigrateSource::count in src/
Plugin/ migrate/ source/ GatherContentMigrateSource.php - Gets the source count.
- GatherContentMigrateSource::initializeIterator in src/
Plugin/ migrate/ source/ GatherContentMigrateSource.php - Initializes the iterator with the source data.
File
- src/
Plugin/ migrate/ source/ GatherContentMigrateSource.php, line 172
Class
- GatherContentMigrateSource
- A source class for Gathercontent API.
Namespace
Drupal\gathercontent\Plugin\migrate\sourceCode
protected function getItems() {
if ($this->items === NULL) {
$this->items = $this->client
->itemsGet($this->projectId, [
'template_id' => $this->templateId,
]);
// The first response will reveal the total number of pages. If there
// is more than one page, continue until total pages has been reached.
if (!empty($this->items['data'])) {
/** @var \Cheppers\GatherContent\DataTypes\Pagination $pagination */
$pagination = $this->items['pagination'];
$total_pages = $pagination->totalPages;
$current_page = $pagination->currentPage;
while ($current_page <= $total_pages) {
$query = [
'template_id' => $this->templateId,
'page' => $current_page + 1,
];
$next_items = $this->client
->itemsGet($this->projectId, $query);
if (!empty($next_items['data'])) {
$this->items['data'] = array_merge($this->items['data'], $next_items['data']);
}
$current_page++;
}
}
}
return $this
->convertItemsToArray($this->items['data']);
}