mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-06-04 14:22:23 -04:00
Stop using Resolver without a Query
This commit is contained in:
parent
dc4316044a
commit
9abc3b4d8f
2 changed files with 18 additions and 7 deletions
|
|
@ -9,15 +9,27 @@ use Icinga\Application\Benchmark;
|
|||
use Icinga\Module\Icingadb\Common\IcingaRedis;
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
use ipl\Orm\Query;
|
||||
use ipl\Orm\Resolver;
|
||||
use ipl\Orm\ResultSet;
|
||||
use RuntimeException;
|
||||
|
||||
class VolatileStateResults extends ResultSet
|
||||
{
|
||||
/** @var Resolver */
|
||||
private $resolver;
|
||||
|
||||
/** @var bool Whether Redis updates were applied */
|
||||
private $updatesApplied = false;
|
||||
|
||||
public static function fromQuery(Query $query)
|
||||
{
|
||||
$self = parent::fromQuery($query);
|
||||
$self->resolver = $query->getResolver();
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
if (! $this->updatesApplied && ! $this->isCacheDisabled) {
|
||||
|
|
@ -59,7 +71,7 @@ class VolatileStateResults extends ResultSet
|
|||
$hostStates = [];
|
||||
foreach ($this as $row) {
|
||||
if ($type === null) {
|
||||
$behaviors = (new Resolver())->getBehaviors($row->state);
|
||||
$behaviors = $this->resolver->getBehaviors($row->state);
|
||||
|
||||
switch (true) {
|
||||
case $row instanceof Host:
|
||||
|
|
|
|||
|
|
@ -169,8 +169,11 @@ class ObjectSuggestions extends Suggestions
|
|||
|
||||
protected function fetchColumnSuggestions($searchTerm)
|
||||
{
|
||||
$model = $this->getModel();
|
||||
$query = $model::on($this->getDb());
|
||||
|
||||
// Ordinary columns first
|
||||
foreach (self::collectFilterColumns($this->getModel()) as $columnName => $columnMeta) {
|
||||
foreach (self::collectFilterColumns($model, $query->getResolver()) as $columnName => $columnMeta) {
|
||||
yield $columnName => $columnMeta;
|
||||
}
|
||||
|
||||
|
|
@ -269,12 +272,8 @@ class ObjectSuggestions extends Suggestions
|
|||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public static function collectFilterColumns(Model $model, Resolver $resolver = null): Generator
|
||||
public static function collectFilterColumns(Model $model, Resolver $resolver): Generator
|
||||
{
|
||||
if ($resolver === null) {
|
||||
$resolver = new Resolver();
|
||||
}
|
||||
|
||||
$metaData = $resolver->getMetaData($model);
|
||||
foreach ($metaData as $columnName => $columnMeta) {
|
||||
yield $columnName => $columnMeta;
|
||||
|
|
|
|||
Loading…
Reference in a new issue