Skip to content

Commit

Permalink
Fix GUI CSV Actor export for translations. (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
melaniekung committed Mar 14, 2024
1 parent a41f2ad commit d733552
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/job/arActorExportJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ protected function doExport($path)
{
$search = self::findExportRecords($this->params);

$itemsExported = 0;

// Scroll through results then iterate through resulting IDs
foreach (arElasticSearchPluginUtil::getScrolledSearchResultIdentifiers($search) as $id) {
if (null === $resource = QubitActor::getById($id)) {
Expand All @@ -71,8 +73,31 @@ protected function doExport($path)
return;
}

$this->exportResource($resource, $path);
$this->csvActionExport($path, $resource);
$this->logExportProgress();
}
}

protected function csvActionExport($path, $resource)
{
$configuration = ProjectConfiguration::getApplicationConfiguration('qubit', 'prod', false);
$this->context = sfContext::createInstance($configuration);

// Prepare CSV exporter
$writer = new csvActorExport($path);
$writer->setOptions(['relations' => true]);

// Export actors and, optionally, related data
$cultures = array_keys(DefaultTranslationLinksComponent::getOtherCulturesAvailable($resource->actorI18ns, 'authorizedFormOfName', $resource->getAuthorizedFormOfName(['sourceCulture' => true])));

// Write row to file and initialize row
foreach ($cultures as $culture) {
$actor = QubitActor::getById($resource->id);
$this->context->getUser()->setCulture($culture);

$writer->exportResource($actor);
}

++$itemsExported;
}
}

0 comments on commit d733552

Please sign in to comment.