Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cater for some "attached_to" CU fields being null in the DB #337

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/module/Api/src/Entity/Licence/Licence.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public function getGroupedConditionsUndertakings()
/** @var ConditionUndertaking $cu */
foreach ($conditionsUndertakings as &$cu) {
$conditionType = $map[$cu->getConditionType()->getId()];
if ($cu->getAttachedTo()->getId() === ConditionUndertaking::ATTACHED_TO_LICENCE) {
if ($cu->getAttachedTo()?->getId() === ConditionUndertaking::ATTACHED_TO_LICENCE) {
$licenceConditionsUndertakings[$conditionType][] = [
'notes' => $cu->getNotes(),
'createdOn' => $cu->getCreatedOn(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,10 @@ private function getConditionUndertakingText(ConditionUndertakingEntity $conditi
private function getAttachedToText(ConditionUndertakingEntity $conditionUndertaking)
{
$text = null;
if (
$conditionUndertaking->getAttachedTo()->getId() ===
ConditionUndertakingEntity::ATTACHED_TO_OPERATING_CENTRE
) {
if ($conditionUndertaking->getAttachedTo()?->getId() === ConditionUndertakingEntity::ATTACHED_TO_OPERATING_CENTRE) {
$text = 'Attached to Operating: ' .
$this->getAddressFormatter()->format($conditionUndertaking->getOperatingCentre()->getAddress());
} elseif ($conditionUndertaking->getAttachedTo()->getId() === ConditionUndertakingEntity::ATTACHED_TO_LICENCE) {
$this->getAddressFormatter()->format($conditionUndertaking->getOperatingCentre()?->getAddress());
} elseif ($conditionUndertaking->getAttachedTo()?->getId() === ConditionUndertakingEntity::ATTACHED_TO_LICENCE) {
$text = 'Attached to licence';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function generateTableRow(ConditionUndertaking $entity, $parentId = '')
$thisEntity['addedVia'] = $entity->getAddedVia()->getDescription();
$thisEntity['isFulfilled'] = $entity->getIsFulfilled();
$thisEntity['isDraft'] = $entity->getIsDraft();
$thisEntity['attachedTo'] = $entity->getAttachedTo()->getDescription();
$thisEntity['attachedTo'] = $entity->getAttachedTo()?->getDescription();
$thisEntity['notes'] = $entity->getNotes();

if (empty($entity->getOperatingCentre())) {
Expand Down
Loading