private static function template($action, $params) { CTemplate::$error = array(); switch ($action) { case 'add': $result = CTemplate::add($params); break; case 'get': $result = CTemplate::get($params); break; case 'getById': $result = CTemplate::getById($params); break; case 'getId': $result = CTemplate::getId($params); break; case 'update': $result = CTemplate::update($params); break; case 'linkHosts': $result = CTemplate::linkHosts($params); break; case 'unlinkHosts': $result = CTemplate::unlinkHosts($params); break; case 'linkTemplates': $result = CTemplate::linkTemplates($params); break; case 'unlinkTemplates': $result = CTemplate::unlinkTemplates($params); break; case 'delete': $result = CTemplate::delete($params); break; default: self::$result = array('error' => ZBX_API_ERROR_NO_METHOD, 'data' => 'Method: "' . $action . '" doesn\'t exist.'); return; //exit function } if ($result !== false) { self::$result = array('result' => $result); } else { self::$result = CTemplate::$error; } }