В СMS2 нет этих глобальных переменных

This commit is contained in:
Anatoly 2017-05-18 12:23:28 +03:00
parent 538239a6c4
commit a83f70422c
3 changed files with 27 additions and 9 deletions

View file

@ -45,10 +45,14 @@ function phptal_time ($e)
* Функция подключения компонента
*/
function phptal_component ($expression) {
global $db, $registry; // Нужно как-то передавать параметры
$begin = microtime(true);
$component = Controller_Component::loadComponent($expression, $db, $registry);
if(class_exists("Controller_Site")){ //Если мы в CMS2
$component = Controller_Site::loadComponent($match);
}else{
global $db, $registry; // Иначе обращаемся к глобальным переменным
$component = Controller_Component::loadComponent($expression, $db, $registry);
}
$req = new HttpRequest();
$result = $component->execute($req);