Skip to content
Open
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
7 changes: 4 additions & 3 deletions app/src/Model/Entity/TAndCAgreement.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,23 @@ 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
if(!empty($this->terms_and_conditions_id)) {
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')) {
Expand Down
12 changes: 8 additions & 4 deletions app/src/Model/Entity/TermsAndConditions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion app/templates/TermsAndConditions/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
];