diff --git a/src/Plugin/Action/AmiStrawberryfieldCSVexport.php b/src/Plugin/Action/AmiStrawberryfieldCSVexport.php index 0cc53c6..1787307 100644 --- a/src/Plugin/Action/AmiStrawberryfieldCSVexport.php +++ b/src/Plugin/Action/AmiStrawberryfieldCSVexport.php @@ -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) { @@ -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; } @@ -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 */ @@ -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.')); + } } }