Fixed: [export] Fix checking of null value: take also empty string value

This commit is contained in:
Julien Fastré 2023-01-11 17:42:50 +01:00
parent 582983f5ef
commit 01790fa0cf
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
42 changed files with 72 additions and 33 deletions

View File

@ -60,7 +60,7 @@ class ByCreatorAggregator implements AggregatorInterface
return 'Created by'; return 'Created by';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ class BySocialActionAggregator implements AggregatorInterface
return 'Social action'; return 'Social action';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ class BySocialIssueAggregator implements AggregatorInterface
return 'Social issues'; return 'Social issues';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ class ByThirdpartyAggregator implements AggregatorInterface
return 'Accepted thirdparty'; return 'Accepted thirdparty';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ class CreatorScopeAggregator implements AggregatorInterface
return 'Scope'; return 'Scope';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -71,7 +71,7 @@ class ActivityTypeAggregator implements AggregatorInterface
return 'Activity type'; return 'Activity type';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -66,7 +66,7 @@ class ActivityUserAggregator implements AggregatorInterface
return 'Activity user'; return 'Activity user';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -64,7 +64,7 @@ class ActivityUsersAggregator implements AggregatorInterface
return 'Activity users'; return 'Activity users';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -63,7 +63,7 @@ class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorI
return 'Users \'s job'; return 'Users \'s job';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -63,7 +63,7 @@ class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\Aggregato
return 'Users \'s scope'; return 'Users \'s scope';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -134,6 +134,10 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
return 'reasons' === $data['level'] ? 'Group by reasons' : 'Group by categories of reason'; return 'reasons' === $data['level'] ? 'Group by reasons' : 'Group by categories of reason';
} }
if (null === $value || '' === $value) {
return '';
}
switch ($data['level']) { switch ($data['level']) {
case 'reasons': case 'reasons':
$r = $this->activityReasonRepository->find($value); $r = $this->activityReasonRepository->find($value);

View File

@ -57,6 +57,7 @@ class SentReceivedAggregator implements AggregatorInterface
switch ($value) { switch ($value) {
case null: case null:
case '':
return ''; return '';
case 'sent': case 'sent':

View File

@ -66,6 +66,10 @@ final class AgentAggregator implements AggregatorInterface
return 'Agent'; return 'Agent';
} }
if (null === $value || '' === $value) {
return '';
}
$r = $this->userRepository->find($value); $r = $this->userRepository->find($value);
return $this->userRender->renderString($r, []); return $this->userRender->renderString($r, []);

View File

@ -67,6 +67,10 @@ class CancelReasonAggregator implements AggregatorInterface
return 'Cancel reason'; return 'Cancel reason';
} }
if (null === $value || '' === $value) {
return '';
}
$j = $this->cancelReasonRepository->find($value); $j = $this->cancelReasonRepository->find($value);
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(

View File

@ -66,6 +66,10 @@ final class JobAggregator implements AggregatorInterface
return 'Job'; return 'Job';
} }
if (null === $value || '' === $value) {
return '';
}
$j = $this->jobRepository->find($value); $j = $this->jobRepository->find($value);
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(

View File

@ -60,6 +60,10 @@ final class LocationAggregator implements AggregatorInterface
return 'Location'; return 'Location';
} }
if (null === $value || '' === $value) {
return '';
}
$l = $this->locationRepository->find($value); $l = $this->locationRepository->find($value);
return $l->getName(); return $l->getName();

View File

@ -66,6 +66,10 @@ final class ScopeAggregator implements AggregatorInterface
return 'Scope'; return 'Scope';
} }
if (null === $value || '' === $value) {
return '';
}
$s = $this->scopeRepository->find($value); $s = $this->scopeRepository->find($value);
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(

View File

@ -65,7 +65,7 @@ class AdministrativeLocationAggregator implements AggregatorInterface
return 'Administrative location'; return 'Administrative location';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -60,7 +60,7 @@ class ClosingMotiveAggregator implements AggregatorInterface
return 'Closing motive'; return 'Closing motive';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ class CreatorJobAggregator implements AggregatorInterface
return 'export.aggregator.course.by_creator_job.Creator\'s job'; return 'export.aggregator.course.by_creator_job.Creator\'s job';
} }
if (null === $value || null === $j = $this->jobRepository->find($value)) { if (null === $value || '' === $value || null === $j = $this->jobRepository->find($value)) {
return ''; return '';
} }

View File

@ -69,7 +69,7 @@ final class EvaluationAggregator implements AggregatorInterface
return 'Evaluation'; return 'Evaluation';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -143,7 +143,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
return 'acp_geog_agg_unitname'; return 'acp_geog_agg_unitname';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ final class JobAggregator implements AggregatorInterface
return 'Job'; return 'Job';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -67,7 +67,7 @@ final class OriginAggregator implements AggregatorInterface
return 'Origin'; return 'Origin';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -94,7 +94,7 @@ final class ReferrerAggregator implements AggregatorInterface
return 'Referrer'; return 'Referrer';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,11 +65,13 @@ final class ScopeAggregator implements AggregatorInterface
return 'Scope'; return 'Scope';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }
$s = $this->scopeRepository->find($value); if (null === $s = $this->scopeRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(
$s->getName() $s->getName()

View File

@ -66,11 +66,13 @@ final class SocialActionAggregator implements AggregatorInterface
return 'Social action'; return 'Social action';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }
$sa = $this->actionRepository->find($value); if (null === $sa = $this->actionRepository->find($value)) {
return '';
}
return $this->actionRender->renderString($sa, []); return $this->actionRender->renderString($sa, []);
}; };

View File

@ -66,6 +66,10 @@ final class SocialIssueAggregator implements AggregatorInterface
return 'Social issues'; return 'Social issues';
} }
if (null === $value || '' === $value) {
return '';
}
$i = $this->issueRepository->find($value); $i = $this->issueRepository->find($value);
return $this->issueRender->renderString($i, []); return $this->issueRender->renderString($i, []);

View File

@ -98,6 +98,7 @@ final class StepAggregator implements AggregatorInterface
return 'Step'; return 'Step';
case null: case null:
case '':
return ''; return '';
default: default:

View File

@ -60,7 +60,7 @@ class EvaluationTypeAggregator implements AggregatorInterface
return 'Evaluation type'; return 'Evaluation type';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -89,7 +89,7 @@ class CompositionAggregator implements AggregatorInterface
return 'Composition'; return 'Composition';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -105,7 +105,7 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
return 'export.aggregator.person.by_household_composition.Household composition'; return 'export.aggregator.person.by_household_composition.Household composition';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -66,6 +66,7 @@ final class GenderAggregator implements AggregatorInterface
return $this->translator->trans('unknown'); return $this->translator->trans('unknown');
case null: case null:
case '':
return $this->translator->trans('Not given'); return $this->translator->trans('Not given');
case '_header': case '_header':

View File

@ -101,7 +101,7 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
return 'Household position'; return 'Household position';
} }
if (null === $value) { if (null === $value || '' === $value) {
return $this->translator->trans('without data'); return $this->translator->trans('without data');
} }

View File

@ -63,6 +63,10 @@ final class MaritalStatusAggregator implements AggregatorInterface
return 'Marital status'; return 'Marital status';
} }
if (null === $value || '' === $value) {
return '';
}
$g = $this->maritalStatusRepository->find($value); $g = $this->maritalStatusRepository->find($value);
return $this->translatableStringHelper->localize($g->getName()); return $this->translatableStringHelper->localize($g->getName());

View File

@ -85,7 +85,7 @@ final class ActionTypeAggregator implements AggregatorInterface
return 'Social Action Type'; return 'Social Action Type';
} }
if (null === $value || null === $sa = $this->socialActionRepository->find($value)) { if (null === $value || '' === $value || null === $sa = $this->socialActionRepository->find($value)) {
return ''; return '';
} }

View File

@ -63,7 +63,7 @@ final class GoalAggregator implements AggregatorInterface
return 'Goal Type'; return 'Goal Type';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -72,7 +72,7 @@ class GoalResultAggregator implements AggregatorInterface
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
{ {
return function ($value) use ($key): string { return function ($value) use ($key): string {
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ final class JobAggregator implements AggregatorInterface
return 'Job'; return 'Job';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ final class ReferrerAggregator implements AggregatorInterface
return 'Referrer'; return 'Referrer';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -63,7 +63,7 @@ final class ResultAggregator implements AggregatorInterface
return 'Result Type'; return 'Result Type';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }

View File

@ -65,7 +65,7 @@ final class ScopeAggregator implements AggregatorInterface
return 'Scope'; return 'Scope';
} }
if (null === $value) { if (null === $value || '' === $value) {
return ''; return '';
} }