-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
monitoring/lib: Add iterator for iterating over non-pseudo monitoring…
… query columns refs #9956
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
modules/monitoring/library/Monitoring/Data/ColumnFilterIterator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ | ||
|
||
namespace Icinga\Module\Monitoring\Data; | ||
|
||
use ArrayIterator; | ||
use FilterIterator; | ||
use Zend_Db_Expr; | ||
|
||
/** | ||
* Iterator over non-pseudo monitoring query columns | ||
*/ | ||
class ColumnFilterIterator extends FilterIterator | ||
{ | ||
/** | ||
* Create a new ColumnFilterIterator | ||
* | ||
* @param array $columns | ||
*/ | ||
public function __construct(array $columns) | ||
{ | ||
parent::__construct(new ArrayIterator($columns)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function accept() | ||
{ | ||
$column = $this->current(); | ||
return ! ($column instanceof Zend_Db_Expr || $column === '(NULL)'); | ||
} | ||
} |