From 8b85490f69492c01c88a3b9ae32ed614cf07e7b5 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Mon, 28 Sep 2026 14:45:34 +0000 Subject: [PATCH] Rename TermsAndConditions entity URL accessor to document_url to preserve database column value --- app/src/Model/Entity/TAndCAgreement.php | 7 ++++--- app/src/Model/Entity/TermsAndConditions.php | 12 ++++++++---- app/templates/TermsAndConditions/columns.inc | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/Model/Entity/TAndCAgreement.php b/app/src/Model/Entity/TAndCAgreement.php index dbc2ba0b5..a76075735 100644 --- a/app/src/Model/Entity/TAndCAgreement.php +++ b/app/src/Model/Entity/TAndCAgreement.php @@ -46,14 +46,15 @@ class TAndCAgreement extends Entity { /** * Get the URL for this Terms and Conditions Agreement. * - * @since COmanage Registry v5.3.0 * @return string|null URL + * @throws \Exception + * @since COmanage Registry v5.3.0 */ protected function _getUrl(): ?string { // If the associated TermsAndConditions is already loaded, check it first if(!empty($this->terms_and_conditions)) { - return $this->terms_and_conditions->url; + return $this->terms_and_conditions->document_url; } // Otherwise look up the Terms and Conditions if terms_and_conditions_id is present @@ -61,7 +62,7 @@ protected function _getUrl(): ?string { try { $TermsAndConditions = TableRegistry::getTableLocator()->get('TermsAndConditions'); - return $TermsAndConditions->get($this->terms_and_conditions_id)->url; + return $TermsAndConditions->get($this->terms_and_conditions_id)->document_url; } catch(\Exception $e) { // We will rethrow here to facilitate debugging if (Configure::read('debug')) { diff --git a/app/src/Model/Entity/TermsAndConditions.php b/app/src/Model/Entity/TermsAndConditions.php index a992791e5..83b939fca 100644 --- a/app/src/Model/Entity/TermsAndConditions.php +++ b/app/src/Model/Entity/TermsAndConditions.php @@ -43,17 +43,21 @@ class TermsAndConditions extends Entity { 'slug' => false, ]; + protected array $_virtual = [ + 'document_url' + ]; + /** - * Get the URL for this Terms and Conditions as a virtual field. + * Get the resolved document URL for this Terms and Conditions as a virtual field. * * @param string|null $url Existing URL field value * @return string|null URL * @throws \Exception * @since COmanage Registry v5.3.0 */ - protected function _getUrl(?string $url = null): ?string { - if(!empty($url)) { - return $url; + protected function _getDocumentUrl(?string $url = null): ?string { + if(!empty($this->url)) { + return $this->url; } if(!empty($this->mostly_static_page?->url)) { diff --git a/app/templates/TermsAndConditions/columns.inc b/app/templates/TermsAndConditions/columns.inc index f1248e8fd..50de04fec 100644 --- a/app/templates/TermsAndConditions/columns.inc +++ b/app/templates/TermsAndConditions/columns.inc @@ -49,6 +49,6 @@ $rowActions = [ [ 'icon' => 'arrow_outward', 'label' => __d('operation', 'visit.tandc'), - 'callbackUrl' => static fn($entity) => $entity->url + 'callbackUrl' => static fn($entity) => $entity->document_url ] ];