mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
Entity with enterprise capabilites
This commit is contained in:
parent
9d6fff0850
commit
23641e45bb
@ -372,6 +372,9 @@ define('MODULE_PREDICTION_CLUSTER_AP', 7);
|
|||||||
// Forced agent OS ID for cluster agents.
|
// Forced agent OS ID for cluster agents.
|
||||||
define('CLUSTER_OS_ID', 100);
|
define('CLUSTER_OS_ID', 100);
|
||||||
|
|
||||||
|
// Forced agent OS ID for satellite agents.
|
||||||
|
define('SATELLITE_OS_ID', 19);
|
||||||
|
|
||||||
// Type of Webserver Modules.
|
// Type of Webserver Modules.
|
||||||
define('MODULE_WEBSERVER_CHECK_LATENCY', 30);
|
define('MODULE_WEBSERVER_CHECK_LATENCY', 30);
|
||||||
define('MODULE_WEBSERVER_CHECK_SERVER_RESPONSE', 31);
|
define('MODULE_WEBSERVER_CHECK_SERVER_RESPONSE', 31);
|
||||||
|
@ -63,11 +63,16 @@ class Agent extends Entity
|
|||||||
) {
|
) {
|
||||||
$table = 'tagente';
|
$table = 'tagente';
|
||||||
$filter = ['id_agente' => $id_agent];
|
$filter = ['id_agente' => $id_agent];
|
||||||
|
$enterprise_class = '\PandoraFMS\Enterprise\Agent';
|
||||||
|
|
||||||
if (is_numeric($id_agent) === true
|
if (is_numeric($id_agent) === true
|
||||||
&& $id_agent > 0
|
&& $id_agent > 0
|
||||||
) {
|
) {
|
||||||
parent::__construct($table, $filter);
|
parent::__construct(
|
||||||
|
$table,
|
||||||
|
$filter,
|
||||||
|
$enterprise_class
|
||||||
|
);
|
||||||
if ($load_modules === true) {
|
if ($load_modules === true) {
|
||||||
$rows = \db_get_all_rows_filter(
|
$rows = \db_get_all_rows_filter(
|
||||||
'tagente_modulo',
|
'tagente_modulo',
|
||||||
@ -84,7 +89,7 @@ class Agent extends Entity
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create empty skel.
|
// Create empty skel.
|
||||||
parent::__construct($table);
|
parent::__construct($table, null, $enterprise_class);
|
||||||
|
|
||||||
// New agent has no modules.
|
// New agent has no modules.
|
||||||
$this->modulesLoaded = true;
|
$this->modulesLoaded = true;
|
||||||
|
@ -50,17 +50,28 @@ abstract class Entity
|
|||||||
*/
|
*/
|
||||||
protected $table = '';
|
protected $table = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enterprise capabilities object.
|
||||||
|
*
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
private $enterprise;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a generic constructor to extract information of the object.
|
* Defines a generic constructor to extract information of the object.
|
||||||
*
|
*
|
||||||
* @param string $table Table.
|
* @param string $table Table.
|
||||||
* @param array $filters Filters, for instance ['id' => $id].
|
* @param array|null $filters Filters, for instance ['id' => $id].
|
||||||
|
* @param string|null $enterprise Enterprise class name.
|
||||||
*
|
*
|
||||||
* @throws \Exception On error.
|
* @throws \Exception On error.
|
||||||
*/
|
*/
|
||||||
public function __construct(string $table, ?array $filters=null)
|
public function __construct(
|
||||||
{
|
string $table,
|
||||||
|
?array $filters=null,
|
||||||
|
?string $enterprise_class=null
|
||||||
|
) {
|
||||||
if (empty($table) === true) {
|
if (empty($table) === true) {
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
get_class($this).' error, table name is not defined'
|
get_class($this).' error, table name is not defined'
|
||||||
@ -96,6 +107,12 @@ abstract class Entity
|
|||||||
$this->fields[$row['Field']] = null;
|
$this->fields[$row['Field']] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (\enterprise_installed() === true
|
||||||
|
&& $enterprise_class !== null
|
||||||
|
) {
|
||||||
|
$this->enterprise = new $enterprise_class($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,6 +132,20 @@ abstract class Entity
|
|||||||
return $this->{$methodName}($params);
|
return $this->{$methodName}($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enterprise capabilities.
|
||||||
|
if (\enterprise_installed() === true
|
||||||
|
&& $this->enterprise !== null
|
||||||
|
&& method_exists($this->enterprise, $methodName) === true
|
||||||
|
) {
|
||||||
|
return call_user_func_array(
|
||||||
|
[
|
||||||
|
$this->enterprise,
|
||||||
|
$methodName,
|
||||||
|
],
|
||||||
|
$params
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists($methodName, $this->fields) === true) {
|
if (array_key_exists($methodName, $this->fields) === true) {
|
||||||
if (empty($params) === true) {
|
if (empty($params) === true) {
|
||||||
return $this->fields[$methodName];
|
return $this->fields[$methodName];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user