Skip to content

Commit

Permalink
COMCL-571: Add missing Smarty getversion method
Browse files Browse the repository at this point in the history
Included in CiviCRM 5.74.04
PR: civicrm#30286, civicrm#30508
  • Loading branch information
olayiwola-compucorp committed Jul 2, 2024
1 parent a88d8bf commit 4f58d1f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions CRM/Core/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,28 @@ public static function escape($string, $esc_type = 'html', $char_set = 'UTF-8')
return $value;
}

public function getVersion (): int {
static $version;
if ($version === NULL) {
if (class_exists('Smarty\Smarty')) {
$version = 5;
}
else {
$class = new ReflectionClass('Smarty');
$path = $class->getFileName();
if (str_contains($path, 'smarty3')) {
$version = 3;
}
elseif (str_contains($path, 'smarty4')) {
$version = 4;
}
else {
$version = 2;
}
}
}
return $version;

}

}

0 comments on commit 4f58d1f

Please sign in to comment.