A m?veletek felel?sek a modul '¨¹zleti logik¨¢j¨¢¨¦rt'. Egy m?velet ¨¢ltal¨¢ban egy ±¹±ð³ú¨¦°ù±ô?²ú?±ô ¨¦s egy m?velet n¨¦zetb?l ¨¢±ô±ô.
Egy modul k¨¦pes:
Egy alap¨¦rtelmezett m?veleti viselked¨¦s bizonyos egy¨¦ni viselked¨¦ssel t?rt¨¦n? fel¨¹lb¨ªr¨¢l¨¢s¨¢hoz adjon meg egy azonos nev? m?veletet a modulkonfigur¨¢ci¨®ban. A m?velet megh¨ªv¨¢sakor a modulm?velet ker¨¹l v¨¦grehajt¨¢sra az alap¨¦rtelmezett Áú»¢¶Ä²© m?velet helyett.
A m?veletf¨¢jlokat az actions mapp¨¢ban kell t¨¢rolni. A m?veleteket a manifest.json f¨¢jlban kell megadni.
Action controller workflow:
Check user permissions.
Prepare the data according to passed parameters: if checkInput() returns true, Áú»¢¶Ä²© calls the controller's doAction() method.
Prepare the $data array for the view. Use CControllerResponseData and setResponse() method to store response in the $data array.
Example:
/**
* Validate input parameters.
*
* @return bool
*/
protected function checkInput(): bool {
$ret = $this->validateInput([
'status' => 'in '.implode(',', [HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED])
]);
if (!$ret) {
$this->setResponse(new CControllerResponseFatal());
}
return $ret;
}
/**
* Check user permissions.
*
* @return bool
*/
protected function checkPermissions() {
return $this->getUserType() >= USER_TYPE_ZABBIX_ADMIN;
}
/**
* Execute action and generate response object.
*/
protected function do Action(): void {
$data = [
'hosts_count' => API::Host()->get([
'countOutput' => true,
'filter' => [
'status' => $this->getInput('status')
]
])
];
$this->setResponse(new CControllerResponseData($data));
}
You can view the full list of available controller classes in Áú»¢¶Ä²© .