Created
April 10, 2023 01:29
-
-
Save halfhope/8bd0871244ae4fa54f62aaceb66d5945 to your computer and use it in GitHub Desktop.
Opencart check for the existance of a function in the model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// opencart 2.3, 3.x | |
private $_route = 'extension/module/pmp'; | |
private $_model = 'model_extension_module_pmp'; | |
$class_name = preg_replace('/[^a-zA-Z0-9]/', '', $this->_model); | |
if (is_callable([$class_name, 'getCachePrecomputedParams'])) { | |
$result = $this->{$this->_model}->getCachePrecomputedParams(); | |
} | |
// opencart 4 | |
private $_route = 'extension/pmp/module/pmp'; | |
private $_model = 'model_extension_pmp_module_pmp'; | |
$class_name = 'Opencart\\' . $this->config->get('application') . '\Model\\' . str_replace(['_', '/'], ['', '\\'], ucwords($this->_route, '_/')); | |
if (method_exists($class_name, 'getCachePrecomputedParams')) { | |
$result = $this->{$this->_model}->getCachePrecomputedParams(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment