Skip to content

Commit

Permalink
Merge pull request #168 from aksm/ISSUE-161
Browse files Browse the repository at this point in the history
ISSUE-161: AMI CSV export fails when an ADO has a missing type key
  • Loading branch information
DiegoPino authored Jun 15, 2023
2 parents ae8db27 + 5bc02b0 commit 486cec3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Plugin/Action/AmiStrawberryfieldCSVexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public function setView(ViewExecutable $view) {
*/
public function executeMultiple(array $objects) {
$results = $response = $errors = [];
$this->context['sandbox']['ado_type_exists'] = TRUE;
foreach ($objects as $entity) {
$result = $this->execute($entity);
if ($result) {
Expand Down Expand Up @@ -275,8 +276,11 @@ public function execute($entity = NULL) {
}
}
}
if(!isset($fullvalues['type'])) {
$this->context['sandbox']['ado_type_exists'] = FALSE;
}
// If two types have different bundles only one will win. Do not do that ok?
if ($this->configuration['create_ami_set']) {
if ($this->configuration['create_ami_set'] && $this->context['sandbox']['ado_type_exists']) {
$this->context['sandbox']['type_bundle'] = $this->context['sandbox']['type_bundle'] ?? [];
$this->context['sandbox']['type_bundle'][$fullvalues['type']] = $entity->bundle().':'.$field_name;
}
Expand Down Expand Up @@ -362,7 +366,7 @@ protected function sendToFile($output) {
$data['data'] = $output;
$data['headers'] = $this->context['sandbox']['headers'];
$file_id = $this->AmiUtilityService->csv_save($data, 'node_uuid');
if ($file_id && $this->configuration['create_ami_set']) {
if ($file_id && $this->configuration['create_ami_set'] && $this->context['sandbox']['ado_type_exists']) {
$amisetdata = new \stdClass();
$amisetdata->plugin = 'spreadsheet';
/* start definitions to make php8 happy */
Expand Down Expand Up @@ -401,6 +405,10 @@ protected function sendToFile($output) {
['@url' => $url->toString()]));
}
}
else if ($this->configuration['create_ami_set'] && !$this->context['sandbox']['ado_type_exists']) {
$this->messenger()
->addStatus($this->t('AMI Set could not be created because object(s) are missing the type key.'));
}
}
}

Expand Down

0 comments on commit 486cec3

Please sign in to comment.