/
LevelField.php
50 lines (42 loc) · 1.17 KB
/
LevelField.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Concrete\Core\Logging\Search\Field\Field;
use Concrete\Core\Form\Service\Form;
use Concrete\Core\Logging\Levels;
use Concrete\Core\Logging\LogList;
use Concrete\Core\Search\Field\AbstractField;
use Concrete\Core\Search\ItemList\ItemList;
use Concrete\Core\Support\Facade\Application;
use Monolog\Logger as Monolog;
class LevelField extends AbstractField
{
protected $requestVariables = [
'level'
];
public function getKey()
{
return 'level';
}
public function getDisplayName()
{
return t('Level');
}
/**
* @param LogList $list
* @noinspection PhpDocSignatureInspection
*/
public function filterList(ItemList $list)
{
$list->filter('level', $this->getData('level'));
}
public function renderSearchField()
{
$app = Application::getFacadeApplication();
/** @var Form $form */
$form = $app->make(Form::class);
$levels = [];
foreach (Monolog::getLevels() as $level) {
$levels[$level] = Levels::getLevelDisplayName($level);
}
return $form->selectMultiple('level[]', $levels, $this->getData('level'));
}
}