mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
MonitoringBackend: Enforce that views and queries are of a particular naming scheme
I'm adding this mainly to not to break support with modules which are utilizing our queries.
This commit is contained in:
parent
4996f569fe
commit
b6a7b43dd0
@ -263,21 +263,21 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
||||
/**
|
||||
* View name to class name resolution
|
||||
*
|
||||
* @param string $viewName
|
||||
* @param string $view
|
||||
*
|
||||
* @return string
|
||||
* @throws ProgrammingError When the view does not exist
|
||||
*
|
||||
* @throws ProgrammingError In case the view does not exist
|
||||
*/
|
||||
protected function buildViewClassName($view)
|
||||
{
|
||||
$class = '\\Icinga\\Module\\Monitoring\\DataView\\' . ucfirst($view);
|
||||
if (!class_exists($class)) {
|
||||
throw new ProgrammingError(
|
||||
'DataView %s does not exist',
|
||||
ucfirst($view)
|
||||
);
|
||||
$class = ucfirst(strtolower($view));
|
||||
$classPath = '\\Icinga\\Module\\Monitoring\\DataView\\' . $class;
|
||||
if (! class_exists($classPath)) {
|
||||
throw new ProgrammingError('DataView %s does not exist', $class);
|
||||
}
|
||||
return $class;
|
||||
|
||||
return $classPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,6 +287,8 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
||||
* @param array $columns Optional column list
|
||||
*
|
||||
* @return Icinga\Data\QueryInterface
|
||||
*
|
||||
* @throws ProgrammingError When the query does not exist for this backend
|
||||
*/
|
||||
public function query($name, $columns = null)
|
||||
{
|
||||
@ -318,16 +320,15 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
||||
/**
|
||||
* Query name to class name resolution
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $query
|
||||
*
|
||||
* @return string
|
||||
* @throws ProgrammingError When the query does not exist for this backend
|
||||
*/
|
||||
protected function buildQueryClassName($query)
|
||||
{
|
||||
$parts = preg_split('~\\\~', get_class($this));
|
||||
array_pop($parts);
|
||||
array_push($parts, 'Query', ucfirst($query) . 'Query');
|
||||
array_push($parts, 'Query', ucfirst(strtolower($query)) . 'Query');
|
||||
return implode('\\', $parts);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user