-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjects.php
More file actions
80 lines (68 loc) · 1.71 KB
/
Copy pathObjects.php
File metadata and controls
80 lines (68 loc) · 1.71 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
// SPDX-FileCopyrightText: 2023 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Icinga\Module\Notifications\Model;
use Icinga\Module\Notifications\Common\Model;
use Icinga\Module\Notifications\Model\Behavior\IdTagAggregator;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Query;
use ipl\Orm\Relations;
/**
* Object
*
* @property string $id
* @property int $source_id
* @property string $name
* @property ?string $url
*
* @property Query|Incident $incident
* @property Query|Tag $tag
* @property Query|Source $source
* @property array<string, string> $id_tags
*/
class Objects extends Model
{
public function getTableName(): string
{
return 'object';
}
public function getKeyName(): string
{
return 'id';
}
public function getColumns(): array
{
return [
'source_id',
'name',
'url'
];
}
/**
* @return string[]
*/
public function getSearchColumns(): array
{
return ['object_id_tag.tag', 'object_id_tag.value'];
}
/**
* @return string
*/
public function getDefaultSort(): string
{
return 'object.name';
}
public function createBehaviors(Behaviors $behaviors): void
{
$behaviors->add(new Binary(['id']));
$behaviors->add(new IdTagAggregator());
}
public function createRelations(Relations $relations): void
{
$relations->hasMany('incident', Incident::class);
$relations->hasMany('object_id_tag', ObjectIdTag::class);
$relations->hasMany('tag', Tag::class);
$relations->belongsTo('source', Source::class)->setJoinType('LEFT');
}
}